@kerros/editor 0.0.0-stage → 0.1.0-rc.2

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 (345) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -2
  3. package/dist/SitePlanner.js +1189 -0
  4. package/dist/SitePlanner.js.map +1 -0
  5. package/dist/adapters/basemap.js +11 -0
  6. package/dist/adapters/basemap.js.map +1 -0
  7. package/dist/adapters/persistence.js +121 -0
  8. package/dist/adapters/persistence.js.map +1 -0
  9. package/dist/adapters/status.js +11 -0
  10. package/dist/adapters/status.js.map +1 -0
  11. package/dist/adapters/useProjectPersistence.js +56 -0
  12. package/dist/adapters/useProjectPersistence.js.map +1 -0
  13. package/dist/components/AiImportPanel.js +635 -0
  14. package/dist/components/AiImportPanel.js.map +1 -0
  15. package/dist/components/AnalysisPreview.js +179 -0
  16. package/dist/components/AnalysisPreview.js.map +1 -0
  17. package/dist/components/ElevatorPanel.js +120 -0
  18. package/dist/components/ElevatorPanel.js.map +1 -0
  19. package/dist/components/Icons.js +57 -0
  20. package/dist/components/Icons.js.map +1 -0
  21. package/dist/components/ImportDialog.js +467 -0
  22. package/dist/components/ImportDialog.js.map +1 -0
  23. package/dist/components/Inspector.js +1184 -0
  24. package/dist/components/Inspector.js.map +1 -0
  25. package/dist/components/NavigatePanel.js +301 -0
  26. package/dist/components/NavigatePanel.js.map +1 -0
  27. package/dist/components/NavigationGraph.js +234 -0
  28. package/dist/components/NavigationGraph.js.map +1 -0
  29. package/dist/components/StructureExplorer.js +510 -0
  30. package/dist/components/StructureExplorer.js.map +1 -0
  31. package/dist/components/StructureView.js +286 -0
  32. package/dist/components/StructureView.js.map +1 -0
  33. package/dist/components/controls.js +209 -0
  34. package/dist/components/controls.js.map +1 -0
  35. package/dist/components/graphLayout.js +27 -0
  36. package/dist/components/graphLayout.js.map +1 -0
  37. package/dist/host.js +175 -0
  38. package/dist/host.js.map +1 -0
  39. package/dist/i18n.js +88 -0
  40. package/dist/i18n.js.map +1 -0
  41. package/dist/import/analysisPreview.js +41 -0
  42. package/dist/import/analysisPreview.js.map +1 -0
  43. package/dist/import/brief.js +29 -0
  44. package/dist/import/brief.js.map +1 -0
  45. package/dist/import/checkpoint.js +50 -0
  46. package/dist/import/checkpoint.js.map +1 -0
  47. package/dist/import/detect.js +120 -0
  48. package/dist/import/detect.js.map +1 -0
  49. package/dist/import/documentSvg.js +49 -0
  50. package/dist/import/documentSvg.js.map +1 -0
  51. package/dist/import/instructions.js +20 -0
  52. package/dist/import/instructions.js.map +1 -0
  53. package/dist/import/openings.js +61 -0
  54. package/dist/import/openings.js.map +1 -0
  55. package/dist/import/planImport.js +233 -0
  56. package/dist/import/planImport.js.map +1 -0
  57. package/dist/import/register.js +47 -0
  58. package/dist/import/register.js.map +1 -0
  59. package/dist/import/runs.js +67 -0
  60. package/dist/import/runs.js.map +1 -0
  61. package/dist/import/session.js +23 -0
  62. package/dist/import/session.js.map +1 -0
  63. package/dist/import/types.js +13 -0
  64. package/dist/import/types.js.map +1 -0
  65. package/dist/import/usage.js +29 -0
  66. package/dist/import/usage.js.map +1 -0
  67. package/dist/import/walls.js +112 -0
  68. package/dist/import/walls.js.map +1 -0
  69. package/dist/index.js +178 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/map/CabinMaterials.js +81 -0
  72. package/dist/map/CabinMaterials.js.map +1 -0
  73. package/dist/map/CabinMirror.js +43 -0
  74. package/dist/map/CabinMirror.js.map +1 -0
  75. package/dist/map/Doors.js +80 -0
  76. package/dist/map/Doors.js.map +1 -0
  77. package/dist/map/ElevatorCabin.js +93 -0
  78. package/dist/map/ElevatorCabin.js.map +1 -0
  79. package/dist/map/FixtureLights.js +117 -0
  80. package/dist/map/FixtureLights.js.map +1 -0
  81. package/dist/map/MapCanvas.js +2161 -0
  82. package/dist/map/MapCanvas.js.map +1 -0
  83. package/dist/map/Passenger.js +69 -0
  84. package/dist/map/Passenger.js.map +1 -0
  85. package/dist/map/SceneLayer.js +1534 -0
  86. package/dist/map/SceneLayer.js.map +1 -0
  87. package/dist/map/UndergroundContext.js +153 -0
  88. package/dist/map/UndergroundContext.js.map +1 -0
  89. package/dist/map/ambience.js +194 -0
  90. package/dist/map/ambience.js.map +1 -0
  91. package/dist/map/architecture.js +305 -0
  92. package/dist/map/architecture.js.map +1 -0
  93. package/dist/map/bathMusic.js +92 -0
  94. package/dist/map/bathMusic.js.map +1 -0
  95. package/dist/map/cameraAim.js +33 -0
  96. package/dist/map/cameraAim.js.map +1 -0
  97. package/dist/map/elevators.js +56 -0
  98. package/dist/map/elevators.js.map +1 -0
  99. package/dist/map/excavation.js +52 -0
  100. package/dist/map/excavation.js.map +1 -0
  101. package/dist/map/exteriors.js +25 -0
  102. package/dist/map/exteriors.js.map +1 -0
  103. package/dist/map/features.js +218 -0
  104. package/dist/map/features.js.map +1 -0
  105. package/dist/map/fences.js +29 -0
  106. package/dist/map/fences.js.map +1 -0
  107. package/dist/map/journey.js +112 -0
  108. package/dist/map/journey.js.map +1 -0
  109. package/dist/map/levels.js +6 -0
  110. package/dist/map/levels.js.map +1 -0
  111. package/dist/map/lighting.js +143 -0
  112. package/dist/map/lighting.js.map +1 -0
  113. package/dist/map/loadBasemap.js +26 -0
  114. package/dist/map/loadBasemap.js.map +1 -0
  115. package/dist/map/materials.js +183 -0
  116. package/dist/map/materials.js.map +1 -0
  117. package/dist/map/poolLighting.js +39 -0
  118. package/dist/map/poolLighting.js.map +1 -0
  119. package/dist/map/projection.js +24 -0
  120. package/dist/map/projection.js.map +1 -0
  121. package/dist/map/rampGeometry.js +38 -0
  122. package/dist/map/rampGeometry.js.map +1 -0
  123. package/dist/map/route.js +107 -0
  124. package/dist/map/route.js.map +1 -0
  125. package/dist/map/stairSurfaces.js +115 -0
  126. package/dist/map/stairSurfaces.js.map +1 -0
  127. package/dist/map/surfaces.js +136 -0
  128. package/dist/map/surfaces.js.map +1 -0
  129. package/dist/map/textures.js +95 -0
  130. package/dist/map/textures.js.map +1 -0
  131. package/dist/map/underground.js +34 -0
  132. package/dist/map/underground.js.map +1 -0
  133. package/dist/map/walk.js +433 -0
  134. package/dist/map/walk.js.map +1 -0
  135. package/dist/map/walkContext.js +46 -0
  136. package/dist/map/walkContext.js.map +1 -0
  137. package/dist/map/walkDimensions.js +7 -0
  138. package/dist/map/walkDimensions.js.map +1 -0
  139. package/dist/map/walkJourney.js +85 -0
  140. package/dist/map/walkJourney.js.map +1 -0
  141. package/dist/map/walkSurfaces.js +106 -0
  142. package/dist/map/walkSurfaces.js.map +1 -0
  143. package/dist/map/wallJoins.js +70 -0
  144. package/dist/map/wallJoins.js.map +1 -0
  145. package/dist/map/water.js +274 -0
  146. package/dist/map/water.js.map +1 -0
  147. package/dist/model/authoring.js +99 -0
  148. package/dist/model/authoring.js.map +1 -0
  149. package/dist/model/boundaries.js +548 -0
  150. package/dist/model/boundaries.js.map +1 -0
  151. package/dist/model/coverage.js +30 -0
  152. package/dist/model/coverage.js.map +1 -0
  153. package/dist/model/document.js +52 -0
  154. package/dist/model/document.js.map +1 -0
  155. package/dist/model/doors.js +47 -0
  156. package/dist/model/doors.js.map +1 -0
  157. package/dist/model/factory.js +56 -0
  158. package/dist/model/factory.js.map +1 -0
  159. package/dist/model/geometry.js +454 -0
  160. package/dist/model/geometry.js.map +1 -0
  161. package/dist/model/history.js +29 -0
  162. package/dist/model/history.js.map +1 -0
  163. package/dist/model/imports.js +45 -0
  164. package/dist/model/imports.js.map +1 -0
  165. package/dist/model/inference.js +182 -0
  166. package/dist/model/inference.js.map +1 -0
  167. package/dist/model/materials.js +11 -0
  168. package/dist/model/materials.js.map +1 -0
  169. package/dist/model/mutations.js +157 -0
  170. package/dist/model/mutations.js.map +1 -0
  171. package/dist/model/navigation.js +275 -0
  172. package/dist/model/navigation.js.map +1 -0
  173. package/dist/model/ontology.js +109 -0
  174. package/dist/model/ontology.js.map +1 -0
  175. package/dist/model/passages.js +5 -0
  176. package/dist/model/passages.js.map +1 -0
  177. package/dist/model/portals.js +42 -0
  178. package/dist/model/portals.js.map +1 -0
  179. package/dist/model/precision.js +11 -0
  180. package/dist/model/precision.js.map +1 -0
  181. package/dist/model/project.js +31 -0
  182. package/dist/model/project.js.map +1 -0
  183. package/dist/model/ramps.js +10 -0
  184. package/dist/model/ramps.js.map +1 -0
  185. package/dist/model/roomNavigation.js +87 -0
  186. package/dist/model/roomNavigation.js.map +1 -0
  187. package/dist/model/routeClearance.js +72 -0
  188. package/dist/model/routeClearance.js.map +1 -0
  189. package/dist/model/spaces.js +104 -0
  190. package/dist/model/spaces.js.map +1 -0
  191. package/dist/model/stairGeometry.js +40 -0
  192. package/dist/model/stairGeometry.js.map +1 -0
  193. package/dist/model/stairTraversal.js +48 -0
  194. package/dist/model/stairTraversal.js.map +1 -0
  195. package/dist/model/topology.js +63 -0
  196. package/dist/model/topology.js.map +1 -0
  197. package/dist/model/types.js +35 -0
  198. package/dist/model/types.js.map +1 -0
  199. package/dist/model/validate.js +240 -0
  200. package/dist/model/validate.js.map +1 -0
  201. package/dist/model/vertical.js +129 -0
  202. package/dist/model/vertical.js.map +1 -0
  203. package/dist/model/walls.js +261 -0
  204. package/dist/model/walls.js.map +1 -0
  205. package/dist/planner/DrawingDock.js +231 -0
  206. package/dist/planner/DrawingDock.js.map +1 -0
  207. package/dist/planner/FloorControls.js +93 -0
  208. package/dist/planner/FloorControls.js.map +1 -0
  209. package/dist/planner/MapSettings.js +143 -0
  210. package/dist/planner/MapSettings.js.map +1 -0
  211. package/dist/planner/PlannerHelp.js +57 -0
  212. package/dist/planner/PlannerHelp.js.map +1 -0
  213. package/dist/planner/ProjectSidebar.js +246 -0
  214. package/dist/planner/ProjectSidebar.js.map +1 -0
  215. package/dist/planner/floors.js +18 -0
  216. package/dist/planner/floors.js.map +1 -0
  217. package/dist/planner/useDrawingTools.js +341 -0
  218. package/dist/planner/useDrawingTools.js.map +1 -0
  219. package/dist/planner/useMapDisplay.js +51 -0
  220. package/dist/planner/useMapDisplay.js.map +1 -0
  221. package/dist/planner/usePlannerKeyboard.js +138 -0
  222. package/dist/planner/usePlannerKeyboard.js.map +1 -0
  223. package/dist/planner/useReferenceAlignment.js +50 -0
  224. package/dist/planner/useReferenceAlignment.js.map +1 -0
  225. package/dist/styles.css +4931 -0
  226. package/dist/theme/index.js +34 -0
  227. package/dist/theme/index.js.map +1 -0
  228. package/dist/types/SitePlanner.d.ts +5 -0
  229. package/dist/types/adapters/basemap.d.ts +2 -0
  230. package/dist/types/adapters/persistence.d.ts +29 -0
  231. package/dist/types/adapters/status.d.ts +4 -0
  232. package/dist/types/adapters/useProjectPersistence.d.ts +13 -0
  233. package/dist/types/components/AiImportPanel.d.ts +9 -0
  234. package/dist/types/components/AnalysisPreview.d.ts +4 -0
  235. package/dist/types/components/ElevatorPanel.d.ts +18 -0
  236. package/dist/types/components/Icons.d.ts +8 -0
  237. package/dist/types/components/ImportDialog.d.ts +42 -0
  238. package/dist/types/components/Inspector.d.ts +38 -0
  239. package/dist/types/components/NavigatePanel.d.ts +27 -0
  240. package/dist/types/components/NavigationGraph.d.ts +10 -0
  241. package/dist/types/components/StructureExplorer.d.ts +8 -0
  242. package/dist/types/components/StructureView.d.ts +22 -0
  243. package/dist/types/components/controls.d.ts +52 -0
  244. package/dist/types/components/graphLayout.d.ts +9 -0
  245. package/dist/types/editor/host.d.ts +9 -0
  246. package/dist/types/editor/index.d.ts +2 -0
  247. package/dist/types/i18n.d.ts +85 -0
  248. package/dist/types/import/analysisPreview.d.ts +27 -0
  249. package/dist/types/import/brief.d.ts +22 -0
  250. package/dist/types/import/checkpoint.d.ts +49 -0
  251. package/dist/types/import/detect.d.ts +34 -0
  252. package/dist/types/import/documentSvg.d.ts +2 -0
  253. package/dist/types/import/index.d.ts +10 -0
  254. package/dist/types/import/instructions.d.ts +7 -0
  255. package/dist/types/import/openings.d.ts +22 -0
  256. package/dist/types/import/planImport.d.ts +22 -0
  257. package/dist/types/import/register.d.ts +25 -0
  258. package/dist/types/import/runs.d.ts +31 -0
  259. package/dist/types/import/session.d.ts +33 -0
  260. package/dist/types/import/types.d.ts +56 -0
  261. package/dist/types/import/usage.d.ts +10 -0
  262. package/dist/types/import/walls.d.ts +37 -0
  263. package/dist/types/map/CabinMaterials.d.ts +18 -0
  264. package/dist/types/map/CabinMirror.d.ts +13 -0
  265. package/dist/types/map/Doors.d.ts +11 -0
  266. package/dist/types/map/ElevatorCabin.d.ts +20 -0
  267. package/dist/types/map/FixtureLights.d.ts +35 -0
  268. package/dist/types/map/MapCanvas.d.ts +87 -0
  269. package/dist/types/map/Passenger.d.ts +18 -0
  270. package/dist/types/map/SceneLayer.d.ts +306 -0
  271. package/dist/types/map/UndergroundContext.d.ts +18 -0
  272. package/dist/types/map/ambience.d.ts +29 -0
  273. package/dist/types/map/architecture.d.ts +8 -0
  274. package/dist/types/map/bathMusic.d.ts +14 -0
  275. package/dist/types/map/cameraAim.d.ts +20 -0
  276. package/dist/types/map/elevators.d.ts +16 -0
  277. package/dist/types/map/excavation.d.ts +9 -0
  278. package/dist/types/map/exteriors.d.ts +3 -0
  279. package/dist/types/map/features.d.ts +33 -0
  280. package/dist/types/map/fences.d.ts +4 -0
  281. package/dist/types/map/journey.d.ts +36 -0
  282. package/dist/types/map/levels.d.ts +4 -0
  283. package/dist/types/map/lighting.d.ts +103 -0
  284. package/dist/types/map/loadBasemap.d.ts +4 -0
  285. package/dist/types/map/materials.d.ts +38 -0
  286. package/dist/types/map/poolLighting.d.ts +11 -0
  287. package/dist/types/map/projection.d.ts +9 -0
  288. package/dist/types/map/rampGeometry.d.ts +8 -0
  289. package/dist/types/map/route.d.ts +59 -0
  290. package/dist/types/map/stairSurfaces.d.ts +29 -0
  291. package/dist/types/map/surfaces.d.ts +36 -0
  292. package/dist/types/map/textures.d.ts +8 -0
  293. package/dist/types/map/underground.d.ts +30 -0
  294. package/dist/types/map/walk.d.ts +232 -0
  295. package/dist/types/map/walkContext.d.ts +11 -0
  296. package/dist/types/map/walkDimensions.d.ts +5 -0
  297. package/dist/types/map/walkJourney.d.ts +33 -0
  298. package/dist/types/map/walkSurfaces.d.ts +27 -0
  299. package/dist/types/map/wallJoins.d.ts +6 -0
  300. package/dist/types/map/water.d.ts +12 -0
  301. package/dist/types/model/authoring.d.ts +38 -0
  302. package/dist/types/model/boundaries.d.ts +41 -0
  303. package/dist/types/model/coverage.d.ts +8 -0
  304. package/dist/types/model/document.d.ts +9 -0
  305. package/dist/types/model/doors.d.ts +19 -0
  306. package/dist/types/model/factory.d.ts +5 -0
  307. package/dist/types/model/geometry.d.ts +99 -0
  308. package/dist/types/model/history.d.ts +10 -0
  309. package/dist/types/model/host.d.ts +154 -0
  310. package/dist/types/model/imports.d.ts +7 -0
  311. package/dist/types/model/inference.d.ts +46 -0
  312. package/dist/types/model/live.d.ts +60 -0
  313. package/dist/types/model/materials.d.ts +28 -0
  314. package/dist/types/model/mutations.d.ts +178 -0
  315. package/dist/types/model/navigation.d.ts +70 -0
  316. package/dist/types/model/ontology.d.ts +43 -0
  317. package/dist/types/model/passages.d.ts +2 -0
  318. package/dist/types/model/portals.d.ts +9 -0
  319. package/dist/types/model/precision.d.ts +11 -0
  320. package/dist/types/model/project.d.ts +8 -0
  321. package/dist/types/model/ramps.d.ts +7 -0
  322. package/dist/types/model/roomNavigation.d.ts +15 -0
  323. package/dist/types/model/routeClearance.d.ts +11 -0
  324. package/dist/types/model/spaces.d.ts +46 -0
  325. package/dist/types/model/stairGeometry.d.ts +27 -0
  326. package/dist/types/model/stairTraversal.d.ts +8 -0
  327. package/dist/types/model/topology.d.ts +14 -0
  328. package/dist/types/model/types.d.ts +369 -0
  329. package/dist/types/model/validate.d.ts +38 -0
  330. package/dist/types/model/vertical.d.ts +145 -0
  331. package/dist/types/model/walls.d.ts +71 -0
  332. package/dist/types/planner/DrawingDock.d.ts +16 -0
  333. package/dist/types/planner/FloorControls.d.ts +17 -0
  334. package/dist/types/planner/MapSettings.d.ts +16 -0
  335. package/dist/types/planner/PlannerHelp.d.ts +3 -0
  336. package/dist/types/planner/ProjectSidebar.d.ts +32 -0
  337. package/dist/types/planner/floors.d.ts +3 -0
  338. package/dist/types/planner/types.d.ts +3 -0
  339. package/dist/types/planner/useDrawingTools.d.ts +52 -0
  340. package/dist/types/planner/useMapDisplay.d.ts +29 -0
  341. package/dist/types/planner/usePlannerKeyboard.d.ts +18 -0
  342. package/dist/types/planner/useReferenceAlignment.d.ts +30 -0
  343. package/dist/types/schema/index.d.ts +25 -0
  344. package/dist/types/theme/index.d.ts +55 -0
  345. package/package.json +58 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapCanvas.js","sources":["../../../../src/map/MapCanvas.tsx"],"sourcesContent":["import { doorSymbol, draggedDoorSwing } from '../model/doors';\nimport {\n Fragment,\n lazy,\n Suspense,\n useEffect,\n useMemo,\n useRef,\n useState,\n type CSSProperties,\n type PointerEvent as ReactPointerEvent,\n} from 'react';\nimport * as maplibregl from 'maplibre-gl';\nimport type {\n ExpressionSpecification,\n FilterSpecification,\n GeoJSONSource,\n ImageSource,\n Map as GLMap,\n VisibilitySpecification,\n} from 'maplibre-gl';\nimport { Compass, LocateFixed, Minus, Mountain, PersonStanding, Plus, RotateCcw, RotateCw } from 'lucide-react';\nimport polygonClipping from 'polygon-clipping';\nimport {\n isSpace,\n type AssetRepository,\n type Point,\n type ProjectDocument,\n type SiteObject,\n type Tool,\n} from '../model/types';\nimport type { StatusReading } from '../model/live';\nimport type { BasemapConfig, ElevatorControls } from '../model/host';\nimport {\n add,\n barrierEnds,\n segmentProjection,\n closeRing,\n distance,\n drawingCorners,\n objectArea,\n objectPosition,\n openRing,\n pointInRing,\n ringArea,\n rotate,\n toLngLat,\n toLocal,\n rectangle,\n} from '../model/geometry';\nimport { statusLabel, statusTone } from '../adapters/status';\nimport { useKerrosTheme, useStrings, type MapStyleOptions } from '../theme';\nimport { neutralBasemap } from '../adapters/basemap';\nimport { ambient, mixColor, type Sun, sunlight } from './lighting';\nimport { EntityIcon } from '../components/Icons';\nimport { draftFeatures, makeFeatures, navGraphFeatures, onFloor, visibleOnFloor } from './features';\nimport { boundaryEdges } from '../model/boundaries';\nimport { ROUTE_COLOR, ROUTE_EDGE, ROUTE_SOFT, routeArrowImage, routeFeatures, routeFlowGradient } from './route';\nimport { aimCenter, cameraPosition, cameraToCenterDistance, floorAim } from './cameraAim';\nimport type { JourneyPlayer } from './journey';\nimport type { WalkJourney, WalkJourneyHost } from './walkJourney';\nimport type { Route } from '../model/navigation';\nimport { LIFT, SLAB } from './levels';\nimport { floorArrival, floorSupport, walkingWallRings } from './walkSurfaces';\nimport type { SceneLayer } from './SceneLayer';\nimport { stairSurfaces } from './stairSurfaces';\nimport {\n DEFAULT_WALK_FOV,\n EYE,\n MAX_MAP_ZOOM,\n MAX_WALK_FOV,\n MIN_WALK_FOV,\n unstick,\n walkFieldOfView,\n type WalkAvatar,\n WalkController,\n type WalkPose,\n} from './walk';\nimport { AmbienceEngine, ambienceAt } from './ambience';\nimport { inSpace, spaceAt, spacePoint } from '../model/spaces';\nimport { servedFloors } from '../model/vertical';\nimport { floorIndex, undergroundView } from './underground';\nimport { loadBasemap } from './loadBasemap';\n// Passenger controls are needed only while walking with a host lift controller.\nconst ElevatorPanel = lazy(() => import('../components/ElevatorPanel').then(m => ({ default: m.ElevatorPanel })));\nimport { elevatorWalls } from './elevators';\n\n// Cadastral parcels come from a host-declared vector tilejson (see BasemapVectorSchema.cadastre):\n// parcel polygons, boundary lines/markers and parcel-id labels styled per theme.\n// The tilejson describes the {z}/{y}/{x} template; transformRequest appends the api-key.\nexport interface MapCanvasProps {\n project: ProjectDocument;\n canEdit: boolean;\n floorId: string | null;\n selected: string | null;\n tool: Tool;\n draft: Point[];\n hover: Point | null;\n /** Alignment hints drawn under the draft: the axis a wall is being held to, or a whole segment\n * the tool is offering. Both are previews — nothing here exists in the document yet. */\n guides?: { line: [Point, Point]; role: 'guide' | 'proposal' }[];\n threeD: boolean;\n stack: boolean;\n coverage: boolean;\n showLabels: boolean;\n showPlan: boolean;\n /** Where the sun stands over this project now. Carries its own `evening` for the dusk look. */\n sun: Sun;\n dark: boolean;\n cityBuildings: boolean;\n cadastre: boolean;\n basemap?: BasemapConfig;\n assets: AssetRepository;\n statuses: Map<string, StatusReading>;\n elevators?: ElevatorControls;\n /** Draw the soil section around below-grade floors. */\n excavation?: boolean;\n /** First-person walk mode: the camera becomes a person standing on `floorId`. Requires threeD.\n * While it is on the map's own gestures are off and the floor is drawn at ground level. */\n walk?: boolean;\n /** Walk mode wants out (Escape). */\n onWalkExit?: () => void;\n /** Where the walker last stood, or was dropped — the person, kept apart from the camera. Drawn on\n * its floor in the other modes, and a walk resumes from it when it is in view. */\n avatar?: WalkAvatar | null;\n /** The walker moved. Throttled to a few times a second, and once more on leaving the walk. */\n onAvatar?: (avatar: WalkAvatar) => void;\n /** The person marker was dropped on the map, or the avatar clicked: walk from here. */\n onWalkAt?: (avatar: WalkAvatar) => void;\n focusId?: string | null;\n alignment?: { image: Point[]; map: Point[] };\n /** Exact camera to restore (deep links); suppresses the automatic fit and 3D tilt-in on load. */\n initialCamera?: { center: [number, number]; zoom: number; bearing: number; pitch: number };\n route?: Route | null; // render route in 2D + 3D whenever set\n activeStep?: number | null; // emphasised step\n playing?: boolean; // journey animation on/off\n onJourneyStep?: (index: number) => void; // fired as the camera reaches each step\n onJourneyEnd?: () => void; // journey finished or was cancelled by user gesture\n onRequestFloor?: (floorId: string | null) => void; // journey asks the app to switch floors\n onClick: (point: Point, entityId: string | null) => void;\n onHover: (point: Point, tolerance: number) => void;\n onAdopt?: (adopted: { rings: Point[][]; sourceId: string | number; storeys: number; name: string }) => void;\n // Method syntax keeps a host handler with the pre-'node' union assignable while A-workstreams land.\n onSelect: (id: string) => void;\n onHoverObject?: (id: string | null) => void;\n /** Lightweight snapped preview. Model validation runs on release, before committing the drop. */\n onVertexPreview?: (\n kind: 'junction' | 'barrier' | 'ring',\n id: string,\n point: Point,\n ring?: number,\n vertex?: number,\n free?: boolean,\n ) => Point;\n snapping?: boolean;\n onVertexMove(\n kind: 'junction' | 'ring' | 'object' | 'barrier' | 'node' | 'opening' | 'rotate' | 'coverage',\n id: string,\n point: Point,\n ring?: number,\n vertex?: number,\n /** Shift was held on release: take the drop exactly as given, ignoring any snapping. */\n free?: boolean,\n ): void;\n onError: (message: string) => void;\n onReady?: (map: GLMap) => void;\n}\nconst EMPTY_FEATURES: GeoJSON.FeatureCollection = { type: 'FeatureCollection', features: [] };\nconst DIM_FEATURES: GeoJSON.FeatureCollection = {\n type: 'FeatureCollection',\n features: [\n {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Polygon',\n coordinates: [\n [\n [-180, -85],\n [180, -85],\n [180, 85],\n [-180, 85],\n [-180, -85],\n ],\n ],\n },\n },\n ],\n};\n\nfunction planFeatures(p: MapCanvasProps, mapStyle?: MapStyleOptions): GeoJSON.FeatureCollection {\n // Three owns the plan in 3D. Status updates must not rebuild hidden 2D geometry in a worker.\n if (p.threeD) return EMPTY_FEATURES;\n const entities = makeFeatures(p.project, p.floorId, p.selected, p.coverage, p.statuses, mapStyle);\n // An intermediate (mezzanine) level draws in context: the level below stays visible dimmed\n // under its own rooms and the level above appears as a faint dashed outline.\n const activeFloor = p.project.floors.find(f => f.id === p.floorId);\n if (activeFloor?.mezzanine && !p.threeD) {\n const band = p.project.floors.filter(f => f.buildingId === activeFloor.buildingId && f.id !== activeFloor.id);\n const lower = band.filter(f => f.elevation < activeFloor.elevation).sort((a, b) => b.elevation - a.elevation)[0];\n const upper = band.filter(f => f.elevation > activeFloor.elevation).sort((a, b) => a.elevation - b.elevation)[0];\n const ctx = (fl: typeof lower, level: string, walls: boolean) =>\n fl\n ? makeFeatures(p.project, fl.id, null, false)\n .features.filter(\n f =>\n f.properties?.floorId === fl.id &&\n !f.properties.decoration &&\n (walls || f.properties.kind !== 'wall') &&\n f.geometry.type === 'Polygon',\n )\n .map(f => ({ ...f, properties: { kind: f.properties!.kind, color: f.properties!.color, context: level } }))\n : [];\n entities.features = [...ctx(lower, 'lower', true), ...entities.features, ...ctx(upper, 'upper', false)];\n }\n return entities;\n}\n\n/** The map heading that puts the plan square on screen.\n *\n * A project's local frame is already turned by its origin bearing, so a site laid out along its\n * street has axis-aligned coordinates and a heading to match. Opening the map due north then shows\n * that plan standing at an angle — and every \"reset north\" put it back at that angle. The frame the\n * drawing was made in is the one to read it in, so north-up means site-up. A project with no\n * bearing is unaffected: its frame IS north. */\nconst siteBearing = (project: ProjectDocument) => project.origin[2] ?? 0;\n/** What walk mode tells the person walking: where they are, and what the level keys would do here. */\ninterface WalkHint {\n looking: boolean;\n /** The building's sound is playing (M turns it off). */\n sound: boolean;\n up: string | null;\n down: string | null;\n where: string;\n /** The next thing the active route asks you to do, and how far off it is. */\n next: string;\n}\nconst NO_HINT: WalkHint = { looking: false, sound: true, up: null, down: null, where: '', next: '' };\n/** Where the walker's choice to mute lives between walks. A person who turned the hum off does not\n * want it back on at the next door. */\nconst MUTED_KEY = 'kerros:walk-muted';\nconst FOV_KEY = 'kerros:walk-fov';\n\nexport function MapCanvas(props: MapCanvasProps) {\n const container = useRef<HTMLDivElement>(null),\n map = useRef<GLMap | null>(null),\n scene = useRef<SceneLayer | null>(null),\n latest = useRef(props),\n urls = useRef(new Map<string, string>());\n latest.current = props;\n const [ready, setReady] = useState(false),\n [frame, setFrame] = useState(0),\n [mapError, setMapError] = useState(''),\n [pitch, setPitch] = useState(0);\n useEffect(() => {\n const pan = (event: KeyboardEvent) => {\n const p = latest.current;\n if (p.threeD || p.walk || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.isComposing)\n return;\n if (\n (event.target as HTMLElement)?.closest('input, textarea, select, dialog, [contenteditable], [role=\"textbox\"]')\n )\n return;\n if (p.canEdit && p.tool !== 'select' && p.tool !== 'pan') return;\n const delta: Record<string, [number, number]> = { w: [0, -140], a: [-140, 0], s: [0, 140], d: [140, 0] };\n const offset = delta[event.key.toLowerCase()];\n if (!offset || !map.current) return;\n event.preventDefault();\n event.stopImmediatePropagation();\n map.current.panBy(offset, { duration: 250 });\n };\n window.addEventListener('keydown', pan, true);\n return () => window.removeEventListener('keydown', pan, true);\n }, []);\n // The 3D renderer, once fetched. A ref rather than state: sync() reads it imperatively, and a\n // re-render is asked for explicitly when it lands.\n const sceneModule = useRef<typeof import('./SceneLayer').SceneLayer | null>(null);\n const scenePending = useRef<Promise<void> | null>(null);\n const loadScene = () => {\n scenePending.current ??= import('./SceneLayer').then(m => {\n sceneModule.current = m.SceneLayer;\n });\n return scenePending.current;\n };\n // Fetch the 3D module alongside map/style initialization. Waiting for syncLayers serialized\n // the downloads behind the first map build, then rebuilt the plan again on every completion.\n useEffect(() => {\n if (!props.threeD || !props.showPlan) return;\n let active = true;\n void loadScene()\n .then(() => {\n if (!active) return;\n // A cached project/style may already be ready. A marker-frame update alone does not\n // rerun the scene-sync effect, leaving 3D blank until a later floor or status change.\n sync();\n setFrame(n => n + 1);\n })\n .catch(error => {\n scenePending.current = null;\n if (active) setMapError(`The 3D view could not load: ${String(error)}`);\n });\n return () => {\n active = false;\n };\n }, [props.threeD, props.showPlan]);\n const suppressClick = useRef(false),\n overlay = useRef<HTMLDivElement>(null),\n hoverId = useRef<string | null>(null);\n const styleReady = useRef(false);\n const mapStyle = useKerrosTheme().mapStyle;\n const mapStyleRef = useRef(mapStyle);\n mapStyleRef.current = mapStyle;\n const strings = useStrings().map;\n const stringsRef = useRef(strings);\n stringsRef.current = strings;\n const entityFeatures = useMemo(\n () => planFeatures(props, mapStyle),\n [\n props.project,\n props.floorId,\n props.selected,\n props.coverage,\n props.threeD,\n props.threeD ? null : props.statuses,\n mapStyle,\n ],\n );\n const draftData = useMemo(\n () => draftFeatures(props.project, props.draft, props.hover, props.tool) as GeoJSON.FeatureCollection,\n [props.project, props.draft, props.hover, props.tool],\n );\n const guideData = useMemo<GeoJSON.FeatureCollection>(\n () => ({\n type: 'FeatureCollection',\n features: [\n ...(props.guides ?? []),\n ...(props.canEdit && !props.threeD\n ? (props.project.virtualBoundaries ?? [])\n .filter(e => e.floorId === props.floorId)\n .map(e => ({ id: e.id, role: 'boundary', line: barrierEnds(props.project, e) }))\n : []),\n ].map(g => ({\n type: 'Feature' as const,\n properties: { role: g.role, ...('id' in g ? { id: g.id, kind: 'boundary' } : {}) },\n geometry: { type: 'LineString' as const, coordinates: g.line.map(pt => toLngLat(pt, props.project.origin)) },\n })),\n }),\n [props.guides, props.project, props.floorId, props.canEdit, props.threeD],\n );\n // 'route' joins the Tool union in the authoring workstream; the cast keeps this file self-contained.\n const routeTool = (props.tool as string) === 'route';\n const navSelected =\n !!props.selected &&\n (!!props.project.navNodes?.some(n => n.id === props.selected) ||\n !!props.project.navEdges?.some(e => e.id === props.selected));\n const routeData = useMemo(\n () =>\n props.route && !props.threeD\n ? (routeFeatures(\n props.project,\n props.route,\n props.floorId,\n props.activeStep ?? null,\n ) as GeoJSON.FeatureCollection)\n : EMPTY_FEATURES,\n [props.project, props.route, props.floorId, props.activeStep, props.threeD],\n );\n const navGraphData = useMemo(\n () =>\n !props.threeD && props.canEdit && (routeTool || navSelected)\n ? (navGraphFeatures(props.project, props.floorId, props.selected) as GeoJSON.FeatureCollection)\n : EMPTY_FEATURES,\n [props.project, props.floorId, props.selected, props.threeD, props.canEdit, routeTool, navSelected],\n );\n const entityData = useRef(entityFeatures),\n draftSourceData = useRef(draftData),\n routeSourceData = useRef(routeData),\n guideSourceData = useRef(guideData),\n navSourceData = useRef(navGraphData);\n entityData.current = entityFeatures;\n draftSourceData.current = draftData;\n guideSourceData.current = guideData;\n routeSourceData.current = routeData;\n navSourceData.current = navGraphData;\n const journey = useRef<JourneyPlayer | null>(null);\n const appliedSourceData = useRef(new Map<string, GeoJSON.FeatureCollection>());\n const objectsById = useMemo(() => new Map(props.project.objects.map(o => [o.id, o])), [props.project]);\n const objectIndex = useRef(objectsById);\n objectIndex.current = objectsById;\n const clampTooltip = (e: { currentTarget: HTMLElement }) => {\n const tip = e.currentTarget.querySelector<HTMLElement>('.marker-tooltip');\n const wrap = container.current;\n if (!tip || !wrap) return;\n const w = wrap.getBoundingClientRect(),\n r = e.currentTarget.getBoundingClientRect(),\n half = tip.offsetWidth / 2 + 10;\n tip.classList.toggle('flip-y', r.top - w.top < tip.offsetHeight + 24);\n tip.classList.toggle('nudge-left', r.left + half > w.right);\n tip.classList.toggle('nudge-right', r.left - half < w.left);\n };\n /** Indoors at eye level the basemap is under the floor you stand on and behind the walls around\n * you: none of it is in the frame. At walking pitch the map runs to the horizon, so the vector\n * tiles it would fetch and draw for the far side of the city are the most expensive thing on a\n * screen they do not appear on. Hide every layer that is not ours; a source no visible layer\n * draws is one MapLibre stops loading tiles for. Remembered per layer and put back on the way\n * out, so a basemap that hides its own layers by zoom keeps its arrangement. */\n const veiled = useRef(new Map<string, VisibilitySpecification>());\n const veilBasemap = () => {\n const m = map.current;\n if (!m || !m.getStyle()) return;\n const p = latest.current;\n const hide = !!p.walk && p.floorId !== null;\n if (hide) {\n for (const layer of m.getStyle().layers ?? []) {\n if (layer.id.startsWith('kerros-') || layer.type === 'background' || veiled.current.has(layer.id)) continue;\n veiled.current.set(\n layer.id,\n (m.getLayoutProperty(layer.id, 'visibility') as VisibilitySpecification | undefined) ?? 'visible',\n );\n m.setLayoutProperty(layer.id, 'visibility', 'none');\n }\n } else if (veiled.current.size) {\n for (const [id, was] of veiled.current) if (m.getLayer(id)) m.setLayoutProperty(id, 'visibility', was);\n veiled.current.clear();\n }\n };\n useEffect(() => {\n if (ready) veilBasemap();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.walk, props.floorId, ready]);\n // Overlay symbols follow the camera imperatively so they never trail a pan while React catches up.\n const reposition = () => {\n const m = map.current,\n el = overlay.current,\n p = latest.current;\n if (!m || !el) return;\n const byId = objectIndex.current;\n for (const child of Array.from(el.children) as HTMLElement[]) {\n const { wx, wy, oid, floor, bearing } = child.dataset;\n if (wx === undefined || wy === undefined) continue;\n // The avatar faces a compass bearing; on screen that is relative to the way the map is turned.\n if (bearing !== undefined) child.style.setProperty('--turn', `${Number(bearing) - m.getBearing()}deg`);\n if (p.threeD && floor !== undefined) {\n const s = scene.current?.projectPoint([Number(wx), Number(wy)], floor || null);\n if (s) {\n child.style.left = `${s.x}px`;\n child.style.top = `${s.y}px`;\n child.style.visibility = s.visible ? '' : 'hidden';\n }\n } else if (p.threeD && oid) {\n const o = byId.get(oid);\n const s = o && scene.current?.projectObject(o);\n if (s) {\n child.style.left = `${s.x}px`;\n child.style.top = `${s.y}px`;\n child.style.visibility = s.visible ? '' : 'hidden';\n }\n } else {\n const s = m.project(toLngLat([Number(wx), Number(wy)], p.project.origin));\n child.style.left = `${s.x + Number(child.dataset.screenDx ?? 0)}px`;\n child.style.top = `${s.y + Number(child.dataset.screenDy ?? 0)}px`;\n child.style.visibility = '';\n }\n }\n };\n // Basemap buildings adopted into the project or standing under a project parcel are excluded\n // from the generic city massing — the project's own model renders there instead.\n const cityHidden = useRef('');\n // Accumulated, never rebuilt from scratch. The set is discovered by querying the tiles that happen\n // to be loaded, and tiles come and go: rebuilt each pass, a footprint identified a moment ago as\n // standing under the project's own parcel would be forgotten the moment its tile unloaded, the\n // filter would widen again, and the city massing would be drawn back over the model — which, since\n // an extrusion writes depth, swallows the floor plate whole and leaves a building with a hole in\n // it. Once a footprint is known to be ours it stays ours. Cleared with the style.\n const cityIds = useRef(new Set<string | number>());\n /** The basemap's own footprint layers, with the filter each carried before we narrowed it. */\n const footprintFilters = useRef(new Map<string, unknown>());\n const refreshCityFilter = () => {\n const m = map.current,\n p = latest.current;\n const fp = p.basemap?.vectorSchema?.footprints;\n if (!m || !fp || !m.getLayer('kerros-city-3d')) return;\n // Out of 3D the model is not standing there, so the basemap's building is the only one there is\n // and gets its own filter back. The massing layer's own visibility already follows the toggle,\n // so narrowing it costs nothing — but the flat fill has to be narrowed whatever the toggle says,\n // or turning the city massing off would bring the box back with it.\n if (!p.threeD || undergroundView(p.project, p.floorId, p.stack).buried) {\n for (const [id, was] of footprintFilters.current)\n if (m.getLayer(id)) m.setFilter(id, (was ?? undefined) as FilterSpecification | undefined);\n footprintFilters.current.clear();\n cityHidden.current = '';\n return;\n }\n const source = (m.getLayer('kerros-city-3d') as unknown as { source: string }).source;\n const parcels = p.project.objects.filter(o => o.kind === 'parcel' && o.rings);\n const ids = cityIds.current;\n for (const b of p.project.buildings) if (b.sourceId !== undefined) ids.add(b.sourceId);\n for (const f of m.querySourceFeatures(source, { sourceLayer: fp.sourceLayer })) {\n const fid = f.properties?.[fp.idField] as string | number | undefined;\n if (fid === undefined || ids.has(fid)) continue;\n const g = f.geometry;\n const ring = g.type === 'Polygon' ? g.coordinates[0] : g.type === 'MultiPolygon' ? g.coordinates[0][0] : null;\n if (!ring) continue;\n const c = ring.reduce<Point>((s, pt) => [s[0] + pt[0] / ring.length, s[1] + pt[1] / ring.length], [0, 0]);\n const local = toLocal(c, p.project.origin);\n if (parcels.some(o => pointInRing(local, o.rings![0]))) ids.add(fid);\n }\n const next = JSON.stringify([...ids].sort());\n if (next === cityHidden.current) return;\n cityHidden.current = next;\n const mine = ['!', ['in', ['get', fp.idField], ['literal', [...ids]]]] as unknown as FilterSpecification;\n m.setFilter('kerros-city-3d', mine);\n // And out of the basemap's own flat building fill, which is the half of this that was missed.\n // A vector style paints its buildings as an opaque fill, and an opaque fill is drawn in a pass\n // of its own that writes depth — so however late the model's layer is added, the basemap's\n // building can still win over the floor plate inside it, while the walls, standing on the\n // footprint's edge, survive. That is the box of flat basemap colour over the building: the plan\n // is not missing, the map is drawn on top of it. Where our own model stands, the basemap's\n // building has nothing left to say.\n for (const layer of m.getStyle().layers) {\n if (layer.id === 'kerros-city-3d' || !('source-layer' in layer) || layer['source-layer'] !== fp.sourceLayer)\n continue;\n if (!footprintFilters.current.has(layer.id))\n footprintFilters.current.set(layer.id, m.getFilter(layer.id) ?? null);\n const was = footprintFilters.current.get(layer.id) as FilterSpecification | null;\n m.setFilter(layer.id, (was ? ['all', was, mine] : mine) as FilterSpecification);\n }\n };\n // Adopt tool: turn the clicked basemap building footprint (all tile pieces, unioned) into local\n // rings, carrying its stable source id so the grey massing hides once our own model exists.\n const adoptAt = (point: { x: number; y: number }) => {\n const m = map.current,\n p = latest.current;\n const fp = p.basemap?.vectorSchema?.footprints;\n if (!m || !fp) return;\n const layers = m\n .getStyle()\n .layers.filter(l => 'source-layer' in l && l['source-layer'] === fp.sourceLayer && l.id !== 'kerros-city-3d')\n .map(l => l.id);\n const hit = layers.length\n ? m\n .queryRenderedFeatures(\n [\n [point.x - 3, point.y - 3],\n [point.x + 3, point.y + 3],\n ],\n { layers },\n )\n .find(f => f.properties?.[fp.idField] !== undefined)\n : undefined;\n if (!hit) {\n p.onError(stringsRef.current.adoptMiss);\n return;\n }\n const id = hit.properties[fp.idField] as string | number;\n const polys: Point[][][] = [];\n for (const f of m.queryRenderedFeatures(undefined, {\n layers,\n filter: ['==', ['get', fp.idField], id] as unknown as FilterSpecification,\n })) {\n const g = f.geometry;\n if (g.type === 'Polygon') polys.push(g.coordinates.map(r => r.map(pt => toLocal(pt as Point, p.project.origin))));\n else if (g.type === 'MultiPolygon')\n for (const poly of g.coordinates)\n polys.push(poly.map(r => r.map(pt => toLocal(pt as Point, p.project.origin))));\n }\n try {\n const union = polygonClipping.union(...(polys.map(poly => [poly]) as [Point[][][]]));\n const best = ([...union] as Point[][][]).sort((a, b) => ringArea(b[0] as Point[]) - ringArea(a[0] as Point[]))[0];\n // Tile geometry is quantised; drop micro-edges so wall segments stay valid and clean.\n const tidy = (ring: Point[]) => {\n const out: Point[] = [];\n for (const pt of openRing(ring))\n if (!out.length || Math.hypot(pt[0] - out[out.length - 1][0], pt[1] - out[out.length - 1][1]) > 0.2)\n out.push(pt);\n while (\n out.length > 2 &&\n Math.hypot(out[0][0] - out[out.length - 1][0], out[0][1] - out[out.length - 1][1]) < 0.2\n )\n out.pop();\n return out;\n };\n const rings = best.map(tidy).filter(r => r.length >= 3);\n if (!rings.length) throw new Error('degenerate footprint');\n p.onAdopt?.({\n rings,\n sourceId: id,\n storeys: fp.storeys?.(hit.properties) ?? 1,\n name: fp.name?.(hit.properties) ?? 'City building',\n });\n } catch {\n p.onError(stringsRef.current.adoptFail);\n }\n };\n // Draft/hover geometry is a handful of points; updating it must never rebuild the whole plan.\n const syncDraft = () => {\n const m = map.current;\n if (!styleReady.current || !m?.getSource('kerros-draft')) return;\n for (const [name, data] of [\n ['kerros-draft', draftSourceData.current],\n ['kerros-guide', guideSourceData.current],\n ] as const) {\n (m.getSource(name) as GeoJSONSource).setData(data);\n appliedSourceData.current.set(name, data);\n }\n };\n const sync = () => {\n const m = map.current,\n p = latest.current;\n // style.load means layers can be added. isStyleLoaded() also waits for external tiles and\n // would incorrectly hide the plan while MML resources are pending or unavailable.\n if (!m || !styleReady.current) return;\n // Adding a source/layer throws while a freshly-swapped style is still resolving its own\n // sources; that must never abort the plan build. Retry once the map settles.\n try {\n syncLayers(m, p);\n } catch {\n m.once('idle', sync);\n }\n };\n const syncLayers = (m: GLMap, p: MapCanvasProps) => {\n // setStyle(diff:false) wipes registered images on every basemap swap; re-add here, not at mount.\n if (!m.hasImage('kerros-route-arrow')) m.addImage('kerros-route-arrow', routeArrowImage());\n const sources = {\n dim: DIM_FEATURES,\n entities: entityData.current,\n draft: draftSourceData.current,\n guide: guideSourceData.current,\n route: routeSourceData.current,\n navgraph: navSourceData.current,\n };\n for (const [id, data] of Object.entries(sources)) {\n const name = `kerros-${id}`;\n // lineMetrics only on the route: it is what makes `line-progress` available, which is what the\n // travelling highlight is drawn with. It cannot be turned on after the fact, and it is not free\n // on sources with a lot of line geometry, so nothing else asks for it.\n if (!m.getSource(name)) m.addSource(name, { type: 'geojson', data, lineMetrics: id === 'route' });\n else if (appliedSourceData.current.get(name) !== data) (m.getSource(name) as GeoJSONSource).setData(data);\n appliedSourceData.current.set(name, data);\n }\n if (!m.getLayer('kerros-areas')) {\n // Selection/hover/draft highlight colours come from the theme's mapStyle (host-brandable),\n // falling back to the built-in indigo.\n const ms = mapStyleRef.current;\n const sel = ms?.selection ?? '#5a52d5';\n const selFill = ms?.selectionFill ?? '#c8c4f5';\n const hoverColor = ms?.hover ?? sel;\n const draftColor = ms?.draft ?? sel;\n // Area fill opacity as a pure data expression, parameterised by what a `small` feature gets at\n // this zoom stop. Kept as a function so the two zoom stops cannot drift apart.\n const areaOpacity = (small: number): ExpressionSpecification =>\n [\n 'case',\n ['==', ['get', 'kind'], 'coverage'],\n 0.13,\n ['==', ['get', 'kind'], 'status-halo'],\n 0.22,\n ['==', ['get', 'context'], 'lower'],\n 0.35,\n ['==', ['get', 'context'], 'upper'],\n 0,\n ['==', ['get', 'selected'], true],\n 1,\n ['==', ['get', 'small'], true],\n small,\n 1,\n ] as ExpressionSpecification;\n // Two-basemap composition: the real taustakartta below everything, and an opaque\n // architectural \"drawing paper\" clipped to the premises parcel above it. In dark mode a\n // translucent veil dims the basemap so the plan stays the brightest surface.\n m.addLayer({\n id: 'kerros-dim',\n type: 'fill',\n source: 'kerros-dim',\n paint: { 'fill-color': '#0d0f16', 'fill-opacity': 0.55 },\n });\n // Below-ground floors bury the basemap: streets, water and city context read as soil.\n m.addLayer({\n id: 'kerros-underground',\n type: 'fill',\n source: 'kerros-dim',\n paint: { 'fill-color': '#262320', 'fill-opacity': 0.985 },\n });\n m.addLayer({\n id: 'kerros-premises',\n type: 'fill',\n source: 'kerros-entities',\n filter: ['all', ['==', ['geometry-type'], 'Polygon'], ['==', ['get', 'kind'], 'parcel']],\n paint: { 'fill-color': '#f3f4f0', 'fill-opacity': 0.97 },\n });\n m.addLayer({\n id: 'kerros-premises-line',\n type: 'line',\n source: 'kerros-entities',\n filter: ['all', ['==', ['geometry-type'], 'Polygon'], ['==', ['get', 'kind'], 'parcel']],\n paint: { 'line-color': '#9aa0ac', 'line-width': 1.5, 'line-dasharray': [4, 2] },\n });\n m.addLayer({\n id: 'kerros-areas',\n type: 'fill',\n source: 'kerros-entities',\n filter: [\n 'all',\n ['==', ['geometry-type'], 'Polygon'],\n ['!=', ['get', 'kind'], 'wall'],\n ['!=', ['get', 'kind'], 'parcel'],\n ],\n paint: {\n 'fill-color': ['case', ['==', ['get', 'selected'], true], selFill, ['get', 'color']],\n // Zoom expressions must be the OUTERMOST expression in a paint property — MapLibre throws\n // (and silently drops the whole layer) if one is nested inside a `case`. So the data-driven\n // chain is evaluated at each zoom stop, differing only in what a `small` feature gets.\n 'fill-opacity': ['interpolate', ['linear'], ['zoom'], 18.6, areaOpacity(0), 19.6, areaOpacity(1)],\n },\n });\n m.addLayer({\n id: 'kerros-outline',\n type: 'line',\n source: 'kerros-entities',\n filter: [\n 'all',\n ['==', ['geometry-type'], 'Polygon'],\n ['!=', ['get', 'kind'], 'furniture'],\n ['!=', ['get', 'kind'], 'parcel'],\n ['!=', ['get', 'context'], 'upper'],\n ],\n paint: {\n 'line-color': ['case', ['==', ['get', 'selected'], true], sel, '#a7adbb'],\n 'line-width': ['case', ['==', ['get', 'selected'], true], 2, 0.8],\n // A narrow area is only a few pixels wide at building zoom; outlining hundreds of them\n // (a garage of bays, a warehouse of racks) reads as a hatch rather than a plan. Fade them\n // in once they are big enough to tell apart — a selected one always draws.\n 'line-opacity': [\n 'interpolate',\n ['linear'],\n ['zoom'],\n 18.6,\n ['case', ['==', ['get', 'selected'], true], 1, ['==', ['get', 'small'], true], 0, 1],\n 19.6,\n 1,\n ],\n },\n });\n m.addLayer({\n id: 'kerros-detail',\n type: 'line',\n source: 'kerros-entities',\n filter: ['==', ['geometry-type'], 'LineString'],\n paint: { 'line-color': ['get', 'color'], 'line-width': 1 },\n });\n m.addLayer({\n id: 'kerros-walls',\n type: 'fill',\n source: 'kerros-entities',\n filter: ['==', ['get', 'kind'], 'wall'],\n paint: {\n 'fill-color': ['case', ['==', ['get', 'selected'], true], sel, ['get', 'color']],\n 'fill-opacity': ['case', ['==', ['get', 'context'], 'lower'], 0.3, 1],\n },\n });\n m.addLayer({\n id: 'kerros-context-upper',\n type: 'line',\n source: 'kerros-entities',\n filter: ['==', ['get', 'context'], 'upper'],\n paint: { 'line-color': '#8b90a0', 'line-width': 1.2, 'line-dasharray': [2, 2] },\n });\n // Dark mode lowers the whole drawing with one veil clipped to the parcel: pastel fills keep\n // their hue but drop enough brightness for the light-on-dark labels to stay legible.\n m.addLayer({\n id: 'kerros-plan-dim',\n type: 'fill',\n source: 'kerros-entities',\n filter: ['all', ['==', ['geometry-type'], 'Polygon'], ['==', ['get', 'kind'], 'parcel']],\n paint: { 'fill-color': '#0d0f16', 'fill-opacity': 0.58 },\n });\n m.addLayer({\n id: 'kerros-hover',\n type: 'line',\n source: 'kerros-entities',\n filter: ['==', ['get', 'id'], ''],\n paint: { 'line-color': hoverColor, 'line-width': 2.5 },\n });\n // Guides sit under the draft: the wall you are drawing should never be hidden by the hint\n // explaining it. line-dasharray is not data-driven, so both roles share one dash and separate\n // on weight and opacity instead.\n m.addLayer({\n id: 'kerros-guide-line',\n type: 'line',\n source: 'kerros-guide',\n paint: {\n 'line-color': draftColor,\n 'line-width': ['case', ['==', ['get', 'role'], 'proposal'], 3, 1.2],\n 'line-opacity': ['case', ['==', ['get', 'role'], 'proposal'], 0.9, 0.45],\n 'line-dasharray': [2, 2],\n },\n });\n m.addLayer({\n id: 'kerros-draft-fill',\n type: 'fill',\n source: 'kerros-draft',\n filter: ['==', ['geometry-type'], 'Polygon'],\n paint: { 'fill-color': draftColor, 'fill-opacity': 0.13 },\n });\n m.addLayer({\n id: 'kerros-draft-line',\n type: 'line',\n source: 'kerros-draft',\n paint: { 'line-color': draftColor, 'line-width': 2, 'line-dasharray': [3, 2] },\n });\n // Edit-mode nav graph (route tool): thin dashed edges under small node dots.\n m.addLayer({\n id: 'kerros-navgraph-edge',\n type: 'line',\n source: 'kerros-navgraph',\n filter: ['==', ['geometry-type'], 'LineString'],\n paint: {\n 'line-color': [\n 'case',\n ['==', ['get', 'selected'], true],\n '#5a52d5',\n ['==', ['get', 'kind'], 'door'],\n '#6a63d8',\n '#8d85dc',\n ],\n 'line-width': 1.4,\n // A derived graph is drawn fainter and in longer dashes: it is what the plan implies, not\n // what anyone drew, and the difference matters the moment you start editing it.\n 'line-dasharray': ['case', ['==', ['get', 'derived'], true], ['literal', [4, 3]], ['literal', [2, 2]]],\n 'line-opacity': ['case', ['==', ['get', 'derived'], true], 0.5, 0.85],\n },\n });\n m.addLayer({\n id: 'kerros-navgraph-node',\n type: 'circle',\n source: 'kerros-navgraph',\n filter: ['==', ['geometry-type'], 'Point'],\n paint: {\n 'circle-radius': ['case', ['==', ['get', 'vertical'], true], 5, ['==', ['get', 'bound'], true], 4.5, 3.5],\n 'circle-color': [\n 'case',\n ['==', ['get', 'selected'], true],\n '#5a52d5',\n ['==', ['get', 'vertical'], true],\n '#567c9a',\n ['==', ['get', 'bound'], true],\n '#6a63d8',\n '#8d85dc',\n ],\n 'circle-stroke-width': 1.2,\n 'circle-stroke-color': '#ffffff',\n 'circle-opacity': ['case', ['==', ['get', 'derived'], true], 0.55, 1],\n },\n });\n // 2D route: casing + accent line + direction chevrons on the current floor, dashed ghost for\n // other floors' segments, circles at vertical transitions. 3D rendering lives in SceneLayer.\n // A track to follow rather than a line to trace: wide enough to read at a glance, white-edged\n // so it carries over a pale floor and a dark one alike, and with the chevrons ON it rather than\n // beside it. Drawn as three coats — white casing, green fill, travelling highlight — plus the\n // arrows on top.\n const trackWidth = (outer: number) =>\n ['interpolate', ['linear'], ['zoom'], 15, outer * 0.5, 18, outer * 0.82, 21, outer] as unknown as number;\n m.addLayer({\n id: 'kerros-route-casing',\n type: 'line',\n source: 'kerros-route',\n filter: ['all', ['==', ['geometry-type'], 'LineString'], ['==', ['get', 'flow'], true]],\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: { 'line-color': ROUTE_EDGE, 'line-width': trackWidth(31), 'line-opacity': 0.96 },\n });\n m.addLayer({\n id: 'kerros-route',\n type: 'line',\n source: 'kerros-route',\n // Not the flow tracing: it covers the same ground, carries no `active`, and so painted itself\n // over the whole path in the not-your-step tone — a route drawn twice, the second time wrong.\n filter: [\n 'all',\n ['==', ['geometry-type'], 'LineString'],\n ['==', ['get', 'onFloor'], true],\n ['!=', ['get', 'flow'], true],\n ],\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: {\n 'line-color': ['case', ['==', ['get', 'active'], true], ROUTE_COLOR, ROUTE_SOFT],\n 'line-width': trackWidth(20),\n 'line-opacity': ['case', ['==', ['get', 'active'], true], 1, 0.9],\n },\n });\n m.addLayer({\n id: 'kerros-route-flow',\n type: 'line',\n source: 'kerros-route',\n filter: ['all', ['==', ['geometry-type'], 'LineString'], ['==', ['get', 'flow'], true]],\n layout: { 'line-cap': 'butt', 'line-join': 'round' },\n // Repainted on a timer while a route is shown; the static value is the band at rest.\n paint: { 'line-width': trackWidth(20), 'line-gradient': routeFlowGradient(0) as never },\n });\n m.addLayer({\n id: 'kerros-route-off',\n type: 'line',\n source: 'kerros-route',\n filter: [\n 'all',\n ['==', ['geometry-type'], 'LineString'],\n ['!=', ['get', 'onFloor'], true],\n ['!=', ['get', 'flow'], true],\n ],\n paint: { 'line-color': ROUTE_SOFT, 'line-width': 2.4, 'line-dasharray': [2, 2], 'line-opacity': 0.45 },\n });\n m.addLayer({\n id: 'kerros-route-arrows',\n type: 'symbol',\n source: 'kerros-route',\n filter: ['all', ['==', ['geometry-type'], 'LineString'], ['==', ['get', 'flow'], true]],\n layout: {\n 'symbol-placement': 'line',\n 'symbol-spacing': 52,\n 'icon-image': 'kerros-route-arrow',\n 'icon-size': ['interpolate', ['linear'], ['zoom'], 15, 0.5, 18, 0.8, 21, 1],\n 'icon-rotation-alignment': 'map',\n 'icon-allow-overlap': true,\n 'icon-ignore-placement': true,\n },\n });\n m.addLayer({\n id: 'kerros-route-vertical',\n type: 'circle',\n source: 'kerros-route',\n filter: ['==', ['get', 'vertical'], true],\n paint: {\n 'circle-radius': ['case', ['==', ['get', 'active'], true], 11, 8],\n 'circle-color': ['case', ['==', ['get', 'active'], true], ROUTE_COLOR, ROUTE_SOFT],\n 'circle-stroke-width': 3,\n 'circle-stroke-color': ROUTE_EDGE,\n 'circle-opacity': ['case', ['==', ['get', 'onFloor'], true], 0.95, 0.4],\n },\n });\n }\n const underground = p.showPlan && undergroundView(p.project, p.floorId, p.threeD && p.stack).buried;\n for (const id of [\n 'kerros-premises',\n 'kerros-premises-line',\n 'kerros-areas',\n 'kerros-outline',\n 'kerros-detail',\n 'kerros-walls',\n 'kerros-context-upper',\n 'kerros-hover',\n ])\n m.setLayoutProperty(id, 'visibility', p.threeD || !p.showPlan ? 'none' : 'visible');\n if (m.getLayer('kerros-underground')) {\n m.setLayoutProperty('kerros-underground', 'visibility', underground && !p.threeD ? 'visible' : 'none');\n m.setPaintProperty('kerros-underground', 'fill-color', '#15130f');\n }\n // Evening lighting used to fall only on the 3D model, so the building sat at dusk inside a map\n // that was still at noon. Dusk is a property of the whole composition, so the basemap is veiled\n // too — lighter than the dark-mode veil, so the city stays legible.\n //\n // Cool, and on a ramp. A warm veil over a basemap whose buildings are already a warm stone read\n // as orange rather than as evening: the city looked lit by a fire rather than unlit by the sun.\n // And it arrived all at once at civil twilight, which is not how an evening happens — it follows\n // the sun down now, so the city loses its light over the hour the sun takes to go.\n const dusk = (1 - ambient(p.sun).day) * (p.dark || underground ? 0 : 1);\n const beam = sunlight(p.sun);\n // The basemap's own light follows the same sun as the model's, so the city's shadows fall the\n // way the building's do instead of the two disagreeing about the time of day.\n m.setLight({\n anchor: 'map',\n position: beam.mapPosition,\n color: beam.color,\n intensity: 0.28 + 0.14 * ambient(p.sun).day,\n });\n // The sky follows the sun down with everything else. Day blue through to an evening violet, over\n // a horizon that warms as the sun reaches it — which is the one part of a dusk that should be\n // warm, and the reason the ground no longer is.\n const daylight = ambient(p.sun).day;\n m.setSky({\n 'sky-color': p.dark ? '#172435' : mixColor('#5d6488', '#92b9d2', daylight),\n 'horizon-color': p.dark ? '#343b4c' : mixColor('#d9ac92', '#e8e4d9', daylight),\n 'sky-horizon-blend': 0.65,\n 'atmosphere-blend': p.threeD && !underground ? 0.65 : 0,\n });\n m.setLayoutProperty('kerros-dim', 'visibility', p.dark || underground || dusk > 0.02 ? 'visible' : 'none');\n m.setPaintProperty('kerros-dim', 'fill-color', dusk > 0 ? '#141a2b' : '#0d0f16');\n m.setPaintProperty('kerros-dim', 'fill-opacity', dusk > 0 ? 0.42 * dusk : 0.55);\n m.setPaintProperty('kerros-premises', 'fill-color', p.dark ? '#232734' : '#f3f4f0');\n m.setPaintProperty('kerros-premises-line', 'line-color', p.dark ? '#565d73' : '#9aa0ac');\n m.setLayoutProperty('kerros-plan-dim', 'visibility', p.dark && !p.threeD && p.showPlan ? 'visible' : 'none');\n const routeOn = !p.threeD && !!p.route;\n for (const id of [\n 'kerros-route-casing',\n 'kerros-route',\n 'kerros-route-flow',\n 'kerros-route-off',\n 'kerros-route-arrows',\n 'kerros-route-vertical',\n ])\n m.setLayoutProperty(id, 'visibility', routeOn ? 'visible' : 'none');\n const graphOn =\n !p.threeD &&\n p.canEdit &&\n ((p.tool as string) === 'route' ||\n !!p.project.navNodes?.some(n => n.id === p.selected) ||\n !!p.project.navEdges?.some(e => e.id === p.selected));\n for (const id of ['kerros-navgraph-edge', 'kerros-navgraph-node'])\n m.setLayoutProperty(id, 'visibility', graphOn ? 'visible' : 'none');\n // The casing stays white in dark mode too. It is the edge of a painted track, not a halo tuned to\n // the page behind it, and a dark edge on a dark floor loses the track's shape entirely.\n m.setPaintProperty('kerros-route-casing', 'line-color', ROUTE_EDGE);\n {\n const ms = mapStyleRef.current;\n if (ms?.route || ms?.routeActive) {\n const active = ms.routeActive ?? ROUTE_COLOR,\n base = ms.route ?? ROUTE_SOFT;\n m.setPaintProperty('kerros-route', 'line-color', [\n 'case',\n ['==', ['get', 'active'], true],\n active,\n base,\n ] as unknown as string);\n m.setPaintProperty('kerros-route-vertical', 'circle-color', [\n 'case',\n ['==', ['get', 'active'], true],\n active,\n base,\n ] as unknown as string);\n m.setPaintProperty('kerros-route-off', 'line-color', base);\n }\n }\n m.setPaintProperty('kerros-route-vertical', 'circle-stroke-color', ROUTE_EDGE);\n m.setPaintProperty('kerros-navgraph-node', 'circle-stroke-color', p.dark ? '#14161f' : '#ffffff');\n if (m.getLayer('background')) m.setPaintProperty('background', 'background-color', p.dark ? '#14161f' : '#e6e8e4');\n // City context: extrude the basemap's building footprints in 3D, and (below grade) draw ghost\n // context layers. What the tiles are called comes from the host's vectorSchema; nothing here is\n // provider-specific. Adopted/underlying footprints are filtered out of the 3D massing.\n const fp = p.basemap?.vectorSchema?.footprints;\n const ctx = p.basemap?.vectorSchema?.context;\n const citySource =\n fp || ctx\n ? Object.entries(m.getStyle().sources).find(([, s]) => (s as { type?: string }).type === 'vector')?.[0]\n : undefined;\n if (citySource && fp) {\n if (!m.getLayer('kerros-city-3d'))\n m.addLayer(\n {\n id: 'kerros-city-3d',\n type: 'fill-extrusion',\n source: citySource,\n 'source-layer': fp.sourceLayer,\n paint: {\n 'fill-extrusion-opacity': 1,\n 'fill-extrusion-vertical-gradient': true,\n 'fill-extrusion-height': (fp.heightExpression ?? 6.5) as never,\n },\n },\n m.getLayer('kerros-3d') ? 'kerros-3d' : undefined,\n );\n m.setLayoutProperty(\n 'kerros-city-3d',\n 'visibility',\n p.threeD && p.cityBuildings && !underground ? 'visible' : 'none',\n );\n // Warm stone rather than pale blue-grey: the surrounding city is context, so it should read as\n // built mass with its own weight, not as a wash the modelled building disappears into.\n m.setPaintProperty(\n 'kerros-city-3d',\n 'fill-extrusion-color',\n p.dark\n ? '#343a49'\n : [\n 'interpolate',\n ['linear'],\n ['to-number', fp.heightExpression ?? 6.5],\n 0,\n '#c5beaf',\n 12,\n '#bcb7aa',\n 30,\n '#b0b4af',\n 70,\n '#a3adb0',\n ],\n );\n refreshCityFilter();\n }\n // Below-grade \"style\": soil cover plus faint ghost layers so a basement plan reads against what\n // stands above it — dashed street centrelines, faint building outlines and darkened water.\n if (citySource && ctx) {\n if (ctx.waterLayer && !m.getLayer('kerros-ug-water'))\n m.addLayer(\n {\n id: 'kerros-ug-water',\n type: 'fill',\n source: citySource,\n 'source-layer': ctx.waterLayer,\n paint: { 'fill-color': '#10151b', 'fill-opacity': 0.55 },\n },\n 'kerros-premises',\n );\n if (ctx.roadLayer && !m.getLayer('kerros-ug-roads'))\n m.addLayer(\n {\n id: 'kerros-ug-roads',\n type: 'line',\n source: citySource,\n 'source-layer': ctx.roadLayer,\n paint: {\n 'line-color': '#7d766a',\n 'line-opacity': 0.33,\n 'line-width': ['interpolate', ['linear'], ['zoom'], 13, 0.5, 16, 2.5, 19, 8],\n 'line-dasharray': [4, 3],\n },\n },\n 'kerros-premises',\n );\n if (ctx.buildingLayer && !m.getLayer('kerros-ug-buildings'))\n m.addLayer(\n {\n id: 'kerros-ug-buildings',\n type: 'line',\n source: citySource,\n 'source-layer': ctx.buildingLayer,\n paint: { 'line-color': '#8a8375', 'line-opacity': 0.4, 'line-width': 1 },\n },\n 'kerros-premises',\n );\n for (const id of ['kerros-ug-water', 'kerros-ug-roads', 'kerros-ug-buildings'])\n if (m.getLayer(id)) m.setLayoutProperty(id, 'visibility', underground && !p.threeD ? 'visible' : 'none');\n }\n // Cadastral parcels (vector): thin themed boundary lines under the drawing paper plus sparse\n // parcel-id labels. Enabled only when the host's vectorSchema declares a cadastre source.\n const cad = p.basemap?.vectorSchema?.cadastre;\n if (cad) {\n if (!m.getSource('kerros-cadastre')) {\n m.addSource('kerros-cadastre', { type: 'vector', url: cad.tilejson, attribution: cad.attribution });\n // Near-invisible parcel fill keeps polygons queryable (parcel id on click) without paint.\n m.addLayer(\n {\n id: 'kerros-cadastre-fill',\n type: 'fill',\n source: 'kerros-cadastre',\n 'source-layer': cad.parcelLayer,\n paint: { 'fill-color': 'rgba(255,255,255,0.02)' },\n },\n 'kerros-premises',\n );\n m.addLayer(\n {\n id: 'kerros-cadastre-line',\n type: 'line',\n source: 'kerros-cadastre',\n 'source-layer': cad.boundaryLayer,\n paint: { 'line-width': 1, 'line-dasharray': [5, 2, 1, 2] },\n },\n 'kerros-premises',\n );\n m.addLayer(\n {\n id: 'kerros-cadastre-mark',\n type: 'circle',\n source: 'kerros-cadastre',\n 'source-layer': cad.markLayer,\n minzoom: 17,\n paint: { 'circle-radius': 2.4, 'circle-stroke-width': 1 },\n },\n 'kerros-premises',\n );\n m.addLayer(\n {\n id: 'kerros-cadastre-label',\n type: 'symbol',\n source: 'kerros-cadastre',\n 'source-layer': cad.labelLayer,\n minzoom: 15.5,\n layout: {\n 'text-field': ['get', cad.labelField],\n 'text-font': [cad.font],\n 'text-size': 10.5,\n 'text-padding': 12,\n },\n paint: {},\n },\n 'kerros-premises',\n );\n }\n for (const id of [\n 'kerros-cadastre-fill',\n 'kerros-cadastre-line',\n 'kerros-cadastre-mark',\n 'kerros-cadastre-label',\n ])\n m.setLayoutProperty(id, 'visibility', p.cadastre && !underground ? 'visible' : 'none');\n m.setPaintProperty('kerros-cadastre-line', 'line-color', p.dark ? '#8d80c9' : '#a5674f');\n m.setPaintProperty('kerros-cadastre-line', 'line-opacity', p.dark ? 0.75 : 0.8);\n m.setPaintProperty('kerros-cadastre-mark', 'circle-color', p.dark ? '#8d80c9' : '#a5674f');\n m.setPaintProperty('kerros-cadastre-mark', 'circle-stroke-color', p.dark ? '#14161f' : '#ffffff');\n m.setPaintProperty('kerros-cadastre-label', 'text-color', p.dark ? '#a89ddb' : '#96604c');\n m.setPaintProperty('kerros-cadastre-label', 'text-halo-color', p.dark ? '#14161f' : '#f4f2ee');\n m.setPaintProperty('kerros-cadastre-label', 'text-halo-width', 1.1);\n }\n if (p.threeD && p.showPlan) {\n if (!m.getLayer('kerros-3d')) {\n // The renderer arrives on demand. three.js and everything drawn with it is half a megabyte\n // that a plan shown flat never executes — and plenty of hosts only ever show it flat — so the\n // module is named here rather than at the top of the file, and a bundler can put it behind a\n // fetch. Everything below already copes with the layer not existing yet: that is the state\n // this file is in for as long as the basemap style takes to load.\n const Layer = sceneModule.current;\n if (!Layer) return;\n scene.current = new Layer();\n m.addLayer(scene.current);\n scene.current.animateIn();\n }\n // The veils go under the model, and are put back under it here rather than trusted to stay.\n // They are added with the rest of the plan's layers and the 3D layer is added after them, so\n // the order is right the first time — but a basemap swap, a floor that dives below ground or\n // the plan being switched off and on again all re-add layers, and which of them ends up on top\n // then depends on which already existed. Get it the wrong way round and the dusk veil paints a\n // flat tinted lid across the floor plate while the walls, standing outside the veiled polygon,\n // keep their colour: a building with an orange box where its inside should be.\n for (const veil of ['kerros-dim', 'kerros-underground']) if (m.getLayer(veil)) m.moveLayer(veil, 'kerros-3d');\n scene.current?.setMapStyle(mapStyleRef.current);\n scene.current?.update(\n p.project,\n p.floorId,\n p.stack,\n p.selected,\n p.sun,\n rider.current\n ? new Map(\n [...p.statuses].map(([id, status]) => {\n const shaft = p.project.objects.find(o => o.id === rider.current);\n return [\n id,\n id === shaft?.feedId\n ? {\n ...status,\n carFloorId: p.floorId ?? undefined,\n targetFloorId: undefined,\n open: status.carFloorId === p.floorId && !status.targetFloorId && status.open,\n }\n : status,\n ];\n }),\n )\n : p.statuses,\n p.excavation ?? false,\n p.walk ?? false,\n );\n scene.current?.setRoute(p.route ?? null, p.activeStep ?? null);\n } else {\n if (m.getLayer('kerros-3d')) {\n m.removeLayer('kerros-3d');\n scene.current = null;\n }\n // 3D moves these above the plan layers, just below its custom layer. Return them beneath\n // the drawing in 2D, or the opaque underground veil covers every room when changing modes.\n for (const veil of ['kerros-dim', 'kerros-underground'])\n if (m.getLayer(veil)) m.moveLayer(veil, 'kerros-premises');\n }\n const validIds = new Set(p.project.drawings.map(d => `drawing-${d.id}`));\n for (const id of Object.keys(m.getStyle().sources).filter(id => id.startsWith('drawing-') && !validIds.has(id))) {\n if (m.getLayer(id)) m.removeLayer(id);\n m.removeSource(id);\n }\n for (const d of p.project.drawings) {\n const id = `drawing-${d.id}`,\n url = urls.current.get(d.assetId);\n if (!url) continue;\n const coordinates = drawingCorners(d).map(pt => toLngLat(pt, p.project.origin)) as [Point, Point, Point, Point];\n if (!m.getSource(id)) {\n m.addSource(id, { type: 'image', url, coordinates });\n m.addLayer(\n { id, source: id, type: 'raster', paint: { 'raster-opacity': d.opacity, 'raster-fade-duration': 0 } },\n 'kerros-outline',\n );\n } else {\n (m.getSource(id) as ImageSource).setCoordinates(coordinates);\n m.setPaintProperty(id, 'raster-opacity', d.opacity);\n }\n m.setLayoutProperty(id, 'visibility', d.visible && d.floorId === p.floorId && !p.threeD ? 'visible' : 'none');\n }\n };\n useEffect(() => {\n if (!container.current) return;\n let m: GLMap;\n const cam = props.initialCamera;\n try {\n m = new maplibregl.Map({\n container: container.current,\n style: neutralBasemap.style,\n transformRequest: props.basemap?.transformRequest,\n center: cam?.center ?? toLngLat([0, -1], props.project.origin),\n zoom: cam?.zoom ?? 18.5,\n bearing: cam?.bearing ?? siteBearing(props.project),\n pitch: cam?.pitch ?? 0,\n // The plan camera's ceiling. Walk mode needs more — its eye is 2 m off the floor — and\n // raises it to its own while it has the map, rather than letting the plan scroll in that far.\n maxZoom: MAX_MAP_ZOOM,\n minZoom: 5,\n // Walk mode looks along the floor, a degree short of level. The default ceiling of 60° keeps\n // the horizon off screen; 85 is as far as the plan camera's own drag will tilt, and the walk\n // raises it to its own limit while it has the map.\n maxPitch: 85,\n attributionControl: false,\n canvasContextAttributes: { antialias: true },\n dragRotate: false,\n pitchWithRotate: false,\n });\n } catch (error) {\n setMapError(`The map could not start: ${String(error)}`);\n return;\n }\n map.current = m;\n if (import.meta.env.DEV) (window as unknown as { __kerrosMap?: GLMap }).__kerrosMap = m;\n m.addControl(new maplibregl.AttributionControl({ compact: true }), 'bottom-right');\n m.doubleClickZoom.disable();\n let lastPitch = 0;\n m.on('pitch', () => {\n const now = performance.now();\n if (now - lastPitch > 100) {\n lastPitch = now;\n setPitch(m.getPitch());\n }\n });\n m.on('pitchend', () => setPitch(m.getPitch()));\n // The depth-aim shift depends on both pitch and bearing, so tilting or turning slides the\n // focused floor out from under the crosshair. Note what was there when the gesture starts and\n // put it back when it settles — only the centre. Re-fitting here (which is what this used to do)\n // threw away the zoom and the pan the user had just chosen, on every floor off grade.\n let aimTimer: ReturnType<typeof setTimeout> | undefined;\n const markAim = () => noteAim(m);\n const settleAim = () => {\n clearTimeout(aimTimer);\n aimTimer = setTimeout(() => aimBack(m), 220);\n };\n m.on('pitchstart', markAim);\n m.on('rotatestart', markAim);\n m.on('pitchend', settleAim);\n m.on('rotateend', settleAim);\n m.on('style.load', () => {\n styleReady.current = true;\n cityHidden.current = '';\n cityIds.current = new Set();\n footprintFilters.current = new Map();\n veiled.current.clear(); // a fresh style: whatever the old one had hidden is gone with it\n if (!m.getLayer('kerros-3d')) scene.current = null;\n sync();\n veilBasemap();\n setReady(true);\n setFrame(n => n + 1);\n setMapError('');\n });\n m.on('load', () => {\n props.onReady?.(m);\n if (!props.initialCamera && !latest.current.playing && !latest.current.walk) fit();\n });\n // Continuous 'render' events caused a React re-render (marker LOD + collision culling over\n // every object) each painted frame. Positions follow imperatively via reposition(); the React\n // pass only needs a low rate while moving plus a final pass when the camera settles.\n let lastFrame = 0;\n const bumpFrame = () => setFrame(n => n + 1);\n m.on('move', () => {\n const now = performance.now();\n if (now - lastFrame > 150) {\n lastFrame = now;\n bumpFrame();\n }\n });\n // Chained journey eases fire moveend once per edge; skip the React pass while playing (the\n // throttled 'move' handler keeps a low rate) and fire one final bumpFrame when the journey ends.\n const guardedBump = () => {\n if (!journey.current?.playing) bumpFrame();\n };\n m.on('moveend', guardedBump);\n m.on('zoomend', guardedBump);\n m.on('idle', guardedBump);\n m.on('error', e => {\n const source = (e as unknown as { sourceId?: string }).sourceId;\n if (/source layer/i.test(e.error.message) || source === 'kerros-cadastre' || /tile/i.test(e.error.message))\n return;\n setMapError(stringsRef.current.basemapUnavailable);\n });\n m.on('mousemove', e => {\n const p = latest.current;\n const local = toLocal([e.lngLat.lng, e.lngLat.lat], p.project.origin);\n const neighbor = m.unproject([e.point.x + 10, e.point.y]);\n const near = toLocal([neighbor.lng, neighbor.lat], p.project.origin);\n p.onHover(local, Math.hypot(near[0] - local[0], near[1] - local[1]));\n let hover: string | null = null;\n if (p.threeD) {\n hover = scene.current?.pick(e.point) ?? null;\n scene.current?.setHover(hover);\n } else if (p.tool === 'select' && !m.isMoving() && m.getLayer('kerros-areas')) {\n const hits = m.queryRenderedFeatures(\n [\n [e.point.x - 3, e.point.y - 3],\n [e.point.x + 3, e.point.y + 3],\n ],\n { layers: ['kerros-guide-line', 'kerros-walls', 'kerros-areas'].filter(id => m.getLayer(id)) },\n );\n hover =\n (hits.find(\n f =>\n f.properties.id &&\n !['parcel', 'building', 'coverage', 'status-halo', 'furniture'].includes(f.properties.kind),\n )?.properties.id as string | undefined) ?? null;\n }\n if (hover !== hoverId.current) {\n hoverId.current = hover;\n latest.current.onHoverObject?.(hover);\n if (m.getLayer('kerros-hover'))\n m.setFilter('kerros-hover', [\n 'all',\n ['==', ['geometry-type'], 'Polygon'],\n ['==', ['get', 'id'], hover ?? ''],\n ]);\n }\n if (p.tool === 'select' || p.threeD) m.getCanvas().style.cursor = hover ? 'pointer' : '';\n });\n m.on('move', reposition);\n // In 3D the overlay projects through the scene camera, whose matrix only updates inside the\n // custom layer's render pass — 'move' fires before it, leaving symbols one frame behind the\n // basemap. Re-snap after every rendered frame so they track the model exactly.\n m.on('render', () => {\n if (latest.current.threeD) reposition();\n });\n const resize = new ResizeObserver(() => {\n m.resize();\n reposition();\n });\n resize.observe(container.current);\n // Two-finger zoom must keep working when the gesture starts over an overlay symbol: those are\n // HTML elements above the canvas, so re-dispatch their wheel events onto the map itself.\n const forwardWheel = (e: WheelEvent) => {\n if ((e.target as HTMLElement).closest('.map-overlay')) {\n e.preventDefault();\n e.stopPropagation();\n m.getCanvasContainer().dispatchEvent(\n new WheelEvent('wheel', {\n deltaX: e.deltaX,\n deltaY: e.deltaY,\n deltaMode: e.deltaMode,\n clientX: e.clientX,\n clientY: e.clientY,\n ctrlKey: e.ctrlKey,\n bubbles: true,\n cancelable: true,\n }),\n );\n }\n };\n const wrap = container.current?.parentElement;\n wrap?.addEventListener('wheel', forwardWheel, { capture: true, passive: false });\n m.on('idle', () => refreshCityFilter());\n m.on('click', e => {\n if (suppressClick.current) {\n suppressClick.current = false;\n return;\n }\n const p = latest.current;\n if (p.tool === 'adopt' && p.canEdit && !p.threeD) {\n adoptAt(e.point);\n return;\n }\n const ids = ['kerros-guide-line', 'kerros-walls', 'kerros-areas'].filter(id => m.getLayer(id));\n const hits = p.threeD\n ? []\n : m.queryRenderedFeatures(\n [\n [e.point.x - 3, e.point.y - 3],\n [e.point.x + 3, e.point.y + 3],\n ],\n { layers: ids },\n );\n const hit = hits.find(\n f =>\n f.properties.id &&\n f.properties.kind !== 'parcel' &&\n f.properties.kind !== 'building' &&\n f.properties.kind !== 'coverage' &&\n f.properties.kind !== 'status-halo',\n );\n // Walking, a click is how you take hold of the pointer — not how you select a wall.\n if (p.walk) return;\n p.onClick(\n toLocal([e.lngLat.lng, e.lngLat.lat], p.project.origin),\n p.threeD ? (scene.current?.pick(e.point) ?? null) : (hit?.properties.id ?? null),\n );\n });\n return () => {\n clearTimeout(aimTimer);\n journey.current?.stop();\n journey.current = null;\n resize.disconnect();\n wrap?.removeEventListener('wheel', forwardWheel, { capture: true });\n urls.current.forEach(URL.revokeObjectURL);\n urls.current.clear();\n // MapLibre's full map teardown drops the style without calling custom-layer onRemove, then\n // deliberately loses the context. Dispose Three first, including its context event listeners.\n if (m.getLayer('kerros-3d')) m.removeLayer('kerros-3d');\n scene.current = null;\n m.remove();\n map.current = null;\n };\n // The map owns its lifecycle; live state is supplied through latest.current.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n // Without a scope, frames the building (or everything); scoped to a floor, frames that floor's\n // geometry — selecting a floor always brings it fully into view.\n function fit(scopeFloor?: string | null) {\n const m = map.current;\n if (!m) return;\n const p = latest.current;\n // Walk mode owns the camera outright. A fit here — from the map's load, from the floor changing,\n // from the fit button — would ease the eye a hundred metres into the air and leave it there,\n // because the walker only writes a pose when the walker moves.\n if (p.walk) return;\n const scoped =\n scopeFloor !== undefined\n ? [\n ...p.project.junctions.filter(j => j.floorId === scopeFloor).map(j => j.position),\n ...p.project.objects.filter(o => o.floorId === scopeFloor).flatMap(o => o.rings?.[0] ?? [o.position]),\n ]\n : [];\n const indoor = scoped.length\n ? scoped\n : [\n ...p.project.junctions.filter(j => j.floorId).map(j => j.position),\n ...p.project.objects.filter(o => o.floorId).flatMap(o => o.rings?.[0] ?? [o.position]),\n ];\n const points = indoor.length\n ? indoor\n : [...p.project.junctions.map(j => j.position), ...p.project.objects.flatMap(o => o.rings?.[0] ?? [o.position])];\n const safe = points.length\n ? points\n : ([\n [-40, -30],\n [40, 30],\n ] as Point[]);\n // Extend with every point, not the local AABB corners: on sites with a rotated origin the\n // rotated corner box inflates the geo bounds by up to ~40%, which read as \"zoomed out\".\n const bounds = new maplibregl.LngLatBounds();\n for (const pt of safe) bounds.extend(toLngLat(pt, p.project.origin));\n // Keep the focus tight on the floor itself — just enough padding to clear the floating chrome.\n // Keep the user's rotation (fitBounds would reset bearing), and in 3D follow the floor's\n // elevation: zoom compensates for depth so navigating floors sinks into the pit (or rises\n // with the towers) instead of viewing a distant plate from street height.\n const camera = m.cameraForBounds(bounds, {\n padding: { top: 64, bottom: p.canEdit && !p.threeD ? 150 : 72, left: 42, right: 42 },\n bearing: m.getBearing(),\n maxZoom: 20.5,\n });\n if (!camera) return;\n let zoom = camera.zoom ?? m.getZoom();\n const focusFloor = scopeFloor === undefined ? p.floorId : scopeFloor;\n const elev = undergroundView(p.project, focusFloor, p.stack).focusElevation;\n if (p.threeD && elev) {\n // Metres per screen pixel at the fitted zoom. MapLibre lays the world out in 512-pixel tiles,\n // so the constant is half the familiar 256-pixel one; with the larger figure the camera looked\n // twice as high as it is and the depth compensation below came out at half strength.\n const perPixel = (78271.5169 * Math.cos((m.getCenter().lat * Math.PI) / 180)) / Math.pow(2, zoom);\n const screenDistance = cameraToCenterDistance(m);\n const altitude = screenDistance * perPixel * Math.cos((m.getPitch() * Math.PI) / 180);\n // cameraForBounds framed the plan on the ground; the storey is `elev` below it (or above), so\n // the camera is that much farther from what is being framed. Zooming in lowers the camera by\n // the same factor, which is why the whole correction is one logarithm and not an iteration.\n // Undamped: the old 0.85 was tuned against an altitude that came out twice too large, and\n // measured on one fixed ring drawn at each depth it left P3 nearly three per cent small.\n const adjusted = altitude + elev;\n if (adjusted > 25) zoom += Math.log2(altitude / adjusted);\n // Aim at the floor itself, not the ground above it — aimCenter() is this fit's depth-aim\n // shift factored into journey.ts so the journey camera and the fit agree exactly.\n const at = maplibregl.LngLat.convert(camera.center as maplibregl.LngLatLike);\n camera.center = aimCenter([at.lng, at.lat], elev, m.getPitch(), m.getBearing());\n }\n steer(m, { center: camera.center, zoom, bearing: m.getBearing(), duration: 650 });\n }\n useEffect(() => {\n // A walker who climbs a stair stays where they are standing; re-fitting would throw them across\n // the floor plate the moment they arrived.\n if (ready && !props.playing && !props.walk) fit(props.floorId);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.floorId, props.stack]);\n // The highlight travelling along the route. A timer rather than a rAF loop: the band moves at\n // reading pace, not at the display's, and setPaintProperty on a gradient is a paint-only change\n // the map coalesces into its own next frame. Off in 3D, where SceneLayer animates the ribbon's\n // texture instead, and off entirely with no route — an idle map must stay idle.\n useEffect(() => {\n const m = map.current;\n if (!m || !ready || !props.route || props.threeD) return;\n let phase = 0;\n const tick = window.setInterval(() => {\n phase = (phase + 0.011) % 1;\n if (m.getLayer('kerros-route-flow'))\n m.setPaintProperty('kerros-route-flow', 'line-gradient', routeFlowGradient(phase) as never);\n }, 40);\n return () => window.clearInterval(tick);\n }, [ready, props.route, props.threeD]);\n // ---------------------------------------------------------------- walk mode\n // The camera stops being a camera and becomes a person: WalkController owns the pose, this owns\n // the things only the document knows — which walls are solid, what a stair leads to, and what the\n // head-up display should say.\n const walker = useRef<WalkController | null>(null);\n const rider = useRef<string | null>(null);\n const walkSound = useRef<AmbienceEngine | null>(null);\n const [riding, setRiding] = useState<string | null>(null);\n const [elevatorRequest, setElevatorRequest] = useState(0);\n const [journeyMessage, setJourneyMessage] = useState('');\n const ride = (id: string | null) => {\n rider.current = id;\n setRiding(id);\n walkSound.current?.set(\n id\n ? { preset: 'elevator', level: 0.5 }\n : ambienceAt(latest.current.project, latest.current.floorId, walker.current?.position ?? [0, 0]),\n );\n };\n /** Where the walk left the person, written by the walk's own teardown. */\n const leftAt = useRef<WalkAvatar | null>(null);\n const [walkHint, setWalkHint] = useState<WalkHint>(NO_HINT);\n const toggleWalkSound = () => {\n const sound = walkSound.current;\n if (!sound) return;\n sound.setMuted(!sound.isMuted);\n sound.resume();\n try {\n localStorage.setItem(MUTED_KEY, sound.isMuted ? '1' : '0');\n } catch {\n /* private mode */\n }\n hintRef.current = { ...hintRef.current, sound: !sound.isMuted };\n setWalkHint(hintRef.current);\n };\n const [walkFov, setWalkFov] = useState(() => {\n try {\n return walkFieldOfView(Number(localStorage.getItem(FOV_KEY) ?? DEFAULT_WALK_FOV));\n } catch {\n return DEFAULT_WALK_FOV;\n }\n });\n const hintRef = useRef<WalkHint>(NO_HINT);\n const hintAt = useRef(0);\n const avatarAt = useRef(0);\n // The person marker being dragged off the navigator, in map-wrap pixels; dropped on the map it\n // becomes the avatar and the walk starts there. Google's pegman, for a floor plan.\n const [peg, setPeg] = useState<{ x: number; y: number } | null>(null);\n /** How high above the map's own ground plane the active floor's walking surface is presented. Zero\n * in plan and while walking, where the storey is rebased onto the ground plane itself. Callers\n * that ask about a view they are leaving — the walk about to start, the 3D about to become 2D —\n * pass `lifted` themselves, because by then the prop has already flipped. */\n const floorLift = (lifted = latest.current.threeD && !latest.current.walk): number => {\n const p = latest.current;\n return lifted ? undergroundView(p.project, p.floorId, p.stack).focusElevation + LIFT + SLAB : 0;\n };\n /** Where a screen point lands on the active floor's walking surface, in plan metres. The map\n * unprojects onto the ground; a floor presented above it meets the same ray nearer the camera, by\n * its elevation times tan(pitch) — the fit's depth-aim in reverse. */\n const floorPoint = (m: GLMap, x: number, y: number, lift = floorLift()): Point => {\n const p = latest.current;\n const ground = m.unproject([x, y]);\n const at = lift\n ? aimCenter([ground.lng, ground.lat], -lift, m.getPitch(), m.getBearing())\n : [ground.lng, ground.lat];\n return toLocal(at as Point, p.project.origin);\n };\n /** The inverse: the ground centre that puts `at` on the floor under the crosshair. */\n const floorCenter = (at: Point, lift: number, pitchDeg: number, bearingDeg: number): [number, number] => {\n const ll = toLngLat(at, latest.current.project.origin);\n return aimCenter([ll[0], ll[1]], lift, pitchDeg, bearingDeg);\n };\n /** The floor point the camera was looking at when a tilt or a turn began, kept until the gesture\n * settles. Held across the whole gesture rather than sampled at the end, because the aim is what\n * the movement is breaking — and the pitch slider fires a start/end pair per tick, so the first\n * reading is the only honest one. */\n const aimHeld = useRef<Point | null>(null);\n /** True while a camera move of our own is in flight. Our eases aim where they mean to and change\n * pitch and bearing to get there, which looks exactly like a user tilting — without this the\n * re-aim below would note a point mid-transition and then chase it once the transition landed. */\n const steering = useRef(false);\n const steer = (m: GLMap, options: Parameters<GLMap['easeTo']>[0]) => {\n steering.current = true;\n aimHeld.current = null;\n const settled = () => {\n clearTimeout(timer);\n m.off('moveend', settled);\n steering.current = false;\n };\n const timer = setTimeout(settled, (options.duration ?? 300) + 400); // an ease with nothing to do never fires moveend\n m.on('moveend', settled);\n m.easeTo(options);\n };\n const noteAim = (m: GLMap) => {\n const p = latest.current;\n if (aimHeld.current || steering.current || !p.threeD || p.walk || journey.current?.playing) return;\n const { clientWidth: w, clientHeight: h } = m.getCanvas();\n aimHeld.current = floorPoint(m, w / 2, h / 2);\n };\n const aimBack = (m: GLMap) => {\n const at = aimHeld.current;\n aimHeld.current = null;\n const p = latest.current;\n if (!at || !p.threeD || p.walk || journey.current?.playing) return;\n const lift = floorLift();\n if (!lift) return; // at grade there is no parallax to correct, and no reason to nudge the view\n m.easeTo({ center: floorCenter(at, lift, m.getPitch(), m.getBearing()), duration: 300 });\n };\n const dropPeg = (e: ReactPointerEvent<HTMLButtonElement>) => {\n const m = map.current,\n wrap = container.current;\n e.currentTarget.releasePointerCapture(e.pointerId);\n setPeg(null);\n if (!m || !wrap) return;\n const r = wrap.getBoundingClientRect();\n const x = e.clientX - r.left,\n y = e.clientY - r.top;\n // Dropped back on the controls, or off the map: nothing happens, as nothing should.\n if (x < 0 || y < 0 || x > r.width || y > r.height) return;\n if (document.elementFromPoint(e.clientX, e.clientY)?.closest('.map-navigator, .canvas-top-left')) return;\n const p = latest.current;\n p.onWalkAt?.({\n floorId: p.floorId,\n position: floorPoint(m, x, y),\n // Facing up the screen: the way the map is turned is the way the person dropped on it faces.\n heading: m.getBearing() - (p.project.origin[2] ?? 0),\n });\n };\n /** Wall bodies the walker's shoulders meet. wallPieces() already splits a wall at its openings, so\n * a doorway is a gap in this list and nothing has to know what a door is; the strip left over a\n * door is a piece lifted clear of head height, which you walk under. */\n const supportedFloors = useMemo(() => (props.walk ? floorSupport(props.project) : null), [props.walk, props.project]);\n const staticWalkWalls = useMemo(\n () => (props.walk ? walkingWallRings(props.project, props.floorId) : []),\n [props.walk, props.project, props.floorId],\n );\n const walkWalls = useMemo(\n () =>\n props.walk\n ? [\n ...props.project.objects\n .filter(\n o =>\n o.kind === 'elevator' &&\n floorIndex(props.project).primary.has(o.id) &&\n servedFloors(props.project, o).some(f => f.id === props.floorId),\n )\n .flatMap(o => {\n const status = props.statuses.get(o.feedId ?? '');\n return elevatorWalls(\n o,\n !!status?.open && !status.moving && !status.targetFloorId && status.carFloorId === props.floorId,\n );\n }),\n ...staticWalkWalls,\n // What stands on the floor is as solid as what encloses it: a parked car, a column,\n // a desk. Anything lower than a step is walked over; a rug is a fixture too.\n ...props.project.objects\n .filter(\n o =>\n o.floorId === props.floorId &&\n o.kind === 'fixture' &&\n o.height >= 0.3 &&\n (o.baseHeight ?? 0) < EYE &&\n !o.slide &&\n o.model !== 'vent',\n )\n .map(o => rectangle(o.position, o.width, o.depth, o.rotation)),\n ]\n : [],\n [props.walk, props.project, props.floorId, props.statuses, staticWalkWalls],\n );\n /** Where to stand when walk mode opens. Under the camera if that is somewhere on this floor —\n * entering walk mode should feel like stepping into the view you already had — and otherwise in\n * the middle of the floor's largest space, rather than in the car park across the street. */\n const startPose = (m: GLMap): { position: Point; heading: number; pitch?: number } => {\n const p = latest.current;\n const planHeading = m.getBearing() - (p.project.origin[2] ?? 0);\n // A route in play is where the walk is meant to begin: its first node on this floor, which is\n // the door you came in by or the point the last flight left off at.\n const onRoute = p.route?.nodes.find(n => n.floorId === p.floorId);\n if (onRoute) return { position: onRoute.position, heading: planHeading };\n // The person is where they were left — as long as that is somewhere in the view being walked\n // into. Panning across the site to another building and pressing Walk means that building, not\n // a march back to where the last walk ended.\n const avatar = p.avatar;\n const { clientWidth: w, clientHeight: h } = m.getCanvas();\n if (avatar && avatar.floorId === p.floorId) {\n const at = m.project(toLngLat(avatar.position, p.project.origin));\n if (at.x >= 0 && at.y >= 0 && at.x <= w && at.y <= h) return avatar;\n }\n // The map's centre is the point the camera looks AT. At walking pitch that is a hundred metres up\n // the corridor from whoever is looking, so a walk pose restored from a deep link would put the\n // walker a building further on than where they left. When the camera is already down at eye\n // height, stand where the camera is and keep its pitch; a plan camera looking down from a\n // hundred metres up has no walker to recover, the point it looks at is the room the person\n // meant, and its 35° tilt would have them staring at their shoes. That point is on the FLOOR,\n // though, not on the ground the plan camera is centred over — on P3 the two are fifteen metres\n // apart, which is where the walk used to begin. (`walk` is already true here, so the lift the\n // view still has has to be asked for explicitly.)\n const camera = cameraPosition(m);\n const eyeLevel = camera.altitude < 2 * (EYE + LIFT + SLAB);\n const cam = camera.lngLat;\n const here = eyeLevel\n ? toLocal([cam.lng, cam.lat], p.project.origin)\n : floorPoint(m, w / 2, h / 2, floorLift(p.threeD));\n const pose = (position: Point) => ({ position, heading: planHeading, pitch: eyeLevel ? m.getPitch() : undefined });\n if (!p.floorId || spaceAt(p.project, p.floorId, here)) return pose(here);\n const spaces = p.project.objects\n .filter(o => o.floorId === p.floorId && isSpace(o.kind) && o.rings?.length)\n .sort((a, b) => objectArea(b) - objectArea(a));\n // A concave plate's centroid can fall in its own courtyard, so take the largest space that\n // actually contains the point it offers.\n for (const space of spaces) {\n const at = spacePoint(p.project, space);\n if (inSpace(space, at)) return pose(at);\n }\n return pose(here);\n };\n /** What the route asks for next, from where the walker is standing. This is the whole reason walk\n * mode is the right mode for indoor navigation: the route is already drawn on the floor by\n * SceneLayer, and standing on it, the only thing left to say is which way and how far. */\n const guide = (at: Point): string => {\n const p = latest.current;\n const route = p.route;\n if (!route?.nodes.length) return '';\n let nearest = -1,\n best = Number.POSITIVE_INFINITY;\n route.nodes.forEach((n, i) => {\n if (n.floorId !== p.floorId) return;\n const d = distance(n.position, at);\n if (d < best) {\n best = d;\n nearest = i;\n }\n });\n if (nearest < 0) return '';\n // The one after the one you are closest to: standing ON a node, the useful instruction is the\n // next one, not the one you have already reached.\n const next = route.nodes[nearest + 1] ?? route.nodes[nearest];\n const step = route.steps.find(s => s.nodeIds.includes(next.id));\n const metres = Math.round(distance(next.position, at));\n return step ? `${metres} m · ${step.text}` : `${metres} m along the route`;\n };\n /** The shaft the walker is standing in and where it could take them. */\n const climb = (at: Point) => {\n const p = latest.current;\n // `reaching` matters: a stair is filed under the floor it starts from, so at the top of a flight\n // the only object under your feet is one that belongs to the storey below. Without it, F does\n // nothing at exactly the place you most want to press it.\n const index = floorIndex(p.project);\n const standing = [...(index.objects.get(p.floorId) ?? []), ...(index.reaching.get(p.floorId ?? '') ?? [])];\n const shaft = standing.find(o =>\n o.kind === 'elevator'\n ? distance(o.position, at) < Math.max(o.width, o.depth) / 2 + 2\n : o.kind === 'stairs' && inSpace(o, at),\n );\n const here = p.project.floors.find(f => f.id === p.floorId);\n if (!shaft || !here) return { shaft: null, up: null, down: null };\n const served = servedFloors(p.project, shaft);\n // An escalator carries you one way. Offering the other is offering to walk up the down staircase.\n const only = shaft.stairModel === 'escalator' ? (shaft.travel ?? 'up') : null;\n const above = served.filter(f => f.elevation > here.elevation)[0] ?? null;\n const below = served.filter(f => f.elevation < here.elevation).slice(-1)[0] ?? null;\n return { shaft, up: only === 'down' ? null : above, down: only === 'up' ? null : below };\n };\n // Deliberately NOT gated on `ready`. That flag waits for the basemap style, which is a network\n // fetch — and on a slow or failing one the UI said Walk, the head-up display was there, and the\n // camera was still a plan view with MapLibre's own drag and arrow-key panning live underneath it.\n // Every symptom of \"walk mode does nothing\" came from that: the controller had never attached.\n // The walker needs the map object and the document, and has both from the first commit.\n useEffect(() => {\n const m = map.current;\n if (!m || !props.walk) return;\n const p = latest.current;\n // What the building sounds like from where the walker stands, synthesised as they go. Muted\n // is remembered; the browser will not let sound start until the walker clicks or presses\n // something, and every such gesture nudges it awake.\n const sound = new AmbienceEngine();\n walkSound.current = sound;\n let muted = false;\n try {\n muted = localStorage.getItem(MUTED_KEY) === '1';\n } catch {\n /* private mode: not remembered, still mutable */\n }\n sound.setMuted(muted);\n if (import.meta.env.DEV) (window as unknown as { __kerrosSound?: AmbienceEngine }).__kerrosSound = sound;\n const wake = () => sound.resume();\n window.addEventListener('pointerdown', wake, true);\n window.addEventListener('keydown', wake, true);\n const controller = new WalkController({\n onPose: (pose: WalkPose) => {\n // Where you are changes every frame; what is there does not, and looking it up means a scan\n // of every object on the floor. Throttle the lookup — never the drag flag, which fires once\n // on mouse-up and would otherwise leave the legend dimmed until the next keystroke.\n const now = performance.now();\n // The avatar is the host's copy of where the person is, and a host re-renders for it; a few\n // times a second is plenty for a marker nobody sees until the walk ends.\n if (now - avatarAt.current >= 400) {\n avatarAt.current = now;\n latest.current.onAvatar?.({\n floorId: latest.current.floorId,\n position: pose.position,\n heading: pose.heading,\n pitch: pose.pitch,\n });\n }\n const fresh = now - hintAt.current >= 150;\n if (!fresh && pose.looking === hintRef.current.looking) return;\n const transfer = fresh ? climb(pose.position) : null;\n const { up, down } = transfer?.shaft?.kind === 'stairs' ? transfer : { up: null, down: null };\n const room = fresh ? spaceAt(latest.current.project, latest.current.floorId, pose.position) : null;\n if (fresh) {\n hintAt.current = now;\n sound.set(\n rider.current\n ? { preset: 'elevator', level: 0.5 }\n : ambienceAt(latest.current.project, latest.current.floorId, pose.position),\n );\n }\n const next: WalkHint = fresh\n ? {\n looking: pose.looking,\n sound: !sound.isMuted,\n up: up?.name ?? null,\n down: down?.name ?? null,\n where: room?.name ?? '',\n next: guide(pose.position),\n }\n : { ...hintRef.current, looking: pose.looking };\n if (\n next.looking !== hintRef.current.looking ||\n next.up !== hintRef.current.up ||\n next.down !== hintRef.current.down ||\n next.where !== hintRef.current.where ||\n next.next !== hintRef.current.next\n ) {\n hintRef.current = next;\n setWalkHint(next);\n }\n },\n onUse: (down: boolean) => {\n const target = climb(walker.current?.position ?? [0, 0]);\n if (target.shaft?.kind === 'elevator') {\n if (latest.current.elevators) {\n setElevatorRequest(n => n + 1);\n }\n return;\n }\n const floor = down ? target.down : target.up;\n if (floor) latest.current.onRequestFloor?.(floor.id);\n },\n onDrop: floorId => latest.current.onRequestFloor?.(floorId),\n onFloor: floorId => latest.current.onRequestFloor?.(floorId),\n onExit: () => latest.current.onWalkExit?.(),\n onSound: toggleWalkSound,\n });\n walker.current = controller;\n if (import.meta.env.DEV) (window as unknown as { __kerrosWalk?: WalkController }).__kerrosWalk = controller;\n const start = startPose(m);\n // Stand clear of things, not against them: the walk's own radius keeps a shoulder off a wall,\n // but arriving with a car's flank filling half the frame is no way to start. A metre of room\n // first, where there is a metre to be had, then the walking radius.\n const position = unstick(unstick(start.position, walkWalls, 1), walkWalls);\n controller.setFieldOfView(walkFov);\n controller.attach(m, p.project.origin, { ...start, position });\n return () => {\n // The last step is the one the marker shows.\n const final = controller.pose;\n controller.detach();\n sound.dispose();\n walkSound.current = null;\n window.removeEventListener('pointerdown', wake, true);\n window.removeEventListener('keydown', wake, true);\n const stood: WalkAvatar = {\n floorId: latest.current.floorId,\n position: final.position,\n heading: final.heading,\n pitch: final.pitch,\n };\n // The camera effect below needs this in the same commit, and the host's copy of it does not\n // come back to us until a render later.\n leftAt.current = stood;\n latest.current.onAvatar?.(stood);\n walker.current = null;\n ride(null);\n hintRef.current = NO_HINT;\n setWalkHint(NO_HINT);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.walk]);\n useEffect(() => {\n walker.current?.setFieldOfView(walkFov);\n }, [walkFov]);\n const walkedFloor = useRef(props.floorId);\n const walkStairs = useMemo(\n () => (props.walk ? stairSurfaces(props.project, props.statuses) : []),\n [props.walk, props.project, props.statuses],\n );\n useEffect(() => {\n // Walk mode draws the active floor on the map's own ground plane (SceneLayer rebases it), so the\n // eye is the same height above it on every storey — only the walls change.\n walker.current?.setTerrain({\n walls: walkWalls,\n eye: EYE + LIFT + SLAB,\n floorId: props.floorId,\n elevation: props.project.floors.find(f => f.id === props.floorId)?.elevation ?? 0,\n stairs: walkStairs,\n supports: supportedFloors?.supports,\n dropAt: at => supportedFloors?.dropAt(at, props.floorId),\n });\n if (walkedFloor.current !== props.floorId && walker.current && !walker.current.onStairs) {\n const at = walker.current.position;\n const arrival = floorArrival(props.project, props.floorId, at);\n if (arrival !== at) walker.current.place(unstick(arrival, walkWalls));\n }\n walkedFloor.current = props.floorId;\n }, [walkWalls, walkStairs, supportedFloors]);\n // Journey floor barrier: resolves once the app shows the target floor AND the view has rebuilt —\n // in 3D when the SceneLayer revision advances past the value captured HERE, before React flushes\n // the floor change (do not insert an await between requestFloor and this call), in 2D after two\n // rendered frames. The safety timeout keeps a host that ignores onRequestFloor from deadlocking.\n const waitForFloor = (target: string | null) =>\n new Promise<void>(resolve => {\n const m = map.current;\n if (!m) return resolve();\n const rev = scene.current?.diagnostics.revision ?? -1;\n let frames = 0;\n const done = () => {\n clearTimeout(timer);\n m.off('render', check);\n resolve();\n };\n const timer = setTimeout(done, 5000);\n const check = () => {\n const p = latest.current;\n if (p.floorId !== target) {\n frames = 0;\n return;\n }\n if (p.threeD ? (scene.current?.diagnostics.revision ?? rev + 1) > rev : ++frames >= 2) done();\n };\n m.on('render', check);\n m.triggerRepaint();\n });\n useEffect(() => {\n const m = map.current;\n // Walking, the route is walked rather than flown: see the follow effect below. The two cannot\n // share a camera — the fly-over aims at the floor's real elevation, and walk mode has rebased the\n // storey to the map's own ground plane, so the journey would ease the eye to a height the\n // building is no longer at and look at nothing.\n if (!props.playing || props.walk) {\n journey.current?.stop();\n return;\n }\n // A host may start playback while remounting the map after graph view. Wait for its style\n // before driving the camera so initial fitting cannot interrupt every route ease.\n if (!m || !ready || journey.current) return;\n const route = latest.current.route;\n if (!route) {\n latest.current.onJourneyEnd?.();\n return;\n }\n let cancelled = false;\n void import('./journey')\n .then(({ JourneyPlayer }) => {\n if (cancelled) return;\n const j = new JourneyPlayer(m, {\n requestFloor: id => latest.current.onRequestFloor?.(id),\n waitForFloor,\n focusElevation: fid =>\n latest.current.threeD\n ? undergroundView(latest.current.project, fid, latest.current.stack).focusElevation\n : 0,\n onStep: i => latest.current.onJourneyStep?.(i),\n onEnd: () => {\n journey.current = null;\n setFrame(n => n + 1);\n latest.current.onJourneyEnd?.();\n },\n });\n journey.current = j;\n j.play(route, { origin: latest.current.project.origin, startFloorId: latest.current.floorId });\n })\n .catch(error => {\n if (!cancelled) {\n setMapError(`Route playback could not load: ${String(error)}`);\n latest.current.onJourneyEnd?.();\n }\n });\n return () => {\n cancelled = true;\n journey.current?.stop();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.playing, props.walk, ready]);\n // The passenger journey retains vertical legs and waits for the same controls used by the sidebar.\n useEffect(() => {\n if (!props.playing || !props.walk || !walker.current) return;\n const route = latest.current.route;\n if (!route) {\n latest.current.onJourneyEnd?.();\n return;\n }\n let cancelled = false;\n let journey: WalkJourney | undefined;\n const host: WalkJourneyHost = {\n project: latest.current.project,\n floor: () => latest.current.floorId,\n changeFloor: async id => {\n if (latest.current.floorId === id) return;\n latest.current.onRequestFloor?.(id);\n await waitForFloor(id);\n if (latest.current.floorId !== id) throw new Error('The requested floor is not available.');\n },\n position: () => walker.current?.position ?? [0, 0],\n walk: (points, options) =>\n new Promise<void>((resolve, reject) => {\n if (cancelled || !walker.current) {\n reject(new Error('Route playback stopped.'));\n return;\n }\n walker.current.follow(points, resolve, {\n ...options,\n onCancel: () => reject(new Error('Route playback stopped at an obstruction or by movement.')),\n });\n }),\n controls: () => latest.current.elevators,\n status: id => latest.current.elevators?.statuses.find(s => s.feedId === id) ?? latest.current.statuses.get(id),\n ride,\n message: text => {\n if (!cancelled) setJourneyMessage(text);\n },\n step: index => latest.current.onJourneyStep?.(index),\n };\n const interrupt = (event: KeyboardEvent) => {\n if (\n [\n 'KeyW',\n 'KeyA',\n 'KeyS',\n 'KeyD',\n 'KeyQ',\n 'KeyE',\n 'ArrowUp',\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'Escape',\n ].includes(event.code)\n )\n latest.current.onJourneyEnd?.();\n };\n window.addEventListener('keydown', interrupt, true);\n void import('./walkJourney')\n .then(({ WalkJourney }) => {\n if (cancelled) return;\n journey = new WalkJourney(host);\n return journey.play(route);\n })\n .catch(error => {\n if (!cancelled) setJourneyMessage(error instanceof Error ? error.message : 'Route playback stopped.');\n })\n .finally(() => {\n if (!cancelled) latest.current.onJourneyEnd?.();\n });\n return () => {\n cancelled = true;\n journey?.stop();\n walker.current?.cancelFollow();\n window.removeEventListener('keydown', interrupt, true);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.playing, props.walk]);\n // A deep-linked camera must survive the mount-time 3D tilt-in; later mode switches animate normally.\n const firstTilt = useRef(true);\n useEffect(() => {\n const m = map.current;\n if (!m) return;\n const controller = new AbortController();\n const config = props.basemap ?? neutralBasemap;\n void loadBasemap(config, controller.signal)\n .then(style => {\n if (controller.signal.aborted) return;\n m.setTransformRequest(config.transformRequest ?? (url => ({ url })));\n styleReady.current = false;\n // A full style swap also bypasses custom-layer disposal in MapLibre.\n if (m.getLayer('kerros-3d')) m.removeLayer('kerros-3d');\n scene.current = null;\n m.setStyle(style, { diff: false });\n })\n .catch(error => {\n if (error.name !== 'AbortError') setMapError(stringsRef.current.basemapUnavailablePlan);\n });\n return () => controller.abort();\n }, [props.basemap]);\n useEffect(() => {\n sync();\n }, [\n props.project,\n props.floorId,\n props.selected,\n props.threeD,\n props.stack,\n props.coverage,\n props.showPlan,\n props.sun,\n props.dark,\n props.cityBuildings,\n props.cadastre,\n props.statuses,\n riding,\n props.route,\n props.activeStep,\n props.tool,\n props.canEdit,\n // The walk builds a different scene — the floor on the ground plane, a ceiling on it, the\n // batches cut for culling — and leaving it has to build the plan's scene back. Without this the\n // 3D view kept the walk's, and a garage came back as its deck lifted to street level, lidded,\n // inside the cage of the levels above it.\n props.walk,\n props.excavation,\n ready,\n ]);\n useEffect(() => {\n syncDraft();\n }, [guideData, props.draft, props.hover, props.guides, props.tool, ready]);\n // A React marker pass may commit positions computed before the camera's latest frame; snap them\n // to the current camera immediately after every commit so symbols never trail a pan.\n useEffect(() => {\n reposition();\n });\n useEffect(() => {\n let cancelled = false;\n const live = new Set(props.project.drawings.map(d => d.assetId));\n for (const [assetId, url] of urls.current)\n if (!live.has(assetId)) {\n URL.revokeObjectURL(url);\n urls.current.delete(assetId);\n }\n let missing: string | null = null;\n Promise.all(\n props.project.drawings.map(async d => {\n if (urls.current.has(d.assetId)) return;\n const blob = await props.assets.get(d.assetId).catch(() => undefined);\n // A missing blob must not stop the drawings that did resolve from rendering.\n if (!blob) missing = d.name;\n else if (!cancelled) urls.current.set(d.assetId, URL.createObjectURL(blob));\n }),\n ).then(() => {\n if (cancelled) return;\n sync();\n if (missing) props.onError(`Reference image “${missing}” is missing.`);\n });\n return () => {\n cancelled = true;\n };\n }, [props.project.drawings, props.assets]);\n const prevView = useRef({ threeD: props.threeD, walk: props.walk });\n useEffect(() => {\n const m = map.current;\n if (!m) return;\n const was = prevView.current;\n prevView.current = { threeD: props.threeD, walk: props.walk };\n const skipEase = (firstTilt.current && !!props.initialCamera) || props.walk || props.playing;\n firstTilt.current = false;\n const pitch = props.threeD ? 35 : 0;\n const bearing = siteBearing(props.project) + (props.threeD ? -12 : 0);\n const { clientWidth: w, clientHeight: h } = m.getCanvas();\n const stood = was.walk && !props.walk ? (leftAt.current ?? props.avatar) : null;\n leftAt.current = null;\n if (stood) {\n // Leaving the walk. The camera is a person's eye, and the point it looks AT is whatever the\n // floor meets some thirty metres up the room in front of them — leaving it there is how the\n // plan view came back showing the next room along, from above, at walking zoom. Ease out to a\n // camera standing over the person and facing the way they faced, in one move that also\n // straightens the pitch, so the walk reads as stepping back out of the building.\n const bearingOut = stood.heading + (props.project.origin[2] ?? 0);\n steer(m, {\n center: floorCenter(stood.position, floorLift(props.threeD), pitch, bearingOut),\n zoom: 20, // room scale: the floor the walk happened on, not the whole storey\n pitch,\n bearing: bearingOut,\n duration: 700,\n });\n } else if (!skipEase) {\n // Switching between the plan and the model moves the horizon, and with it the depth aim: the\n // floor point under the crosshair is displaced by its own elevation times tan(pitch). Read that\n // point through the view being LEFT and put it back under the crosshair in the same ease.\n const at = floorPoint(m, w / 2, h / 2, floorLift(was.threeD && !was.walk));\n const center = was.threeD !== props.threeD ? floorCenter(at, floorLift(props.threeD), pitch, bearing) : null;\n steer(m, { ...(center ? { center } : {}), pitch, bearing, duration: 600 });\n }\n if (props.walk) {\n // Walk mode owns the handlers and turns them off — said here as well as in the controller so\n // that a walk which somehow fails to attach is inert rather than wrong. This effect also runs\n // in the same commit as the one that entered walk from 2D, so without it the branch below\n // would hand dragRotate straight back.\n for (const h of ['dragPan', 'dragRotate', 'scrollZoom', 'keyboard', 'touchZoomRotate'] as const) m[h]?.disable();\n } else if (props.threeD) {\n m.dragRotate.enable();\n m.touchZoomRotate.enableRotation();\n } else {\n m.dragRotate.disable();\n m.touchZoomRotate.disableRotation();\n } // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props.threeD, props.walk]);\n useEffect(() => {\n const m = map.current;\n if (!m || props.walk) return;\n m.getCanvas().style.cursor = props.tool === 'pan' ? 'grab' : props.tool === 'select' ? '' : 'crosshair';\n }, [props.tool, props.walk]);\n useEffect(() => {\n const m = map.current;\n if (props.playing) return;\n const o = props.project.objects.find(o => o.id === props.focusId);\n if (props.walk) {\n if (o) walker.current?.lookAt(objectPosition(props.project, o));\n return;\n }\n // Through the depth aim: the object's plan position is on the ground, and the storey it belongs\n // to is drawn metres under it, so centring on the raw coordinate leaves a basement object well\n // up the frame — the miss runs along the view axis, not across it. The object's OWN floor, with\n // no fallback to the storey being viewed: out of doors is drawn at grade whichever level is\n // open, so a parcel or an entrance picked while the garage is up wants no aim at all, and\n // borrowing P3's put it a good fifteen metres up the frame.\n if (m && o)\n m.easeTo({\n center: floorAim(m, props.project, objectPosition(props.project, o), o.floorId, props),\n duration: 500,\n });\n }, [props.focusId]); // eslint-disable-line react-hooks/exhaustive-deps\n // Ground-plane projection: no elevation term, which is also how the markers are placed. Its\n // inverse is unproject, so a handle you grab and the point you drop it on are in the same frame\n // whether or not the view is pitched — which is what lets an object be dragged in 3D at all.\n const screen = (p: Point) => map.current?.project(toLngLat(p, props.project.origin));\n function startDrag(\n event: React.PointerEvent<HTMLButtonElement>,\n kind: 'junction' | 'ring' | 'object' | 'barrier' | 'node' | 'opening' | 'rotate' | 'coverage',\n id: string,\n ring?: number,\n vertex?: number,\n ) {\n event.stopPropagation();\n event.preventDefault();\n const m = map.current;\n if (!m || !props.canEdit || (kind === 'node' ? !routeTool : props.tool !== 'select')) return;\n m.dragPan.disable();\n const target = event.currentTarget;\n // A spread handle keeps its screen offset while dragging, so grabbing it does not make\n // the actual endpoint jump out to the handle's display position.\n const bounds = target.getBoundingClientRect();\n const screenDx = Number(target.dataset.screenDx ?? 0) + event.clientX - bounds.left - bounds.width / 2,\n screenDy = Number(target.dataset.screenDy ?? 0) + event.clientY - bounds.top - bounds.height / 2;\n const oldWorld = [target.dataset.wx, target.dataset.wy];\n const origin = { x: event.clientX, y: event.clientY };\n let moved = false;\n // Live preview: temporary lines track the cursor through the lightweight draft source, so the\n // full plan only rebuilds once on release.\n const preview = (clientX: number, clientY: number, free = false) => {\n const rect = m.getContainer().getBoundingClientRect();\n const ll = m.unproject([clientX - rect.left - screenDx, clientY - rect.top - screenDy]);\n const p = latest.current;\n const raw = toLocal([ll.lng, ll.lat], p.project.origin);\n const local =\n kind === 'junction' || kind === 'barrier' || kind === 'ring'\n ? (p.onVertexPreview?.(kind, id, raw, ring, vertex, free) ?? raw)\n : p.snapping && !free && (kind === 'object' || kind === 'node')\n ? ([Math.round(raw[0] * 2) / 2, Math.round(raw[1] * 2) / 2] as Point)\n : raw;\n const at = m.project(toLngLat(local, p.project.origin));\n target.dataset.wx = String(local[0]);\n target.dataset.wy = String(local[1]);\n target.style.left = `${at.x + Number(target.dataset.screenDx ?? 0)}px`;\n target.style.top = `${at.y + Number(target.dataset.screenDy ?? 0)}px`;\n const lines: Point[][] = [];\n if (kind === 'object') {\n const o = p.project.objects.find(x => x.id === id);\n if (o?.rings) {\n const dx = local[0] - o.position[0],\n dy = local[1] - o.position[1];\n lines.push(closeRing(o.rings[0].map(pt => [pt[0] + dx, pt[1] + dy] as Point)));\n }\n } else if (kind === 'ring') {\n const o = p.project.objects.find(x => x.id === id);\n const points = o?.rings?.[ring ?? 0];\n if (points) {\n const open = openRing(points);\n lines.push([\n open[((vertex ?? 0) + open.length - 1) % open.length],\n local,\n open[((vertex ?? 0) + 1) % open.length],\n ]);\n }\n } else if (kind === 'barrier') {\n // Translating a whole wall along its normal only (orthogonal slide); walls sharing those\n // junctions stretch to follow, so the mesh stays connected.\n const b = boundaryEdges(p.project).find(x => x.id === id);\n if (b) {\n const [a, c] = barrierEnds(p.project, b);\n const mid: Point = [(a[0] + c[0]) / 2, (a[1] + c[1]) / 2];\n const len = Math.hypot(c[0] - a[0], c[1] - a[1]);\n const nx = -(c[1] - a[1]) / len,\n ny = (c[0] - a[0]) / len;\n const s = (local[0] - mid[0]) * nx + (local[1] - mid[1]) * ny;\n const dx = nx * s,\n dy = ny * s;\n const a2: Point = [a[0] + dx, a[1] + dy],\n c2: Point = [c[0] + dx, c[1] + dy];\n lines.push([a2, c2]);\n for (const other of boundaryEdges(p.project).filter(\n x =>\n x.id !== id &&\n (x.startId === b.startId || x.endId === b.startId || x.startId === b.endId || x.endId === b.endId),\n )) {\n const [oa, oc] = barrierEnds(p.project, other);\n const movedStart = other.startId === b.startId || other.startId === b.endId;\n const anchor = movedStart ? oc : oa;\n const movedEnd = (movedStart ? other.startId : other.endId) === b.startId ? a2 : c2;\n lines.push([anchor, movedEnd]);\n }\n }\n } else if (kind === 'opening') {\n // Where the leaf will land: the drop projected onto its wall and clamped so the opening\n // stays wholly on the segment — the same arithmetic the commit does, so the ghost is not a\n // near-miss of the result.\n const opening = p.project.objects.find(o => o.id === id);\n const barrier = p.project.barriers.find(b => b.id === opening?.barrierId);\n if (opening && barrier) {\n const [a, b] = barrierEnds(p.project, barrier);\n const hit = segmentProjection(local, a, b);\n const half = opening.width / 2;\n if (hit.length >= opening.width) {\n const offset = Math.max(half, Math.min(hit.length - half, hit.t * hit.length));\n const ux = (b[0] - a[0]) / hit.length,\n uy = (b[1] - a[1]) / hit.length;\n const at: Point = [a[0] + ux * offset, a[1] + uy * offset];\n lines.push([\n [at[0] - ux * half, at[1] - uy * half],\n [at[0] + ux * half, at[1] + uy * half],\n ]);\n if (opening.kind === 'door') {\n const door = { ...opening, offset, position: at, doorSwing: draggedDoorSwing(p.project, opening, local) };\n lines.push(...doorSymbol(p.project, door));\n }\n // A tick across the wall, so a leaf being slid is legible against the wall it slides on.\n const t = barrier.thickness;\n lines.push([\n [at[0] + uy * t, at[1] - ux * t],\n [at[0] - uy * t, at[1] + ux * t],\n ]);\n }\n }\n } else if (kind === 'rotate') {\n const o = p.project.objects.find(x => x.id === id);\n if (o) {\n const degrees = Math.atan2(local[1] - o.position[1], local[0] - o.position[0]);\n lines.push([o.position, local]);\n // An object with a footprint shows that footprint turned; one without — a camera, a\n // marker — is legible from the arm alone.\n if (o.rings?.[0]) {\n const cos = Math.cos(degrees - ((o.rotation ?? 0) * Math.PI) / 180),\n sin = Math.sin(degrees - ((o.rotation ?? 0) * Math.PI) / 180);\n lines.push(\n closeRing(\n o.rings[0].map(pt => {\n const dx = pt[0] - o.position[0],\n dy = pt[1] - o.position[1];\n return [o.position[0] + dx * cos - dy * sin, o.position[1] + dx * sin + dy * cos] as Point;\n }),\n ),\n );\n }\n }\n } else if (kind === 'coverage') {\n // The cone as the release will leave it: reach from the handle's distance, spread from its\n // bearing either side of the object's facing.\n const o = p.project.objects.find(x => x.id === id);\n if (o) {\n const dx = local[0] - o.position[0],\n dy = local[1] - o.position[1];\n const range = Math.max(1, Math.min(120, Math.hypot(dx, dy)));\n const bearing = (Math.atan2(dy, dx) * 180) / Math.PI;\n const half = Math.min(\n 175,\n Math.max(5, Math.abs(((((bearing - (o.rotation ?? 0)) % 360) + 540) % 360) - 180)),\n );\n const facing = ((o.rotation ?? 0) * Math.PI) / 180;\n const arc: Point[] = [o.position];\n const steps = 24;\n for (let k = 0; k <= steps; k++) {\n const th = facing + ((-half + (2 * half * k) / steps) * Math.PI) / 180;\n arc.push([o.position[0] + Math.cos(th) * range, o.position[1] + Math.sin(th) * range]);\n }\n arc.push(o.position);\n lines.push(arc);\n }\n } else if (kind === 'node') {\n const node = p.project.navNodes?.find(n => n.id === id);\n for (const edge of (p.project.navEdges ?? []).filter(e => e.aId === id || e.bId === id)) {\n const other = p.project.navNodes?.find(n => n.id === (edge.aId === id ? edge.bId : edge.aId));\n if (other && node && other.floorId === node.floorId) lines.push([other.position, local]);\n }\n } else\n for (const b of boundaryEdges(p.project).filter(b => b.startId === id || b.endId === id)) {\n const j = p.project.junctions.find(j => j.id === (b.startId === id ? b.endId : b.startId));\n if (j) lines.push([j.position, local]);\n }\n (m.getSource('kerros-draft') as GeoJSONSource | undefined)?.setData({\n type: 'FeatureCollection',\n features: lines.map(points => ({\n type: 'Feature',\n properties: {},\n geometry: { type: 'LineString', coordinates: points.map(pt => toLngLat(pt, p.project.origin)) },\n })),\n } as GeoJSON.FeatureCollection);\n };\n let previewFrame = 0;\n let pending: { x: number; y: number; free: boolean } | undefined;\n const move = (e: PointerEvent) => {\n moved ||= Math.hypot(e.clientX - origin.x, e.clientY - origin.y) > 3;\n if (!moved) return;\n pending = { x: e.clientX, y: e.clientY, free: e.shiftKey };\n // Pointer devices can report several times per display frame. Preview only the latest\n // sample; release still resolves its own exact coordinates through the same snapping.\n previewFrame ||= requestAnimationFrame(() => {\n previewFrame = 0;\n if (pending) preview(pending.x, pending.y, pending.free);\n });\n };\n const up = (e: PointerEvent) => {\n cancelAnimationFrame(previewFrame);\n window.removeEventListener('pointermove', move);\n window.removeEventListener('pointerup', up);\n m.dragPan.enable();\n target.dataset.wx = oldWorld[0] ?? '';\n target.dataset.wy = oldWorld[1] ?? '';\n syncDraft();\n if (moved) {\n suppressClick.current = true;\n const rect = m.getContainer().getBoundingClientRect();\n const ll = m.unproject([e.clientX - rect.left - screenDx, e.clientY - rect.top - screenDy]);\n latest.current.onVertexMove(\n kind,\n id,\n toLocal([ll.lng, ll.lat], props.project.origin),\n ring,\n vertex,\n e.shiftKey,\n );\n setFrame(n => n + 1);\n setTimeout(() => {\n suppressClick.current = false;\n }, 100);\n }\n };\n window.addEventListener('pointermove', move);\n window.addEventListener('pointerup', up, { once: true });\n }\n const selectedObject = props.project.objects.find(o => o.id === props.selected);\n const selectedBarrier = boundaryEdges(props.project).find(b => b.id === props.selected);\n const floor = props.project.floors.find(f => f.id === props.floorId);\n const depthView = undergroundView(props.project, props.floorId, props.threeD && props.stack);\n const m = map.current;\n let scaleWidth = 70;\n // Not while walking: ten metres at the site origin, seen in perspective from eye level, is a\n // different number of pixels on every step, and everything gated on it below would flicker with\n // it. At eye level a marker is worth showing whenever it is near, so the bar is held at the width\n // that shows the nearby ones and the bar itself is not drawn.\n if (m && ready && props.walk) scaleWidth = 80;\n else if (m && ready) {\n const a = screen([0, 0]),\n b = screen([10, 0]);\n if (a && b) scaleWidth = Math.hypot(b.x - a.x, b.y - a.y);\n }\n // Zoom LOD, pass 1 — cheap thresholds: a symbol class only becomes a candidate once the scale\n // could fit it, and a room label must fit inside its own footprint.\n const ppm = scaleWidth / 10;\n const pinned = (o: { id: string; feedId?: string }) =>\n o.id === props.selected || !!(o.feedId && statusTone(props.statuses.get(o.feedId)) === 'critical');\n // Tiered by zoom: full symbol → small colour-coded dot that reveals its name on hover → hidden.\n const tier = (o: {\n kind: string;\n id: string;\n feedId?: string;\n name: string;\n width: number;\n }): 'full' | 'mini' | null => {\n // The walk HUD already names the occupied room. Area dots and labels turn a large interior\n // into a wall of text; reserve in-world markers for nearby devices and wayfinding instead.\n if (props.walk && (o.kind === 'room' || o.kind === 'zone' || o.kind === 'light')) return null;\n if (o.kind === 'light' && !pinned(o)) return null;\n if (pinned(o)) return 'full';\n if (o.kind === 'room' || o.kind === 'zone')\n // An area only earns a dot once it is big enough on screen to be worth pointing at. Without the\n // width test a dense plan (a garage of 2.5 m bays, a warehouse of racks) peppers the view with\n // markers for shapes a few pixels across.\n return ppm >= 3.5 && o.name.length * 6.5 <= o.width * ppm * 1.2\n ? 'full'\n : ppm >= 1.8 && o.width * ppm >= 26\n ? 'mini'\n : null;\n if (o.kind === 'poi' || o.kind === 'gate') return ppm >= 1.2 ? 'full' : ppm >= 0.5 ? 'mini' : null;\n return (['door', 'reader', 'turnstile'].includes(o.kind) ? ppm >= 6 : ppm >= 5)\n ? 'full'\n : ppm >= 2.4\n ? 'mini'\n : null;\n };\n // Outdoor symbols (gates, POIs, parking labels) only accompany the outdoor view and the ground\n // floor; on other levels they are distracting clutter under the building.\n const groundSymbols =\n props.floorId === null || (props.project.floors.find(f => f.id === props.floorId)?.elevation ?? 0) === 0;\n // Pass 2 — screen-space collision culling: symbols claim space in priority order (site wayfinding\n // first, dense per-door hardware last); whatever would overlap stays hidden until zoomed closer.\n const PRIORITY: Record<string, number> = {\n poi: 1,\n gate: 2,\n zone: 3,\n room: 4,\n camera: 5,\n elevator: 6,\n stairs: 7,\n turnstile: 8,\n reader: 9,\n door: 10,\n };\n const items: {\n o: SiteObject;\n s: { x: number; y: number };\n world: Point;\n isLabel: boolean;\n mini: boolean;\n voidLabel: boolean;\n }[] = [];\n if (ready && props.showPlan)\n for (const o of props.project.objects) {\n if (\n !onFloor(props.project, o, props.floorId) ||\n !(groundSymbols || o.floorId !== null || pinned(o)) ||\n ['window', 'building', 'parcel', 'office', 'container', 'storage', 'fixture', 'landscape'].includes(o.kind)\n )\n continue;\n const t = tier(o);\n if (!t) continue;\n const isLabel = o.kind === 'room' || o.kind === 'zone';\n if (isLabel && (!props.showLabels || (props.threeD && props.stack && o.floorId !== props.floorId))) continue;\n const world = objectPosition(props.project, o);\n const s = props.threeD ? scene.current?.projectObject(o) : screen(world);\n if (!s || ('visible' in s && !s.visible)) continue;\n const voidLabel = isLabel && !!o.rings?.slice(1).some(ring => pointInRing(world, ring));\n items.push({ o, s, world, isLabel: isLabel && t === 'full', mini: t === 'mini', voidLabel });\n }\n items.sort((a, b) => (pinned(a.o) ? 0 : (PRIORITY[a.o.kind] ?? 9)) - (pinned(b.o) ? 0 : (PRIORITY[b.o.kind] ?? 9)));\n const placed: { x: number; y: number; w: number; h: number }[] = [];\n const markers = items.filter(({ o, s, isLabel, mini, voidLabel }) => {\n const w = mini ? 8 : isLabel ? (voidLabel ? 90 : Math.max(36, o.name.length * 3.6)) : 19,\n h = mini ? 8 : isLabel ? (voidLabel ? 36 : 16) : 19;\n if (!pinned(o) && placed.some(q => Math.abs(q.x - s.x) < q.w + w && Math.abs(q.y - s.y) < q.h + h)) return false;\n placed.push({ x: s.x, y: s.y, w, h });\n return true;\n });\n const st = mapStyleRef.current?.statusTones;\n const TONE: Record<string, string> = {\n normal: st?.normal ?? '#2e9e6b',\n warning: st?.warning ?? '#e39d3b',\n critical: st?.critical ?? '#e0524e',\n unknown: st?.unknown ?? '#9a9daf',\n };\n const MINI: Record<string, string> = {\n room: '#a9b3c2',\n zone: '#96a58b',\n poi: '#1d2038',\n gate: '#5d6390',\n door: '#6a63d8',\n camera: '#7b74dd',\n elevator: '#567c9a',\n stairs: '#6d7a90',\n reader: '#4a7fb5',\n turnstile: '#4a7fb5',\n sensor: '#5b9bd0',\n alarm: '#e0524e',\n equipment: '#9a8f74',\n };\n return (\n <div\n className={`map-wrap ${props.threeD ? 'perspective' : ''}`}\n data-frame={frame > 0 ? 'ready' : 'loading'}\n data-scene={props.threeD && props.showPlan ? (scene.current?.diagnostics.drawCalls ? 'ready' : 'loading') : 'off'}\n >\n <div className=\"map-surface\" ref={container} data-testid=\"map-canvas\" />\n <div className=\"map-overlay\" ref={overlay}>\n {markers.map(({ o, s, world, isLabel, mini, voidLabel }) => {\n const status = o.feedId ? props.statuses.get(o.feedId) : undefined;\n if (mini)\n return (\n <button\n key={o.id}\n onMouseEnter={clampTooltip}\n className={`mini-marker ${o.category ? 'cat-' + o.category : ''}`}\n data-wx={world[0]}\n data-wy={world[1]}\n data-oid={o.id}\n data-kind={o.kind}\n data-category={o.category}\n style={{\n left: s.x,\n top: s.y,\n background:\n mapStyleRef.current?.objectColor?.(o) ??\n (o.feedId ? TONE[statusTone(status)] : (MINI[o.kind] ?? o.color ?? '#9a9daf')),\n }}\n title={`${o.name}${o.feedId ? ` · ${statusLabel(status)}` : ''}`}\n aria-label={o.name}\n onClick={e => {\n e.stopPropagation();\n if (props.tool === 'select' || props.threeD) props.onSelect(o.id);\n else props.onClick(objectPosition(props.project, o), o.id);\n }}\n >\n <span className=\"marker-tooltip\">\n {o.name}\n {o.feedId ? ` · ${statusLabel(status)}` : ''}\n </span>\n </button>\n );\n return isLabel ? (\n <div\n key={o.id}\n className={`space-label ${o.floorId === null ? 'outdoor' : ''} ${voidLabel ? 'void-label' : ''}`}\n data-wx={world[0]}\n data-wy={world[1]}\n data-oid={o.id}\n style={{ left: s.x, top: s.y }}\n >\n <span>{o.name}</span>\n {o.kind === 'room' && <small>{Math.round(objectArea(o))} m²</small>}\n {voidLabel && o.kind === 'zone' && floor && (\n <small>\n {floor.code ? `${floor.code} · ` : ''}\n {floor.elevation.toFixed(0)} m\n </small>\n )}\n </div>\n ) : (\n <button\n key={o.id}\n onMouseEnter={clampTooltip}\n className={`entity-marker ${o.kind === 'poi' ? 'poi' : ''} ${o.category ? 'cat-' + o.category : ''} ${statusTone(status)} ${props.selected === o.id ? 'selected' : ''}`}\n data-wx={world[0]}\n data-wy={world[1]}\n data-oid={o.id}\n data-kind={o.kind}\n data-category={o.category}\n style={{ left: s.x, top: s.y }}\n title={`${o.name}${o.feedId ? ` · ${statusLabel(status)}` : ''}`}\n aria-label={o.name}\n onClick={e => {\n e.stopPropagation();\n if (props.tool === 'select' || props.threeD) props.onSelect(o.id);\n else props.onClick(objectPosition(props.project, o), o.id);\n }}\n >\n <EntityIcon\n kind={o.kind}\n size={o.kind === 'door' ? 14 : 17}\n symbol={o.symbol}\n travel={status?.travel ?? o.travel}\n />\n {o.feedId && <i className={`status-dot ${statusTone(status)}`} />}\n <span className=\"marker-tooltip\">{o.name}</span>\n </button>\n );\n })}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedObject?.geometry?.mode === 'boundaries' &&\n (() => {\n const used = new Set(selectedObject.geometry.loops.flat().map(u => u.edgeId));\n const edges = boundaryEdges(props.project).filter(e => used.has(e.id));\n const junctions = new Set(edges.flatMap(e => [e.startId, e.endId]));\n return (\n <>\n {props.project.junctions\n .filter(j => junctions.has(j.id))\n .map((j, i) => {\n const s = screen(j.position);\n return (\n s && (\n <button\n key={j.id}\n aria-label={`Move space boundary corner ${i + 1}`}\n className=\"vertex-handle\"\n data-wx={j.position[0]}\n data-wy={j.position[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'junction', j.id)}\n />\n )\n );\n })}\n {edges.map((edge, i) => {\n const [a, b] = barrierEnds(props.project, edge),\n mid: Point = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2],\n s = screen(mid);\n return (\n s && (\n <button\n key={edge.id}\n aria-label={`Move space boundary ${i + 1}`}\n title=\"Drag this boundary; connected spaces follow\"\n className=\"move-handle\"\n data-wx={mid[0]}\n data-wy={mid[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'barrier', edge.id)}\n >\n ✥\n </button>\n )\n );\n })}\n </>\n );\n })()}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedObject?.geometry?.mode !== 'boundaries' &&\n selectedObject?.rings?.flatMap((r, ri) =>\n openRing(r).map((p, i) => {\n const s = screen(p);\n return s ? (\n <button\n key={`${ri}-${i}`}\n aria-label={`Move vertex ${i + 1}`}\n className=\"vertex-handle\"\n data-wx={p[0]}\n data-wy={p[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'ring', selectedObject.id, ri, i)}\n />\n ) : null;\n }),\n )}\n {props.canEdit &&\n props.tool === 'select' &&\n // Ground-plane handles, like the vertex and junction ones: in 3D the object is drawn at its\n // storey's elevation and the handle would hang metres away from it, in open air over a\n // basement or inside the slab over a tower.\n !props.threeD &&\n selectedObject &&\n selectedObject.geometry?.mode !== 'boundaries' &&\n (() => {\n const s = screen(selectedObject.position);\n // An opening cannot go wherever the pointer went — it belongs to its wall. Same handle,\n // different constraint: the drop is projected back onto the barrier it is fitted to.\n const attached = !!selectedObject.barrierId;\n return s ? (\n <button\n className=\"move-handle\"\n aria-label={attached ? 'Slide along the wall' : 'Move selected object'}\n title={\n selectedObject.kind === 'door'\n ? 'Drag along the wall to slide; across it to flip the opening side'\n : undefined\n }\n data-wx={selectedObject.position[0]}\n data-wy={selectedObject.position[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, attached ? 'opening' : 'object', selectedObject.id)}\n >\n ✥\n </button>\n ) : null;\n })()}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedObject &&\n selectedObject.geometry?.mode !== 'boundaries' &&\n !selectedObject.barrierId &&\n selectedObject.rotation !== undefined &&\n (() => {\n // A turned object had no visible affordance at all: the angle was a number in a panel.\n // The handle stands off along the object's own facing, at arm's length from its footprint.\n const reach = Math.max(1.6, (Math.abs(selectedObject.width) + Math.abs(selectedObject.depth)) / 2 + 0.8);\n const at = add(selectedObject.position, rotate([reach, 0], selectedObject.rotation));\n const s = screen(at);\n return s ? (\n <button\n className=\"rotate-handle\"\n aria-label=\"Turn selected object\"\n data-wx={at[0]}\n data-wy={at[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'rotate', selectedObject.id)}\n />\n ) : null;\n })()}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedObject?.kind === 'camera' &&\n (() => {\n // One handle for the whole cone: how far it reaches is the distance, how wide it opens\n // is twice the angle off the camera's facing. Dragging it does both at once, which is\n // how you actually aim a camera — pull it to the thing you want in frame.\n const range = selectedObject.coverageRange ?? 12;\n const half = (selectedObject.coverageAngle ?? 70) / 2;\n const at = add(selectedObject.position, rotate([range, 0], selectedObject.rotation + half));\n const s = screen(at);\n return s ? (\n <button\n className=\"coverage-handle\"\n aria-label=\"Camera reach and field of view\"\n data-wx={at[0]}\n data-wy={at[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'coverage', selectedObject.id)}\n />\n ) : null;\n })()}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedBarrier &&\n barrierEnds(props.project, selectedBarrier).map((p, i) => {\n const s = screen(p);\n const other = screen(barrierEnds(props.project, selectedBarrier)[1 - i]);\n if (!s || !other) return null;\n // Short walls still need three independently grabbable controls. Spread endpoint\n // handles along the wall's axis, with a tether back to the actual junction.\n const dx = s.x - other.x,\n dy = s.y - other.y;\n const span = Math.hypot(dx, dy);\n const pad = Math.max(0, 32 - span / 2);\n const ux = span ? dx / span : i ? 1 : -1,\n uy = span ? dy / span : 0;\n return (\n <Fragment key={i}>\n {pad > 0 && (\n <span\n aria-hidden=\"true\"\n data-wx={p[0]}\n data-wy={p[1]}\n style={{\n position: 'absolute',\n pointerEvents: 'none',\n left: s.x,\n top: s.y,\n width: pad,\n height: 1,\n background: 'var(--accent)',\n transformOrigin: '0 0',\n transform: `rotate(${Math.atan2(uy, ux)}rad)`,\n }}\n />\n )}\n <button\n className=\"vertex-handle\"\n aria-label={`Move wall endpoint ${i + 1}`}\n data-wx={p[0]}\n data-wy={p[1]}\n data-screen-dx={ux * pad}\n data-screen-dy={uy * pad}\n style={{ left: s.x + ux * pad, top: s.y + uy * pad }}\n onPointerDown={e => startDrag(e, 'junction', i ? selectedBarrier.endId : selectedBarrier.startId)}\n />\n </Fragment>\n );\n })}\n {props.canEdit &&\n props.tool === 'select' &&\n !props.threeD &&\n selectedBarrier &&\n (() => {\n const [a, b] = barrierEnds(props.project, selectedBarrier);\n const mid: Point = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];\n const s = screen(mid);\n return s ? (\n <button\n className=\"move-handle\"\n aria-label=\"Move whole wall\"\n title=\"Drag to move the wall; connected walls follow\"\n data-wx={mid[0]}\n data-wy={mid[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'barrier', selectedBarrier.id)}\n >\n ✥\n </button>\n ) : null;\n })()}\n {props.canEdit &&\n routeTool &&\n !props.threeD &&\n (props.project.navNodes ?? [])\n .filter(n => visibleOnFloor(n, props.floorId))\n .map(n => {\n const s = screen(n.position);\n return s ? (\n <button\n key={n.id}\n className=\"vertex-handle nav-node-handle\"\n aria-label=\"Move route node\"\n title=\"Drag to move this route node\"\n data-wx={n.position[0]}\n data-wy={n.position[1]}\n style={{ left: s.x, top: s.y }}\n onPointerDown={e => startDrag(e, 'node', n.id)}\n />\n ) : null;\n })}\n {props.draft.map((p, i) => {\n const s = screen(p);\n return s ? (\n <i key={i} className=\"draft-node\" data-wx={p[0]} data-wy={p[1]} style={{ left: s.x, top: s.y }} />\n ) : null;\n })}\n {props.alignment?.map.map((p, i) => {\n const s = screen(p);\n return s ? (\n <b key={i} className=\"alignment-pin\" data-wx={p[0]} data-wy={p[1]} style={{ left: s.x, top: s.y }}>\n {i + 1}\n </b>\n ) : null;\n })}\n {(() => {\n // The person, where the last walk left them, on the floor they were left on. Clicking\n // them picks the walk back up from there.\n const a = props.avatar;\n if (!a || props.walk || a.floorId !== props.floorId) return null;\n const s = (props.threeD ? scene.current?.projectPoint(a.position, a.floorId) : null) ?? screen(a.position);\n if (!s) return null;\n const bearing = a.heading + (props.project.origin[2] ?? 0);\n return (\n <button\n className=\"avatar-marker\"\n data-wx={a.position[0]}\n data-wy={a.position[1]}\n data-floor={a.floorId ?? ''}\n data-bearing={bearing}\n style={\n {\n left: s.x,\n top: s.y,\n '--turn': `${bearing - (map.current?.getBearing() ?? 0)}deg`,\n } as CSSProperties\n }\n title=\"Resume walking from here\"\n aria-label=\"Resume walking from here\"\n onClick={e => {\n e.stopPropagation();\n props.onWalkAt?.(a);\n }}\n >\n <i />\n <PersonStanding size={13} />\n </button>\n );\n })()}\n </div>\n {props.threeD && !props.walk && (\n <label className=\"pitch-control\" title=\"Camera inclination (⇧W / ⇧S)\">\n <Mountain size={14} />\n <input\n type=\"range\"\n min={0}\n max={75}\n step={1}\n value={Math.round(pitch)}\n aria-label=\"Camera inclination\"\n onChange={e => map.current?.easeTo({ pitch: Number(e.target.value), duration: 0 })}\n />\n </label>\n )}\n {!props.walk && (\n <div className=\"map-navigator\">\n {!props.walk && (\n <>\n <button\n className={`pegman ${peg ? 'lifted' : ''}`}\n title=\"Drag onto the map to walk from there\"\n aria-label=\"Drag onto the map to walk from there\"\n onPointerDown={e => {\n if (e.button !== 0) return;\n e.currentTarget.setPointerCapture(e.pointerId);\n const r = container.current?.getBoundingClientRect();\n if (r) setPeg({ x: e.clientX - r.left, y: e.clientY - r.top });\n }}\n onPointerMove={e => {\n if (!peg) return;\n const r = container.current?.getBoundingClientRect();\n if (r) setPeg({ x: e.clientX - r.left, y: e.clientY - r.top });\n }}\n onPointerUp={dropPeg}\n onPointerCancel={e => {\n e.currentTarget.releasePointerCapture(e.pointerId);\n setPeg(null);\n }}\n // A click without a drag walks from wherever the walker last stood, or the middle\n // of the view — the same as the Walk button, for anyone who does not think to drag.\n onClick={() => {\n const m = map.current;\n const p = latest.current;\n if (!m) return;\n const a = p.avatar && p.avatar.floorId === p.floorId ? p.avatar : null;\n p.onWalkAt?.(\n a ?? {\n floorId: p.floorId,\n position: floorPoint(m, m.getCanvas().clientWidth / 2, m.getCanvas().clientHeight / 2),\n heading: m.getBearing() - (p.project.origin[2] ?? 0),\n },\n );\n }}\n >\n <PersonStanding size={19} />\n </button>\n <div />\n </>\n )}\n <button title=\"Zoom in\" aria-label=\"Zoom in\" onClick={() => map.current?.zoomIn()}>\n <Plus size={18} />\n </button>\n <button title=\"Zoom out\" aria-label=\"Zoom out\" onClick={() => map.current?.zoomOut()}>\n <Minus size={18} />\n </button>\n <div />\n {props.threeD && (\n <>\n <button\n title=\"Tilt view\"\n aria-label=\"Tilt view\"\n onClick={() => {\n const m = map.current;\n if (m) m.easeTo({ pitch: m.getPitch() >= 50 ? 20 : m.getPitch() + 15, duration: 400 });\n }}\n >\n <Mountain size={17} />\n </button>\n <button\n title=\"Rotate left\"\n aria-label=\"Rotate left\"\n onClick={() => {\n const m = map.current;\n if (m) m.easeTo({ bearing: m.getBearing() - 45, duration: 450 });\n }}\n >\n <RotateCcw size={17} />\n </button>\n <button\n title=\"Rotate right\"\n aria-label=\"Rotate right\"\n onClick={() => {\n const m = map.current;\n if (m) m.easeTo({ bearing: m.getBearing() + 45, duration: 450 });\n }}\n >\n <RotateCw size={17} />\n </button>\n <div />\n </>\n )}\n <button title=\"Fit floor\" aria-label=\"Fit floor\" onClick={() => fit(props.floorId)}>\n <LocateFixed size={18} />\n </button>\n <button\n title=\"Reset north\"\n aria-label=\"Reset north\"\n onClick={() => map.current?.easeTo({ bearing: siteBearing(props.project), pitch: props.threeD ? 35 : 0 })}\n >\n <Compass size={18} />\n </button>\n </div>\n )}\n {props.walk && props.elevators && (\n <Suspense fallback={null}>\n <ElevatorPanel\n project={props.project}\n floorId={props.floorId}\n controls={props.elevators}\n walker={walker}\n riding={riding}\n onRide={ride}\n onFloor={props.onRequestFloor}\n requested={elevatorRequest}\n onWave={() => scene.current?.wave()}\n soundOn={walkHint.sound}\n onSound={toggleWalkSound}\n />\n </Suspense>\n )}\n {props.walk && (\n <label className=\"walk-fov\" title=\"Horizontal field of view\">\n <span>\n Field of view <output>{walkFov}°</output>\n </span>\n <input\n type=\"range\"\n min={MIN_WALK_FOV}\n max={MAX_WALK_FOV}\n step={1}\n value={walkFov}\n aria-label=\"POV field of view\"\n aria-valuetext={`${walkFov} degrees horizontally`}\n onChange={e => {\n const value = walkFieldOfView(Number(e.target.value));\n setWalkFov(value);\n try {\n localStorage.setItem(FOV_KEY, String(value));\n } catch {\n /* The control still works when preferences cannot be stored. */\n }\n }}\n />\n </label>\n )}\n {props.walk && (\n <div className=\"walk-hud\">\n <div className=\"walk-status\">\n {(journeyMessage || walkHint.next) && <em role=\"status\">{journeyMessage || walkHint.next}</em>}\n {walkHint.where && <b>{walkHint.where}</b>}\n {walkHint.up && (\n <span>\n <kbd>F</kbd> up to {walkHint.up}\n </span>\n )}\n {walkHint.down && (\n <span>\n <kbd>⇧F</kbd> down to {walkHint.down}\n </span>\n )}\n </div>\n <div className={`walk-keys ${walkHint.looking ? 'busy' : ''}`}>\n <span>Drag to look around</span>\n <span>\n <kbd>W</kbd>\n <kbd>S</kbd> walk\n </span>\n <span>\n <kbd>A</kbd>\n <kbd>D</kbd> turn\n </span>\n <span>\n <kbd>Q</kbd>\n <kbd>E</kbd> sidestep\n </span>\n <span>\n <kbd>Shift</kbd> run\n </span>\n <span>\n <kbd>M</kbd> {walkHint.sound ? 'mute' : 'sound'}\n </span>\n <span>\n <kbd>Esc</kbd> leave\n </span>\n </div>\n </div>\n )}\n {peg && (\n <div className=\"pegman-ghost\" style={{ left: peg.x, top: peg.y }}>\n <PersonStanding size={22} />\n </div>\n )}\n <div className=\"map-scale\" hidden={props.walk}>\n <span style={{ width: scaleWidth }} />\n 10 m <i />{' '}\n {props.threeD\n ? `${props.stack ? 'Building stack' : (floor?.name ?? 'Outdoor site')} · ${depthView.buried ? `${floor ? `${Math.abs(floor.elevation).toFixed(1)} m below ground` : 'Below-ground structure'}${depthView.compressed ? (floor ? ` · shown at ${Math.abs(depthView.focusElevation).toFixed(1)} m` : ' · depth compressed') : ''}` : 'cutaway'}`\n : 'metres'}\n </div>\n {mapError && (\n <button className=\"map-error\" onClick={() => setMapError('')}>\n {mapError} ×\n </button>\n )}\n {!ready && !mapError && (\n <div className=\"map-loading\">\n <span className=\"loading-orbit\" />\n Preparing your space…\n </div>\n )}\n </div>\n );\n}\n"],"names":["ElevatorPanel","lazy","m","EMPTY_FEATURES","DIM_FEATURES","planFeatures","p","mapStyle","entities","makeFeatures","activeFloor","f","band","lower","a","b","upper","ctx","fl","level","walls","_a","siteBearing","project","NO_HINT","MUTED_KEY","FOV_KEY","MapCanvas","props","container","useRef","map","scene","latest","urls","ready","setReady","useState","frame","setFrame","mapError","setMapError","pitch","setPitch","useEffect","pan","event","offset","sceneModule","scenePending","loadScene","active","sync","n","error","suppressClick","overlay","hoverId","styleReady","useKerrosTheme","mapStyleRef","strings","useStrings","stringsRef","entityFeatures","useMemo","draftData","draftFeatures","guideData","barrierEnds","g","pt","toLngLat","routeTool","navSelected","_b","routeData","routeFeatures","navGraphData","navGraphFeatures","entityData","draftSourceData","routeSourceData","guideSourceData","navSourceData","journey","appliedSourceData","objectsById","o","objectIndex","clampTooltip","tip","wrap","w","r","half","veiled","veilBasemap","layer","id","was","reposition","el","byId","child","wx","wy","oid","floor","bearing","s","cityHidden","cityIds","footprintFilters","refreshCityFilter","fp","undergroundView","source","parcels","ids","fid","_c","ring","c","local","toLocal","pointInRing","next","mine","adoptAt","point","layers","l","hit","polys","poly","best","polygonClipping","ringArea","tidy","out","openRing","rings","_e","_d","syncDraft","name","data","syncLayers","routeArrowImage","sources","ms","sel","selFill","hoverColor","draftColor","areaOpacity","small","trackWidth","outer","ROUTE_EDGE","ROUTE_COLOR","ROUTE_SOFT","routeFlowGradient","underground","dusk","ambient","beam","sunlight","daylight","mixColor","routeOn","graphOn","e","base","_f","citySource","_g","cad","_i","_h","Layer","veil","_j","_k","rider","status","shaft","_l","validIds","d","url","coordinates","drawingCorners","cam","maplibregl","neutralBasemap","MAX_MAP_ZOOM","lastPitch","now","aimTimer","markAim","noteAim","settleAim","aimBack","fit","lastFrame","bumpFrame","guardedBump","neighbor","near","hover","resize","forwardWheel","scopeFloor","scoped","j","indoor","points","safe","bounds","camera","zoom","focusFloor","elev","perPixel","altitude","cameraToCenterDistance","adjusted","at","aimCenter","steer","phase","tick","walker","walkSound","riding","setRiding","elevatorRequest","setElevatorRequest","journeyMessage","setJourneyMessage","ride","ambienceAt","leftAt","walkHint","setWalkHint","toggleWalkSound","sound","hintRef","walkFov","setWalkFov","walkFieldOfView","DEFAULT_WALK_FOV","hintAt","avatarAt","peg","setPeg","floorLift","lifted","LIFT","SLAB","floorPoint","x","y","lift","ground","floorCenter","pitchDeg","bearingDeg","ll","aimHeld","steering","options","settled","timer","h","dropPeg","supportedFloors","floorSupport","staticWalkWalls","walkingWallRings","walkWalls","floorIndex","servedFloors","elevatorWalls","EYE","rectangle","startPose","planHeading","onRoute","avatar","cameraPosition","eyeLevel","here","pose","position","spaceAt","spaces","isSpace","objectArea","space","spacePoint","inSpace","guide","route","nearest","i","distance","step","metres","climb","index","served","only","above","below","AmbienceEngine","muted","wake","controller","WalkController","fresh","transfer","up","down","room","target","floorId","start","unstick","final","stood","walkedFloor","walkStairs","stairSurfaces","arrival","floorArrival","waitForFloor","resolve","rev","frames","done","check","cancelled","JourneyPlayer","host","reject","text","interrupt","WalkJourney","firstTilt","config","loadBasemap","style","live","assetId","missing","blob","prevView","skipEase","bearingOut","center","objectPosition","floorAim","screen","startDrag","kind","vertex","screenDx","screenDy","oldWorld","origin","moved","preview","clientX","clientY","free","rect","raw","lines","dx","dy","closeRing","open","boundaryEdges","mid","len","nx","ny","a2","c2","other","oa","oc","movedStart","anchor","movedEnd","opening","barrier","segmentProjection","ux","uy","door","draggedDoorSwing","doorSymbol","t","degrees","cos","sin","range","facing","arc","steps","k","th","node","edge","previewFrame","pending","move","selectedObject","selectedBarrier","depthView","scaleWidth","ppm","pinned","statusTone","tier","groundSymbols","PRIORITY","items","onFloor","isLabel","world","voidLabel","placed","markers","mini","q","st","TONE","MINI","jsxs","jsx","statusLabel","EntityIcon","used","u","edges","junctions","Fragment","ri","attached","reach","add","rotate","span","pad","visibleOnFloor","_m","PersonStanding","Mountain","Plus","Minus","RotateCcw","RotateCw","LocateFixed","Compass","Suspense","MIN_WALK_FOV","MAX_WALK_FOV","value"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAMA,KAAgBC,GAAK,MAAM,OAAO,gCAA6B,EAAE,KAAK,CAAAC,OAAM,EAAE,SAASA,EAAE,cAAA,EAAgB,CAAC,GAmF1GC,KAA4C,EAAE,MAAM,qBAAqB,UAAU,CAAA,EAAC,GACpFC,KAA0C;AAAA,EAC9C,MAAM;AAAA,EACN,UAAU;AAAA,IACR;AAAA,MACE,MAAM;AAAA,MACN,YAAY,CAAA;AAAA,MACZ,UAAU;AAAA,QACR,MAAM;AAAA,QACN,aAAa;AAAA,UACX;AAAA,YACE,CAAC,MAAM,GAAG;AAAA,YACV,CAAC,KAAK,GAAG;AAAA,YACT,CAAC,KAAK,EAAE;AAAA,YACR,CAAC,MAAM,EAAE;AAAA,YACT,CAAC,MAAM,GAAG;AAAA,UAAA;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEJ;AAEA,SAASC,GAAaC,GAAmBC,GAAuD;AAE9F,MAAID,EAAE,OAAQ,QAAOH;AACrB,QAAMK,IAAWC,GAAaH,EAAE,SAASA,EAAE,SAASA,EAAE,UAAUA,EAAE,UAAUA,EAAE,UAAUC,CAAQ,GAG1FG,IAAcJ,EAAE,QAAQ,OAAO,KAAK,CAAAK,MAAKA,EAAE,OAAOL,EAAE,OAAO;AACjE,MAAII,KAAA,QA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