@mapcairn/map 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 (315) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +167 -2
  3. package/dist/chrome/Attribution/Attribution.js +304 -0
  4. package/dist/chrome/Attribution/Attribution.js.map +1 -0
  5. package/dist/chrome/Attribution/Attribution.styles.js +10 -0
  6. package/dist/chrome/Attribution/Attribution.styles.js.map +1 -0
  7. package/dist/chrome/Attribution/AttributionSkeleton.js +29 -0
  8. package/dist/chrome/Attribution/AttributionSkeleton.js.map +1 -0
  9. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js +83 -0
  10. package/dist/chrome/ChromeSkeleton/ChromeSkeleton.js.map +1 -0
  11. package/dist/chrome/EndStack/EndStack.js +157 -0
  12. package/dist/chrome/EndStack/EndStack.js.map +1 -0
  13. package/dist/chrome/EndStack/EndStack.styles.js +12 -0
  14. package/dist/chrome/EndStack/EndStack.styles.js.map +1 -0
  15. package/dist/chrome/EndStack/EndStackSkeleton.js +78 -0
  16. package/dist/chrome/EndStack/EndStackSkeleton.js.map +1 -0
  17. package/dist/chrome/EndStack/endStackHeight.js +22 -0
  18. package/dist/chrome/EndStack/endStackHeight.js.map +1 -0
  19. package/dist/chrome/MapChrome/MapChrome.js +488 -0
  20. package/dist/chrome/MapChrome/MapChrome.js.map +1 -0
  21. package/dist/chrome/MapChrome/MapChrome.styles.js +15 -0
  22. package/dist/chrome/MapChrome/MapChrome.styles.js.map +1 -0
  23. package/dist/chrome/MapChrome/chromeSurface.js +18 -0
  24. package/dist/chrome/MapChrome/chromeSurface.js.map +1 -0
  25. package/dist/chrome/MapChrome/chromeVars.js +71 -0
  26. package/dist/chrome/MapChrome/chromeVars.js.map +1 -0
  27. package/dist/chrome/MapChrome/mapKeyPlacement.js +41 -0
  28. package/dist/chrome/MapChrome/mapKeyPlacement.js.map +1 -0
  29. package/dist/chrome/MapChrome/sharesWidth.js +13 -0
  30. package/dist/chrome/MapChrome/sharesWidth.js.map +1 -0
  31. package/dist/chrome/MapReadout/MapReadout.js +199 -0
  32. package/dist/chrome/MapReadout/MapReadout.js.map +1 -0
  33. package/dist/chrome/MapReadout/MapReadout.styles.js +14 -0
  34. package/dist/chrome/MapReadout/MapReadout.styles.js.map +1 -0
  35. package/dist/chrome/Sheet/Sheet.js +412 -0
  36. package/dist/chrome/Sheet/Sheet.js.map +1 -0
  37. package/dist/chrome/Sheet/Sheet.styles.js +14 -0
  38. package/dist/chrome/Sheet/Sheet.styles.js.map +1 -0
  39. package/dist/chrome/focusRegistry.js +76 -0
  40. package/dist/chrome/focusRegistry.js.map +1 -0
  41. package/dist/chrome/layoutContext.js +30 -0
  42. package/dist/chrome/layoutContext.js.map +1 -0
  43. package/dist/chrome/useScrollEdges.js +53 -0
  44. package/dist/chrome/useScrollEdges.js.map +1 -0
  45. package/dist/host/MapContext.js +16 -0
  46. package/dist/host/MapContext.js.map +1 -0
  47. package/dist/host/MapView.js +189 -0
  48. package/dist/host/MapView.js.map +1 -0
  49. package/dist/host/MapView.styles.js +16 -0
  50. package/dist/host/MapView.styles.js.map +1 -0
  51. package/dist/host/overlays/AccuracyCircle.js +36 -0
  52. package/dist/host/overlays/AccuracyCircle.js.map +1 -0
  53. package/dist/host/overlays/CentreCrosshair.js +40 -0
  54. package/dist/host/overlays/CentreCrosshair.js.map +1 -0
  55. package/dist/host/overlays/DrawOverlay.js +221 -0
  56. package/dist/host/overlays/DrawOverlay.js.map +1 -0
  57. package/dist/host/overlays/MapOverlayLayer.js +27 -0
  58. package/dist/host/overlays/MapOverlayLayer.js.map +1 -0
  59. package/dist/host/overlays/MeasureOverlay.js +87 -0
  60. package/dist/host/overlays/MeasureOverlay.js.map +1 -0
  61. package/dist/host/overlays/PinMarker.js +40 -0
  62. package/dist/host/overlays/PinMarker.js.map +1 -0
  63. package/dist/host/overlays/geometry.js +41 -0
  64. package/dist/host/overlays/geometry.js.map +1 -0
  65. package/dist/host/overlays/overlays.styles.js +27 -0
  66. package/dist/host/overlays/overlays.styles.js.map +1 -0
  67. package/dist/host/pointerTargets.js +22 -0
  68. package/dist/host/pointerTargets.js.map +1 -0
  69. package/dist/host/useLongPress.js +102 -0
  70. package/dist/host/useLongPress.js.map +1 -0
  71. package/dist/host/useMapEngine.js +352 -0
  72. package/dist/host/useMapEngine.js.map +1 -0
  73. package/dist/host/usePointerPosition.js +60 -0
  74. package/dist/host/usePointerPosition.js.map +1 -0
  75. package/dist/index.d.ts +3845 -0
  76. package/dist/index.js +89 -0
  77. package/dist/layers/CatalogueStatus.js +138 -0
  78. package/dist/layers/CatalogueStatus.js.map +1 -0
  79. package/dist/layers/DateTimeControl.js +101 -0
  80. package/dist/layers/DateTimeControl.js.map +1 -0
  81. package/dist/layers/FeatureCard.js +147 -0
  82. package/dist/layers/FeatureCard.js.map +1 -0
  83. package/dist/layers/FeatureChoices.js +101 -0
  84. package/dist/layers/FeatureChoices.js.map +1 -0
  85. package/dist/layers/FeatureGlyph.js +56 -0
  86. package/dist/layers/FeatureGlyph.js.map +1 -0
  87. package/dist/layers/IdentifyStatus.js +36 -0
  88. package/dist/layers/IdentifyStatus.js.map +1 -0
  89. package/dist/layers/LayerItem.js +321 -0
  90. package/dist/layers/LayerItem.js.map +1 -0
  91. package/dist/layers/LayerKey.js +36 -0
  92. package/dist/layers/LayerKey.js.map +1 -0
  93. package/dist/layers/Layers.styles.js +50 -0
  94. package/dist/layers/Layers.styles.js.map +1 -0
  95. package/dist/layers/LayersSection.js +267 -0
  96. package/dist/layers/LayersSection.js.map +1 -0
  97. package/dist/layers/MapDataLayers.js +261 -0
  98. package/dist/layers/MapDataLayers.js.map +1 -0
  99. package/dist/layers/MapKey.js +131 -0
  100. package/dist/layers/MapKey.js.map +1 -0
  101. package/dist/layers/MapKey.styles.js +16 -0
  102. package/dist/layers/MapKey.styles.js.map +1 -0
  103. package/dist/layers/MarkerGlyph.js +84 -0
  104. package/dist/layers/MarkerGlyph.js.map +1 -0
  105. package/dist/layers/SelectionProvider.js +27 -0
  106. package/dist/layers/SelectionProvider.js.map +1 -0
  107. package/dist/layers/ShapeGlyph.js +122 -0
  108. package/dist/layers/ShapeGlyph.js.map +1 -0
  109. package/dist/layers/TurnOffActions.js +147 -0
  110. package/dist/layers/TurnOffActions.js.map +1 -0
  111. package/dist/layers/answersTap.js +16 -0
  112. package/dist/layers/answersTap.js.map +1 -0
  113. package/dist/layers/catalogueNotice.js +65 -0
  114. package/dist/layers/catalogueNotice.js.map +1 -0
  115. package/dist/layers/catalogueReconcile.js +55 -0
  116. package/dist/layers/catalogueReconcile.js.map +1 -0
  117. package/dist/layers/catalogueView.js +32 -0
  118. package/dist/layers/catalogueView.js.map +1 -0
  119. package/dist/layers/featureTitle.js +14 -0
  120. package/dist/layers/featureTitle.js.map +1 -0
  121. package/dist/layers/identifyFeedback.js +30 -0
  122. package/dist/layers/identifyFeedback.js.map +1 -0
  123. package/dist/layers/identifyRun.js +148 -0
  124. package/dist/layers/identifyRun.js.map +1 -0
  125. package/dist/layers/layerStatus.js +13 -0
  126. package/dist/layers/layerStatus.js.map +1 -0
  127. package/dist/layers/loadOutcome.js +107 -0
  128. package/dist/layers/loadOutcome.js.map +1 -0
  129. package/dist/layers/loadReport.js +33 -0
  130. package/dist/layers/loadReport.js.map +1 -0
  131. package/dist/layers/loadRequests.js +73 -0
  132. package/dist/layers/loadRequests.js.map +1 -0
  133. package/dist/layers/mapFeatures.js +307 -0
  134. package/dist/layers/mapFeatures.js.map +1 -0
  135. package/dist/layers/mapKeyBlocks.js +24 -0
  136. package/dist/layers/mapKeyBlocks.js.map +1 -0
  137. package/dist/layers/reveal.js +119 -0
  138. package/dist/layers/reveal.js.map +1 -0
  139. package/dist/layers/selectionMessages.js +53 -0
  140. package/dist/layers/selectionMessages.js.map +1 -0
  141. package/dist/layers/selectionResolve.js +111 -0
  142. package/dist/layers/selectionResolve.js.map +1 -0
  143. package/dist/layers/useDataLayers.js +940 -0
  144. package/dist/layers/useDataLayers.js.map +1 -0
  145. package/dist/layers/useFeatureSelection.js +179 -0
  146. package/dist/layers/useFeatureSelection.js.map +1 -0
  147. package/dist/layers/useScrolls.js +37 -0
  148. package/dist/layers/useScrolls.js.map +1 -0
  149. package/dist/panels/BasemapPicker/BasemapPicker.js +169 -0
  150. package/dist/panels/BasemapPicker/BasemapPicker.js.map +1 -0
  151. package/dist/panels/BasemapPicker/BasemapPicker.styles.js +42 -0
  152. package/dist/panels/BasemapPicker/BasemapPicker.styles.js.map +1 -0
  153. package/dist/panels/ExportSection/ExportSection.js +91 -0
  154. package/dist/panels/ExportSection/ExportSection.js.map +1 -0
  155. package/dist/panels/HelpSection/HelpSection.js +163 -0
  156. package/dist/panels/HelpSection/HelpSection.js.map +1 -0
  157. package/dist/panels/HelpSection/HelpSection.styles.js +9 -0
  158. package/dist/panels/HelpSection/HelpSection.styles.js.map +1 -0
  159. package/dist/panels/PinSection/PinSection.js +39 -0
  160. package/dist/panels/PinSection/PinSection.js.map +1 -0
  161. package/dist/panels/Section/Section.js +43 -0
  162. package/dist/panels/Section/Section.js.map +1 -0
  163. package/dist/panels/Section/Section.styles.js +13 -0
  164. package/dist/panels/Section/Section.styles.js.map +1 -0
  165. package/dist/panels/SettingsSection/LanguageField.js +126 -0
  166. package/dist/panels/SettingsSection/LanguageField.js.map +1 -0
  167. package/dist/panels/SettingsSection/SettingsSection.js +175 -0
  168. package/dist/panels/SettingsSection/SettingsSection.js.map +1 -0
  169. package/dist/panels/SettingsSection/SettingsSection.styles.js +9 -0
  170. package/dist/panels/SettingsSection/SettingsSection.styles.js.map +1 -0
  171. package/dist/panels/ShapesSection/ShapesSection.js +229 -0
  172. package/dist/panels/ShapesSection/ShapesSection.js.map +1 -0
  173. package/dist/panels/ShapesSection/ShapesSection.styles.js +7 -0
  174. package/dist/panels/ShapesSection/ShapesSection.styles.js.map +1 -0
  175. package/dist/panels/SheetContent/SheetContent.js +92 -0
  176. package/dist/panels/SheetContent/SheetContent.js.map +1 -0
  177. package/dist/panels/SheetContent/SheetContent.styles.js +6 -0
  178. package/dist/panels/SheetContent/SheetContent.styles.js.map +1 -0
  179. package/dist/services/ServicesProvider.js +42 -0
  180. package/dist/services/ServicesProvider.js.map +1 -0
  181. package/dist/services/activeMessages.js +140 -0
  182. package/dist/services/activeMessages.js.map +1 -0
  183. package/dist/services/basemapAvailability.js +78 -0
  184. package/dist/services/basemapAvailability.js.map +1 -0
  185. package/dist/services/englishMessages.js +10 -0
  186. package/dist/services/englishMessages.js.map +1 -0
  187. package/dist/services/hooks.js +214 -0
  188. package/dist/services/hooks.js.map +1 -0
  189. package/dist/styles.css +2866 -0
  190. package/dist/styles.css.d.ts +1 -0
  191. package/dist/tools/Directions/Directions.styles.js +25 -0
  192. package/dist/tools/Directions/Directions.styles.js.map +1 -0
  193. package/dist/tools/Directions/DirectionsOverlay.js +46 -0
  194. package/dist/tools/Directions/DirectionsOverlay.js.map +1 -0
  195. package/dist/tools/Directions/DirectionsPanel.js +428 -0
  196. package/dist/tools/Directions/DirectionsPanel.js.map +1 -0
  197. package/dist/tools/Directions/MapDirections.js +84 -0
  198. package/dist/tools/Directions/MapDirections.js.map +1 -0
  199. package/dist/tools/Directions/useDirections.js +226 -0
  200. package/dist/tools/Directions/useDirections.js.map +1 -0
  201. package/dist/tools/Directions/useFreeCentre.js +30 -0
  202. package/dist/tools/Directions/useFreeCentre.js.map +1 -0
  203. package/dist/tools/DrawToolbar/DrawMapBindings.js +34 -0
  204. package/dist/tools/DrawToolbar/DrawMapBindings.js.map +1 -0
  205. package/dist/tools/DrawToolbar/DrawToolbar.js +296 -0
  206. package/dist/tools/DrawToolbar/DrawToolbar.js.map +1 -0
  207. package/dist/tools/DrawToolbar/DrawToolbar.styles.js +21 -0
  208. package/dist/tools/DrawToolbar/DrawToolbar.styles.js.map +1 -0
  209. package/dist/tools/DrawToolbar/imageDrawing.js +24 -0
  210. package/dist/tools/DrawToolbar/imageDrawing.js.map +1 -0
  211. package/dist/tools/DrawToolbar/useDraw.js +543 -0
  212. package/dist/tools/DrawToolbar/useDraw.js.map +1 -0
  213. package/dist/tools/MeasureToolbar/MeasureToolbar.js +116 -0
  214. package/dist/tools/MeasureToolbar/MeasureToolbar.js.map +1 -0
  215. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js +12 -0
  216. package/dist/tools/MeasureToolbar/MeasureToolbar.styles.js.map +1 -0
  217. package/dist/tools/MeasureToolbar/useMeasure.js +75 -0
  218. package/dist/tools/MeasureToolbar/useMeasure.js.map +1 -0
  219. package/dist/tools/PinCard/PinCard.js +174 -0
  220. package/dist/tools/PinCard/PinCard.js.map +1 -0
  221. package/dist/tools/PinCard/PinCard.styles.js +16 -0
  222. package/dist/tools/PinCard/PinCard.styles.js.map +1 -0
  223. package/dist/tools/PinCard/useReverseAddress.js +77 -0
  224. package/dist/tools/PinCard/useReverseAddress.js.map +1 -0
  225. package/dist/tools/SearchPill/SearchPill.js +292 -0
  226. package/dist/tools/SearchPill/SearchPill.js.map +1 -0
  227. package/dist/tools/SearchPill/SearchPill.styles.js +16 -0
  228. package/dist/tools/SearchPill/SearchPill.styles.js.map +1 -0
  229. package/dist/tools/SearchPill/SearchPillSkeleton.js +41 -0
  230. package/dist/tools/SearchPill/SearchPillSkeleton.js.map +1 -0
  231. package/dist/tools/SearchPill/useSearch.js +143 -0
  232. package/dist/tools/SearchPill/useSearch.js.map +1 -0
  233. package/dist/tools/SearchPill/useSuggestions.js +105 -0
  234. package/dist/tools/SearchPill/useSuggestions.js.map +1 -0
  235. package/dist/tools/Tour/TourCard.js +156 -0
  236. package/dist/tools/Tour/TourCard.js.map +1 -0
  237. package/dist/tools/Tour/TourCard.styles.js +10 -0
  238. package/dist/tools/Tour/TourCard.styles.js.map +1 -0
  239. package/dist/tools/Tour/useTour.js +110 -0
  240. package/dist/tools/Tour/useTour.js.map +1 -0
  241. package/dist/tools/locate/useLocate.js +94 -0
  242. package/dist/tools/locate/useLocate.js.map +1 -0
  243. package/dist/ui/Button/Button.js +36 -0
  244. package/dist/ui/Button/Button.js.map +1 -0
  245. package/dist/ui/Button/Button.styles.js +17 -0
  246. package/dist/ui/Button/Button.styles.js.map +1 -0
  247. package/dist/ui/Chip/Chip.js +37 -0
  248. package/dist/ui/Chip/Chip.js.map +1 -0
  249. package/dist/ui/Chip/Chip.styles.js +29 -0
  250. package/dist/ui/Chip/Chip.styles.js.map +1 -0
  251. package/dist/ui/ControlGroup/ControlGroup.js +23 -0
  252. package/dist/ui/ControlGroup/ControlGroup.js.map +1 -0
  253. package/dist/ui/ControlGroup/ControlGroup.styles.js +6 -0
  254. package/dist/ui/ControlGroup/ControlGroup.styles.js.map +1 -0
  255. package/dist/ui/EmptyState/EmptyState.js +37 -0
  256. package/dist/ui/EmptyState/EmptyState.js.map +1 -0
  257. package/dist/ui/EmptyState/EmptyState.styles.js +10 -0
  258. package/dist/ui/EmptyState/EmptyState.styles.js.map +1 -0
  259. package/dist/ui/Icon/Icon.js +28 -0
  260. package/dist/ui/Icon/Icon.js.map +1 -0
  261. package/dist/ui/Icon/Icon.styles.js +8 -0
  262. package/dist/ui/Icon/Icon.styles.js.map +1 -0
  263. package/dist/ui/IconButton/IconButton.js +47 -0
  264. package/dist/ui/IconButton/IconButton.js.map +1 -0
  265. package/dist/ui/IconButton/IconButton.styles.js +27 -0
  266. package/dist/ui/IconButton/IconButton.styles.js.map +1 -0
  267. package/dist/ui/Isolate/Isolate.js +26 -0
  268. package/dist/ui/Isolate/Isolate.js.map +1 -0
  269. package/dist/ui/Isolate/fillSlots.js +27 -0
  270. package/dist/ui/Isolate/fillSlots.js.map +1 -0
  271. package/dist/ui/ListRow/ListRow.js +59 -0
  272. package/dist/ui/ListRow/ListRow.js.map +1 -0
  273. package/dist/ui/ListRow/ListRow.styles.js +30 -0
  274. package/dist/ui/ListRow/ListRow.styles.js.map +1 -0
  275. package/dist/ui/LiveRegion/LiveRegion.js +88 -0
  276. package/dist/ui/LiveRegion/LiveRegion.js.map +1 -0
  277. package/dist/ui/LiveRegion/announcer.js +114 -0
  278. package/dist/ui/LiveRegion/announcer.js.map +1 -0
  279. package/dist/ui/SegmentedControl/SegmentedControl.js +55 -0
  280. package/dist/ui/SegmentedControl/SegmentedControl.js.map +1 -0
  281. package/dist/ui/SegmentedControl/SegmentedControl.styles.js +9 -0
  282. package/dist/ui/SegmentedControl/SegmentedControl.styles.js.map +1 -0
  283. package/dist/ui/SkipLink/SkipLink.js +35 -0
  284. package/dist/ui/SkipLink/SkipLink.js.map +1 -0
  285. package/dist/ui/SkipLink/SkipLink.styles.js +6 -0
  286. package/dist/ui/SkipLink/SkipLink.styles.js.map +1 -0
  287. package/dist/ui/Slider/Slider.js +68 -0
  288. package/dist/ui/Slider/Slider.js.map +1 -0
  289. package/dist/ui/Slider/Slider.styles.js +13 -0
  290. package/dist/ui/Slider/Slider.styles.js.map +1 -0
  291. package/dist/ui/StatusMessage/StatusMessage.js +124 -0
  292. package/dist/ui/StatusMessage/StatusMessage.js.map +1 -0
  293. package/dist/ui/StatusMessage/StatusMessage.styles.js +28 -0
  294. package/dist/ui/StatusMessage/StatusMessage.styles.js.map +1 -0
  295. package/dist/ui/StatusMessage/StatusMessageFocus.js +30 -0
  296. package/dist/ui/StatusMessage/StatusMessageFocus.js.map +1 -0
  297. package/dist/ui/Surface/Surface.js +22 -0
  298. package/dist/ui/Surface/Surface.js.map +1 -0
  299. package/dist/ui/Surface/Surface.styles.js +27 -0
  300. package/dist/ui/Surface/Surface.styles.js.map +1 -0
  301. package/dist/ui/Switch/Switch.js +58 -0
  302. package/dist/ui/Switch/Switch.js.map +1 -0
  303. package/dist/ui/Switch/Switch.styles.js +13 -0
  304. package/dist/ui/Switch/Switch.styles.js.map +1 -0
  305. package/dist/ui/Tooltip/Tooltip.js +66 -0
  306. package/dist/ui/Tooltip/Tooltip.js.map +1 -0
  307. package/dist/ui/Tooltip/Tooltip.styles.js +6 -0
  308. package/dist/ui/Tooltip/Tooltip.styles.js.map +1 -0
  309. package/dist/ui/Tooltip/inheritColours.js +27 -0
  310. package/dist/ui/Tooltip/inheritColours.js.map +1 -0
  311. package/dist/ui/VisuallyHidden/VisuallyHidden.js +16 -0
  312. package/dist/ui/VisuallyHidden/VisuallyHidden.js.map +1 -0
  313. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js +6 -0
  314. package/dist/ui/VisuallyHidden/VisuallyHidden.styles.js.map +1 -0
  315. package/package.json +82 -4
@@ -0,0 +1,488 @@
1
+ import { usePreferences } from "../../services/hooks.js";
2
+ import { ChromeLayoutProvider } from "../layoutContext.js";
3
+ import { ChromeSurfaceContext } from "./chromeSurface.js";
4
+ import { chromeVars } from "./chromeVars.js";
5
+ import { background, bottomCentre, bottomEnd, bottomStart, endStack, mapKey, root, topStart, tour } from "./MapChrome.styles.js";
6
+ import { applyMapKeyPlacement, isMapKeyCrowded, placeMapKey } from "./mapKeyPlacement.js";
7
+ import { sharesWidth } from "./sharesWidth.js";
8
+ import { chooseLayout, computeBottomSlotLayout, computeEndStackMaxHeight } from "@mapcairn/core";
9
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { useLatestRef } from "@mapcairn/react";
12
+ // src/chrome/MapChrome/MapChrome.tsx
13
+ /** What changes in the bottom-end slot that no change of size reports: the credits popover opening, moving or mounting. */
14
+ var POPOVER_CHANGES = {
15
+ subtree: true,
16
+ childList: true,
17
+ attributes: true,
18
+ attributeFilter: [
19
+ "hidden",
20
+ "data-placement",
21
+ "data-readout-clear"
22
+ ]
23
+ };
24
+ /** Layout box of a slot, ignoring transforms (which only lift or shift it). */
25
+ function box(slots, name) {
26
+ const element = slots.get(name);
27
+ return element ? {
28
+ top: element.offsetTop,
29
+ left: element.offsetLeft,
30
+ height: element.offsetHeight,
31
+ width: element.offsetWidth
32
+ } : null;
33
+ }
34
+ /**
35
+ * Where the bottom-start and bottom-centre slots will rest across the page,
36
+ * from their layout boxes and the sideways shift the side panel asks of the
37
+ * bottom-start slot (the bottom-centre slot takes half of it). The shift is a
38
+ * transform, so a layout box leaves it out; it is a distance along the
39
+ * reading direction, which a right-to-left page reverses.
40
+ */
41
+ function restingSpan(slot, shift, rtl) {
42
+ return {
43
+ left: slot.left + (rtl ? -shift : shift),
44
+ width: slot.width
45
+ };
46
+ }
47
+ /**
48
+ * How far the map key rises: with the readout where it does, and further
49
+ * where the key shares width with the bottom-centre slot and has to clear its
50
+ * top instead (the key's resting place is a gap above the bottom row's top).
51
+ */
52
+ function mapKeyRaiseAbove(centre, sharesCentre, startRaise, rowTop) {
53
+ if (!sharesCentre || centre === null || centre.height === 0) return startRaise;
54
+ return Math.min(startRaise, centre.top - rowTop);
55
+ }
56
+ /**
57
+ * How much further the open credits popover must rise to clear the
58
+ * bottom-centre slot, from where `transform` has put it (`popoverRiseNow`
59
+ * reads that). The popover is read from its own box, so a placement beside the
60
+ * end stack, which moves it sideways, is counted.
61
+ */
62
+ function popoverRiseOverCentre(root, slots, centreSpan, raises) {
63
+ const popover = root.querySelector("[data-chrome=\"attribution-popover\"]:not([hidden])");
64
+ const tops = {
65
+ start: slots.start && slots.start.height > 0 ? slots.start.top : null,
66
+ end: slots.end && slots.end.height > 0 ? slots.end.top : null,
67
+ centre: slots.centre && slots.centre.height > 0 ? slots.centre.top : null
68
+ };
69
+ if (!popover || tops.end === null || tops.centre === null) return 0;
70
+ if (centreSpan === null) return 0;
71
+ const rootBox = root.getBoundingClientRect();
72
+ const popoverBox = popover.getBoundingClientRect();
73
+ const popoverSpan = {
74
+ left: popoverBox.left - rootBox.left,
75
+ width: popoverBox.width
76
+ };
77
+ if (!sharesWidth(centreSpan, popoverSpan, 12)) return 0;
78
+ const rowRise = popover.dataset.readoutClear === "true" || tops.start === null ? 0 : Math.max(0, tops.end + raises.end - (tops.start + raises.start));
79
+ return Math.max(0, tops.end + raises.end - tops.centre - rowRise);
80
+ }
81
+ function measure(root, slots, startShiftX) {
82
+ const { width, height } = root.getBoundingClientRect();
83
+ const topStart = box(slots, "top-start");
84
+ const endStack = box(slots, "end-stack");
85
+ const bottomStart = box(slots, "bottom-start");
86
+ const bottomEnd = box(slots, "bottom-end");
87
+ const bottomCentre = box(slots, "bottom-centre");
88
+ const tour = box(slots, "tour");
89
+ const mapKey = box(slots, "map-key");
90
+ const restingBottom = height - 12;
91
+ const shown = [bottomStart, bottomEnd].filter((slot) => slot !== null && slot.height > 0);
92
+ const rowBottom = shown.length > 0 ? Math.max(...shown.map((slot) => slot.top + slot.height)) : restingBottom;
93
+ const bottomInset = Math.max(0, height - rowBottom);
94
+ const rowTop = shown.length > 0 ? Math.min(...shown.map((slot) => slot.top)) : rowBottom;
95
+ const rtl = getComputedStyle(root).direction === "rtl";
96
+ const centreSpan = bottomCentre && bottomCentre.height > 0 ? restingSpan(bottomCentre, startShiftX / 2, rtl) : null;
97
+ const sharesWithCentre = (slot, shift) => centreSpan !== null && slot !== null && slot.height > 0 && sharesWidth(centreSpan, restingSpan(slot, shift, rtl), 12);
98
+ const centreSharesStart = sharesWithCentre(bottomStart, startShiftX);
99
+ const centreSharesEnd = sharesWithCentre(bottomEnd, 0);
100
+ const centreSharesKey = sharesWithCentre(mapKey, startShiftX);
101
+ const centreSharesTour = sharesWithCentre(tour, 0);
102
+ const raise = bottomCentre ? -(bottomCentre.height + bottomInset) : 0;
103
+ return {
104
+ width,
105
+ height,
106
+ topStartBottom: topStart ? topStart.top + topStart.height : 12,
107
+ endStackTop: endStack?.top ?? 12,
108
+ endStackBottom: endStack ? endStack.top + endStack.height : 12,
109
+ endStackWidth: endStack?.width ?? 0,
110
+ bottomRowTop: rowTop,
111
+ bottomStartTop: bottomStart && bottomStart.height > 0 ? bottomStart.top : null,
112
+ bottomEndTop: bottomEnd && bottomEnd.height > 0 ? bottomEnd.top : null,
113
+ bottomInset,
114
+ bottomCentreTop: bottomCentre && bottomCentre.height > 0 ? bottomCentre.top : null,
115
+ centreSharesStart,
116
+ centreSharesEnd,
117
+ centreSharesKey,
118
+ centreSharesTour,
119
+ mapKeyRaise: mapKeyRaiseAbove(bottomCentre, centreSharesKey, centreSharesStart ? raise : 0, rowTop),
120
+ bottomStartRaise: centreSharesStart ? raise : 0,
121
+ bottomEndRaise: centreSharesEnd ? raise : 0,
122
+ popoverCentreRise: popoverRiseOverCentre(root, {
123
+ start: bottomStart,
124
+ end: bottomEnd,
125
+ centre: bottomCentre
126
+ }, centreSpan, {
127
+ start: centreSharesStart ? raise : 0,
128
+ end: centreSharesEnd ? raise : 0
129
+ }),
130
+ tourBottom: tour && tour.height > 0 ? tour.top + tour.height : null,
131
+ mapKeyBottom: mapKey && mapKey.height > 0 ? mapKey.top + mapKey.height : null,
132
+ mapKeyHeight: mapKey?.height ?? 0
133
+ };
134
+ }
135
+ /**
136
+ * The top of the bottom row once each slot has been lifted by its own lift:
137
+ * the highest of the slots that show.
138
+ */
139
+ function liftedRowTop(m, lifts) {
140
+ const tops = [m.bottomStartTop === null ? null : m.bottomStartTop + lifts.start, m.bottomEndTop === null ? null : m.bottomEndTop + lifts.end].filter((top) => top !== null);
141
+ return tops.length > 0 ? Math.min(...tops) : m.bottomRowTop + Math.min(lifts.start, lifts.end);
142
+ }
143
+ /**
144
+ * Whether the tour card has to give way: the bottom row (lifted above the
145
+ * sheet or a toolbar) comes up to it, or a bottom-centre slot it shares width
146
+ * with does.
147
+ */
148
+ function isTourCrowded(m, lifts, centreTop) {
149
+ if (m === null || m.tourBottom === null) return false;
150
+ const centreEdge = m.centreSharesTour && centreTop !== null ? centreTop : Number.POSITIVE_INFINITY;
151
+ return m.tourBottom + 12 > Math.min(liftedRowTop(m, lifts), centreEdge);
152
+ }
153
+ /**
154
+ * How far the map key is lifted for the key's placement: with the bottom-start
155
+ * slot, and further where the key, which can be wider than the readout,
156
+ * shares width with the bottom-centre slot and has to clear its top.
157
+ */
158
+ function mapKeyLiftAbove(m, lifts, centreTop) {
159
+ return m?.centreSharesKey && centreTop !== null ? Math.min(lifts.start, centreTop - m.bottomRowTop) : lifts.start;
160
+ }
161
+ /**
162
+ * Vertical room between the end stack and the bottom row, once each bottom
163
+ * slot has been lifted. The end stack stops a gap above that row, and the
164
+ * credits popover, which grows up from bottom-end and rises over the whole row
165
+ * (`bottomEndRise` is how much higher than the bottom-end slot the row is),
166
+ * stops a gap below the end stack. Placed beside the end stack instead, the
167
+ * popover may rise to a gap below the top-start slot.
168
+ */
169
+ function verticalRoom(m, lifts) {
170
+ const rowTop = liftedRowTop(m, lifts);
171
+ return {
172
+ endStackMaxHeight: computeEndStackMaxHeight({
173
+ viewportHeight: m.height,
174
+ topOffset: m.endStackTop,
175
+ bottomReserved: m.height - rowTop + 12 - 12,
176
+ inset: 12
177
+ }),
178
+ bottomEndRise: m.bottomStartTop === null || m.bottomEndTop === null ? 0 : Math.max(0, m.bottomEndTop + lifts.end - (m.bottomStartTop + lifts.start)),
179
+ bottomEndRoom: Math.max(0, rowTop - 12 - m.endStackBottom),
180
+ bottomEndBesideRoom: Math.max(0, rowTop - 12 - m.topStartBottom)
181
+ };
182
+ }
183
+ function sameMeasurements(a, b) {
184
+ return a !== null && Object.keys(b).every((key) => a[key] === b[key]);
185
+ }
186
+ /** How far a fitted feature must stay above the visible key at the bottom. */
187
+ function clearanceAboveMapKey(measurements, crowded, placement) {
188
+ if (!measurements || measurements.mapKeyBottom === null || placement === null || crowded) return null;
189
+ const top = measurements.mapKeyBottom - measurements.mapKeyHeight + placement.shift;
190
+ return measurements.height - top;
191
+ }
192
+ /** Places the key from a complete measurement, when one exists. */
193
+ function mapKeyPlacementAt(measurements, lift, tourBottom) {
194
+ return measurements ? placeMapKey(measurements, lift, tourBottom) : null;
195
+ }
196
+ /** The tour edge that competes with the key, when the tour is shown. */
197
+ function keyTourBottom(hidden, measurements) {
198
+ return hidden ? null : measurements?.tourBottom ?? null;
199
+ }
200
+ /**
201
+ * The one owner of everything floating over the map. It draws the map
202
+ * full-bleed inside `main`, lays the slots out with flow layout, and keeps
203
+ * the bottom slots clear of the sheet, the side panel and the measure
204
+ * toolbar.
205
+ *
206
+ * @remarks
207
+ * - DOM order is reading order: top-start, tour, end-stack, the sheet, the map
208
+ * (`main`), the map key, then bottom-start, bottom-centre and bottom-end.
209
+ * The app renders the skip link before this component and the page's h1
210
+ * itself.
211
+ * - While `modal`, every group except the sheet gets `inert`. That is one
212
+ * inert attribute per group rather than one wrapper, because the sheet sits
213
+ * between the groups in reading order.
214
+ * - The container ignores the pointer; each slot takes it back, so the map
215
+ * stays draggable in every gap. Every slot wrapper has `data-chrome` with
216
+ * its slot name; the sheet carries its own `data-chrome="sheet"`.
217
+ * - A `ResizeObserver` measures the container (which already reflects the
218
+ * visual viewport) and the slots. From that it chooses the layout, gives
219
+ * `ChromeLayoutProvider` the viewport and the pointer preference, and sets
220
+ * the {@link chromeVars} on the root with CSSOM: never a `style` attribute,
221
+ * because production CSP is `style-src 'self'`.
222
+ * - The sheet publishes its top edge (`publishSheetTop`) and detent, and the
223
+ * side panel its right edge. Whatever is shown in bottom-centre, a toolbar
224
+ * first, is an obstruction too, measured from its slot.
225
+ * `computeBottomSlotLayout` turns these into the lift and shift of the
226
+ * bottom slots, which hide at the full detent.
227
+ * - The bottom row rides above the sheet with a `transform`, which slides, and
228
+ * above the bottom-centre slot with the separate `translate` property
229
+ * (`bottomStartRaise`, `bottomEndRaise` and `mapKeyRaise`, each zero for a slot
230
+ * that shares no width with the bottom-centre slot), which does not, and which
231
+ * the measuring observer sets in
232
+ * its own callback. A toolbar that changes height therefore never has the
233
+ * row over it, in any frame, with motion or without.
234
+ * - Before the first measurement (and in server rendering) the layout is the
235
+ * bottom sheet, the narrow-screen default.
236
+ */
237
+ function MapChrome({ background: background$1, topStart: topStart$1, endStack: endStack$1, bottomStart: bottomStart$1, bottomEnd: bottomEnd$1, bottomCentre: bottomCentre$1, tour: tour$1, tourSide = "start", mapKey: mapKey$1, sheet, modal, onViewportChange }) {
238
+ const rootRef = useRef(null);
239
+ const slots = useRef(/* @__PURE__ */ new Map());
240
+ const { finePointer } = usePreferences();
241
+ const [measurements, setMeasurements] = useState(null);
242
+ const [sheetTop, publishSheetTop] = useState(null);
243
+ const [sheetDetent, publishSheetDetent] = useState(null);
244
+ const [panelEdge, publishPanelEdge] = useState(null);
245
+ const mapKeyTourBottomRef = useRef(null);
246
+ const startShiftXRef = useRef(0);
247
+ const observerRef = useRef(null);
248
+ const popoverChangesRef = useRef(null);
249
+ const update = useCallback(() => {
250
+ const root = rootRef.current;
251
+ if (!root || !observerRef.current) return;
252
+ const next = measure(root, slots.current, startShiftXRef.current);
253
+ if (next.width === 0 && next.height === 0) return;
254
+ root.style.setProperty(chromeVars.bottomStartRaise, `${next.bottomStartRaise}px`);
255
+ root.style.setProperty(chromeVars.bottomEndRaise, `${next.bottomEndRaise}px`);
256
+ root.style.setProperty(chromeVars.mapKeyRaise, `${next.mapKeyRaise}px`);
257
+ root.style.setProperty(chromeVars.popoverCentreRise, `${next.popoverCentreRise}px`);
258
+ const popover = root.querySelector("[data-chrome=\"attribution-popover\"]");
259
+ if (popover) observerRef.current.observe(popover);
260
+ applyMapKeyPlacement(root, placeMapKey(next, 0, mapKeyTourBottomRef.current));
261
+ setMeasurements((current) => sameMeasurements(current, next) ? current : next);
262
+ }, []);
263
+ const slotRefs = useMemo(() => {
264
+ const make = (name) => (element) => {
265
+ const previous = slots.current.get(name);
266
+ if (element) {
267
+ slots.current.set(name, element);
268
+ observerRef.current?.observe(element);
269
+ if (name === "bottom-end") popoverChangesRef.current?.observe(element, POPOVER_CHANGES);
270
+ return;
271
+ }
272
+ if (previous) observerRef.current?.unobserve(previous);
273
+ slots.current.delete(name);
274
+ update();
275
+ };
276
+ return {
277
+ "top-start": make("top-start"),
278
+ tour: make("tour"),
279
+ "map-key": make("map-key"),
280
+ "end-stack": make("end-stack"),
281
+ "bottom-start": make("bottom-start"),
282
+ "bottom-centre": make("bottom-centre"),
283
+ "bottom-end": make("bottom-end")
284
+ };
285
+ }, [update]);
286
+ useLayoutEffect(() => {
287
+ const root = rootRef.current;
288
+ if (!root || typeof ResizeObserver === "undefined") return;
289
+ const observer = new ResizeObserver(update);
290
+ observerRef.current = observer;
291
+ observer.observe(root);
292
+ for (const element of slots.current.values()) observer.observe(element);
293
+ const popoverChanges = new MutationObserver(() => {
294
+ update();
295
+ });
296
+ popoverChangesRef.current = popoverChanges;
297
+ const endSlot = slots.current.get("bottom-end");
298
+ if (endSlot) popoverChanges.observe(endSlot, POPOVER_CHANGES);
299
+ return () => {
300
+ observer.disconnect();
301
+ popoverChanges.disconnect();
302
+ popoverChangesRef.current = null;
303
+ observerRef.current = null;
304
+ };
305
+ }, [update]);
306
+ const width = measurements?.width ?? 0;
307
+ const height = measurements?.height ?? 0;
308
+ const viewport = useMemo(() => ({
309
+ width,
310
+ height
311
+ }), [width, height]);
312
+ const layout = measurements ? chooseLayout(viewport) : "sheet";
313
+ useLayoutEffect(() => {
314
+ update();
315
+ }, [layout, update]);
316
+ const presence = [
317
+ topStart$1,
318
+ tour$1,
319
+ mapKey$1,
320
+ endStack$1,
321
+ bottomStart$1,
322
+ bottomCentre$1,
323
+ bottomEnd$1
324
+ ].map((content) => content == null ? "-" : "+").join("");
325
+ const measuredPresence = useRef(presence);
326
+ useLayoutEffect(() => {
327
+ if (measuredPresence.current !== presence) {
328
+ measuredPresence.current = presence;
329
+ update();
330
+ }
331
+ }, [presence, update]);
332
+ const onViewportChangeRef = useLatestRef(onViewportChange);
333
+ useEffect(() => {
334
+ if (measurements) onViewportChangeRef.current?.(viewport);
335
+ }, [
336
+ viewport,
337
+ measurements,
338
+ onViewportChangeRef
339
+ ]);
340
+ const inset = measurements?.bottomInset ?? 12;
341
+ const sheetOnly = computeBottomSlotLayout({
342
+ layout,
343
+ viewportWidth: width,
344
+ viewportHeight: height,
345
+ sheetTopEdge: sheetTop,
346
+ sheetDetent,
347
+ panelRightEdge: panelEdge,
348
+ measureToolbarTop: null,
349
+ inset
350
+ });
351
+ const centreTop = measurements?.bottomCentreTop == null ? null : measurements.bottomCentreTop + sheetOnly.bottomStartTranslateY;
352
+ const bottomAbove = (sharesWidthWithCentre) => computeBottomSlotLayout({
353
+ layout,
354
+ viewportWidth: width,
355
+ viewportHeight: height,
356
+ sheetTopEdge: sheetTop,
357
+ sheetDetent,
358
+ panelRightEdge: panelEdge,
359
+ measureToolbarTop: sharesWidthWithCentre ? centreTop : null,
360
+ inset
361
+ });
362
+ const startLayout = bottomAbove(measurements?.centreSharesStart);
363
+ const endLayout = bottomAbove(measurements?.centreSharesEnd);
364
+ const lifts = {
365
+ start: startLayout.bottomStartTranslateY,
366
+ end: endLayout.bottomEndTranslateY
367
+ };
368
+ const keyLift = mapKeyLiftAbove(measurements, lifts, centreTop);
369
+ const room = measurements ? verticalRoom(measurements, lifts) : null;
370
+ const tourCrowded = isTourCrowded(measurements, lifts, centreTop);
371
+ const tourHidden = modal || tourCrowded;
372
+ const keyTourEdge = keyTourBottom(tourHidden, measurements);
373
+ useLayoutEffect(() => {
374
+ if (mapKeyTourBottomRef.current === keyTourEdge) return;
375
+ mapKeyTourBottomRef.current = keyTourEdge;
376
+ update();
377
+ }, [keyTourEdge, update]);
378
+ const mapKeyLivePlacement = mapKeyPlacementAt(measurements, keyLift, keyTourEdge);
379
+ const mapKeyCrowded = isMapKeyCrowded(mapKeyLivePlacement);
380
+ const mapKeyClearance = clearanceAboveMapKey(measurements, mapKeyCrowded, mapKeyLivePlacement);
381
+ const endStackMaxHeight = room?.endStackMaxHeight ?? null;
382
+ const bottomEndRise = room?.bottomEndRise ?? null;
383
+ const bottomEndRoom = room?.bottomEndRoom ?? null;
384
+ const bottomEndBesideRoom = room?.bottomEndBesideRoom ?? null;
385
+ useLayoutEffect(() => {
386
+ const root = rootRef.current;
387
+ if (!root || !measurements || endStackMaxHeight === null || bottomEndRise === null || bottomEndRoom === null || bottomEndBesideRoom === null) return;
388
+ const set = (name, px) => {
389
+ root.style.setProperty(name, `${px}px`);
390
+ };
391
+ set(chromeVars.width, measurements.width);
392
+ set(chromeVars.topStartBottom, measurements.topStartBottom);
393
+ set(chromeVars.endStackMaxHeight, endStackMaxHeight);
394
+ set(chromeVars.endStackWidth, measurements.endStackWidth);
395
+ set(chromeVars.bottomEndRise, bottomEndRise);
396
+ set(chromeVars.bottomEndRoom, bottomEndRoom);
397
+ set(chromeVars.bottomEndBesideRoom, bottomEndBesideRoom);
398
+ set(chromeVars.bottomLift, sheetOnly.bottomStartTranslateY);
399
+ set(chromeVars.bottomStartX, startLayout.bottomStartTranslateX);
400
+ if (startShiftXRef.current !== startLayout.bottomStartTranslateX) {
401
+ startShiftXRef.current = startLayout.bottomStartTranslateX;
402
+ update();
403
+ }
404
+ }, [
405
+ measurements,
406
+ endStackMaxHeight,
407
+ bottomEndRise,
408
+ bottomEndRoom,
409
+ bottomEndBesideRoom,
410
+ startLayout.bottomStartTranslateX,
411
+ sheetOnly.bottomStartTranslateY,
412
+ update
413
+ ]);
414
+ const layoutValue = useMemo(() => ({
415
+ layout,
416
+ viewport,
417
+ finePointer,
418
+ panelEdge,
419
+ mapKeyClearance,
420
+ publishSheetTop
421
+ }), [
422
+ layout,
423
+ viewport,
424
+ finePointer,
425
+ panelEdge,
426
+ mapKeyClearance
427
+ ]);
428
+ const surfaceValue = useMemo(() => ({
429
+ publishSheetDetent,
430
+ publishPanelEdge,
431
+ endStackMaxHeight,
432
+ tourHidden
433
+ }), [endStackMaxHeight, tourHidden]);
434
+ const slot = (name, className, content) => content == null ? null : /* @__PURE__ */ jsx("div", {
435
+ ref: slotRefs[name],
436
+ "data-chrome": name,
437
+ className,
438
+ inert: modal,
439
+ children: content
440
+ });
441
+ return /* @__PURE__ */ jsx(ChromeLayoutProvider, {
442
+ value: layoutValue,
443
+ children: /* @__PURE__ */ jsx(ChromeSurfaceContext.Provider, {
444
+ value: surfaceValue,
445
+ children: /* @__PURE__ */ jsxs("div", {
446
+ ref: rootRef,
447
+ "data-chrome-root": "",
448
+ "data-testid": "map-chrome",
449
+ "data-layout": layout,
450
+ "data-hide-bottom": startLayout.hideBottomSlots ? "true" : "false",
451
+ className: root,
452
+ children: [
453
+ slot("top-start", topStart, topStart$1),
454
+ tour$1 == null ? null : /* @__PURE__ */ jsx("div", {
455
+ ref: slotRefs.tour,
456
+ "data-chrome": "tour",
457
+ "data-side": tourSide,
458
+ "data-crowded": tourCrowded ? "true" : "false",
459
+ className: tour,
460
+ inert: tourHidden,
461
+ children: tour$1
462
+ }),
463
+ slot("end-stack", endStack, endStack$1),
464
+ sheet,
465
+ /* @__PURE__ */ jsx("main", {
466
+ className: background,
467
+ inert: modal,
468
+ children: background$1
469
+ }),
470
+ mapKey$1 == null ? null : /* @__PURE__ */ jsx("div", {
471
+ ref: slotRefs["map-key"],
472
+ "data-chrome": "map-key",
473
+ "data-crowded": mapKeyCrowded ? "true" : "false",
474
+ className: mapKey,
475
+ inert: modal || mapKeyCrowded,
476
+ children: mapKey$1
477
+ }),
478
+ slot("bottom-start", bottomStart, bottomStart$1),
479
+ slot("bottom-centre", bottomCentre, bottomCentre$1),
480
+ slot("bottom-end", bottomEnd, bottomEnd$1)
481
+ ]
482
+ })
483
+ })
484
+ });
485
+ }
486
+ export { MapChrome };
487
+
488
+ //# sourceMappingURL=MapChrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapChrome.js","names":["topStart","tour","mapKey","endStack","bottomStart","bottomCentre","bottomEnd","styles.root","styles.topStart","styles.tour","styles.endStack","styles.background","background","styles.mapKey","styles.bottomStart","styles.bottomCentre","styles.bottomEnd"],"sources":["../../../src/chrome/MapChrome/MapChrome.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport {\n type ChromeLayout,\n chooseLayout,\n computeBottomSlotLayout,\n computeEndStackMaxHeight,\n type SheetDetent,\n} from \"@mapcairn/core\";\nimport { useLatestRef } from \"@mapcairn/react\";\nimport {\n type ReactNode,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { usePreferences } from \"../../services\";\nimport { CHROME_GAP_PX, CHROME_INSET_PX } from \"../chromeSpacing\";\nimport { ChromeLayoutProvider, type ChromeLayoutValue } from \"../layoutContext\";\nimport { ChromeSurfaceContext, type ChromeSurfaceValue } from \"./chromeSurface\";\nimport { chromeVars } from \"./chromeVars\";\nimport * as styles from \"./MapChrome.css\";\nimport {\n applyMapKeyPlacement,\n isMapKeyCrowded,\n placeMapKey,\n} from \"./mapKeyPlacement\";\nimport { type Span, sharesWidth } from \"./sharesWidth\";\n\n/** Props for {@link MapChrome}. */\nexport interface MapChromeProps {\n /** The map, drawn full-bleed behind everything inside the `main` landmark. */\n readonly background: ReactNode;\n /** Search pill. */\n readonly topStart?: ReactNode;\n /** Compass, main control group and zoom group (`EndStack`). */\n readonly endStack?: ReactNode;\n /** Scale bar, cursor coordinates and zoom level (`MapReadout`). */\n readonly bottomStart?: ReactNode;\n /** Attribution. */\n readonly bottomEnd?: ReactNode;\n /** Measure toolbar, toasts and the tile-error banner. */\n readonly bottomCentre?: ReactNode;\n /**\n * The first-visit tour card. It sits in the free space at the top of the\n * map: under the search pill on a narrow screen, and between the search\n * column and the end stack in the panel layout. It hides, like the bottom\n * slots, while the sheet is at full, and while the bottom row, lifted above\n * the sheet or a toolbar, would run into it.\n */\n readonly tour?: ReactNode;\n /**\n * In the panel layout, whether the tour card sits against the search\n * column and panel (`\"start\"`, the default) or against the end stack.\n */\n readonly tourSide?: \"start\" | \"end\";\n /**\n * The key to the layers that are on (`MapKey`). It sits above the scale\n * bar, rides above the sheet or beside the side panel with it, is as tall\n * as the room under the search pill allows, and hides when there is no room\n * for its chip, while the credits are open, and at the full detent. A\n * prop named `key` would be React's own, so it is `mapKey`.\n */\n readonly mapKey?: ReactNode;\n /**\n * The `Sheet` (bottom sheet or side panel). Rendered outside every inert\n * group, so it stays operable while the rest of the chrome is inert.\n */\n readonly sheet?: ReactNode;\n /** True while the sheet is modal: everything but the sheet becomes `inert`. */\n readonly modal: boolean;\n /** Called when the measured container size changes. */\n readonly onViewportChange?: (viewport: {\n readonly width: number;\n readonly height: number;\n }) => void;\n}\n\n/** What changes in the bottom-end slot that no change of size reports: the credits popover opening, moving or mounting. */\nconst POPOVER_CHANGES: MutationObserverInit = {\n subtree: true,\n childList: true,\n attributes: true,\n attributeFilter: [\"hidden\", \"data-placement\", \"data-readout-clear\"],\n};\n\n/** Layout boxes read from the slots, in px from the container's top edge. */\ninterface Measurements {\n readonly width: number;\n readonly height: number;\n readonly topStartBottom: number;\n readonly endStackTop: number;\n readonly endStackBottom: number;\n readonly endStackWidth: number;\n /** Top of the bottom row (bottom-start and bottom-end) before any lift. */\n readonly bottomRowTop: number;\n /** Top of the bottom-start slot before any lift, or null while it is empty. */\n readonly bottomStartTop: number | null;\n /** Top of the bottom-end slot before any lift, or null while it is empty. */\n readonly bottomEndTop: number | null;\n /** Gap between the bottom row and the container's bottom edge (inset plus safe area). */\n readonly bottomInset: number;\n /** Top of the bottom-centre slot before any lift, or null while it is empty. */\n readonly bottomCentreTop: number | null;\n /**\n * Whether the bottom-centre slot shares width with the bottom-start slot\n * (as that slot will rest, once any side panel has moved it), so the slot\n * would cover it.\n */\n readonly centreSharesStart: boolean;\n /** Whether the bottom-centre slot shares width with the bottom-end slot. */\n readonly centreSharesEnd: boolean;\n /** Whether the bottom-centre slot shares width with the tour card's slot. */\n readonly centreSharesTour: boolean;\n /** Whether the bottom-centre slot shares width with the map key's slot. */\n readonly centreSharesKey: boolean;\n /**\n * How far the map key must rise to clear the bottom-centre slot: at least\n * the bottom-start slot's rise, and further where the key (wider than the\n * readout) shares width with the slot and the readout does not. Zero or\n * negative.\n */\n readonly mapKeyRaise: number;\n /**\n * How far the bottom-start slot must rise to clear the bottom-centre slot,\n * from the slot's own height: zero or negative, and zero while it is empty\n * or shares no width with the bottom-start slot.\n */\n readonly bottomStartRaise: number;\n /** The same for the bottom-end slot. */\n readonly bottomEndRaise: number;\n /**\n * How much further the open credits popover must rise, over the rise its\n * `transform` gives it, to clear the bottom-centre slot when it shares width\n * with that slot (the popover is wider than its button, so it can where the\n * button does not). Zero or positive, and zero while the popover is closed.\n */\n readonly popoverCentreRise: number;\n /** Bottom edge of the tour card's slot, or null while it is empty. */\n readonly tourBottom: number | null;\n /** Bottom edge of the map key's slot before any lift, or null while it is empty. */\n readonly mapKeyBottom: number | null;\n /** Height of the map key's slot as laid out, within its room cap. */\n readonly mapKeyHeight: number;\n}\n\ntype SlotName =\n | \"top-start\"\n | \"tour\"\n | \"map-key\"\n | \"end-stack\"\n | \"bottom-start\"\n | \"bottom-centre\"\n | \"bottom-end\";\n\n/** The layout box of a slot, as {@link box} reads it. */\ntype SlotBox = NonNullable<ReturnType<typeof box>>;\n\n/** Layout box of a slot, ignoring transforms (which only lift or shift it). */\nfunction box(slots: Map<SlotName, HTMLElement>, name: SlotName) {\n const element = slots.get(name);\n return element\n ? {\n top: element.offsetTop,\n left: element.offsetLeft,\n height: element.offsetHeight,\n width: element.offsetWidth,\n }\n : null;\n}\n\n/**\n * Where the bottom-start and bottom-centre slots will rest across the page,\n * from their layout boxes and the sideways shift the side panel asks of the\n * bottom-start slot (the bottom-centre slot takes half of it). The shift is a\n * transform, so a layout box leaves it out; it is a distance along the\n * reading direction, which a right-to-left page reverses.\n */\nfunction restingSpan(\n slot: { readonly left: number; readonly width: number },\n shift: number,\n rtl: boolean,\n): Span {\n return { left: slot.left + (rtl ? -shift : shift), width: slot.width };\n}\n\n/**\n * How far the map key rises: with the readout where it does, and further\n * where the key shares width with the bottom-centre slot and has to clear its\n * top instead (the key's resting place is a gap above the bottom row's top).\n */\nfunction mapKeyRaiseAbove(\n centre: { readonly top: number; readonly height: number } | null,\n sharesCentre: boolean,\n startRaise: number,\n rowTop: number,\n): number {\n if (!sharesCentre || centre === null || centre.height === 0) {\n return startRaise;\n }\n return Math.min(startRaise, centre.top - rowTop);\n}\n\n/**\n * How much further the open credits popover must rise to clear the\n * bottom-centre slot, from where `transform` has put it (`popoverRiseNow`\n * reads that). The popover is read from its own box, so a placement beside the\n * end stack, which moves it sideways, is counted.\n */\nfunction popoverRiseOverCentre(\n root: HTMLElement,\n slots: {\n readonly start: SlotBox | null;\n readonly end: SlotBox | null;\n readonly centre: SlotBox | null;\n },\n centreSpan: Span | null,\n raises: { readonly start: number; readonly end: number },\n): number {\n // MapChrome reads the credits popover through its `data-chrome` hook and its\n // `data-readout-clear` state, which is a coupling with `Attribution`: the\n // popover is the one floating element wider than its slot's box.\n const popover = root.querySelector<HTMLElement>(\n '[data-chrome=\"attribution-popover\"]:not([hidden])',\n );\n const tops = {\n start: slots.start && slots.start.height > 0 ? slots.start.top : null,\n end: slots.end && slots.end.height > 0 ? slots.end.top : null,\n centre: slots.centre && slots.centre.height > 0 ? slots.centre.top : null,\n };\n if (!popover || tops.end === null || tops.centre === null) {\n return 0;\n }\n if (centreSpan === null) {\n return 0;\n }\n const rootBox = root.getBoundingClientRect();\n const popoverBox = popover.getBoundingClientRect();\n const popoverSpan = {\n left: popoverBox.left - rootBox.left,\n width: popoverBox.width,\n };\n if (!sharesWidth(centreSpan, popoverSpan, CHROME_GAP_PX)) {\n return 0;\n }\n // The rise its `transform` already gives it over a taller readout, from this\n // measurement (the same as `bottomEndRise` in `verticalRoom`).\n const rowRise =\n popover.dataset.readoutClear === \"true\" || tops.start === null\n ? 0\n : Math.max(0, tops.end + raises.end - (tops.start + raises.start));\n return Math.max(0, tops.end + raises.end - tops.centre - rowRise);\n}\n\nfunction measure(\n root: HTMLElement,\n slots: Map<SlotName, HTMLElement>,\n startShiftX: number,\n): Measurements {\n const { width, height } = root.getBoundingClientRect();\n const topStart = box(slots, \"top-start\");\n const endStack = box(slots, \"end-stack\");\n const bottomStart = box(slots, \"bottom-start\");\n const bottomEnd = box(slots, \"bottom-end\");\n const bottomCentre = box(slots, \"bottom-centre\");\n const tour = box(slots, \"tour\");\n const mapKey = box(slots, \"map-key\");\n const restingBottom = height - CHROME_INSET_PX;\n const shown = [bottomStart, bottomEnd].filter(\n (slot): slot is NonNullable<typeof slot> =>\n slot !== null && slot.height > 0,\n );\n const rowBottom =\n shown.length > 0\n ? Math.max(...shown.map((slot) => slot.top + slot.height))\n : restingBottom;\n const bottomInset = Math.max(0, height - rowBottom);\n const rowTop =\n shown.length > 0 ? Math.min(...shown.map((slot) => slot.top)) : rowBottom;\n const rtl = getComputedStyle(root).direction === \"rtl\";\n const centreSpan =\n bottomCentre && bottomCentre.height > 0\n ? restingSpan(bottomCentre, startShiftX / 2, rtl)\n : null;\n const sharesWithCentre = (slot: typeof bottomStart, shift: number) =>\n centreSpan !== null &&\n slot !== null &&\n slot.height > 0 &&\n sharesWidth(centreSpan, restingSpan(slot, shift, rtl), CHROME_GAP_PX);\n const centreSharesStart = sharesWithCentre(bottomStart, startShiftX);\n const centreSharesEnd = sharesWithCentre(bottomEnd, 0);\n const centreSharesKey = sharesWithCentre(mapKey, startShiftX);\n const centreSharesTour = sharesWithCentre(tour, 0);\n const raise = bottomCentre ? -(bottomCentre.height + bottomInset) : 0;\n return {\n width,\n height,\n topStartBottom: topStart ? topStart.top + topStart.height : CHROME_INSET_PX,\n endStackTop: endStack?.top ?? CHROME_INSET_PX,\n endStackBottom: endStack ? endStack.top + endStack.height : CHROME_INSET_PX,\n endStackWidth: endStack?.width ?? 0,\n bottomRowTop: rowTop,\n bottomStartTop:\n bottomStart && bottomStart.height > 0 ? bottomStart.top : null,\n bottomEndTop: bottomEnd && bottomEnd.height > 0 ? bottomEnd.top : null,\n bottomInset,\n bottomCentreTop:\n bottomCentre && bottomCentre.height > 0 ? bottomCentre.top : null,\n centreSharesStart,\n centreSharesEnd,\n centreSharesKey,\n centreSharesTour,\n mapKeyRaise: mapKeyRaiseAbove(\n bottomCentre,\n centreSharesKey,\n centreSharesStart ? raise : 0,\n rowTop,\n ),\n bottomStartRaise: centreSharesStart ? raise : 0,\n bottomEndRaise: centreSharesEnd ? raise : 0,\n popoverCentreRise: popoverRiseOverCentre(\n root,\n { start: bottomStart, end: bottomEnd, centre: bottomCentre },\n centreSpan,\n {\n start: centreSharesStart ? raise : 0,\n end: centreSharesEnd ? raise : 0,\n },\n ),\n tourBottom: tour && tour.height > 0 ? tour.top + tour.height : null,\n mapKeyBottom:\n mapKey && mapKey.height > 0 ? mapKey.top + mapKey.height : null,\n mapKeyHeight: mapKey?.height ?? 0,\n };\n}\n\n/** How far each bottom slot is lifted (zero or negative), sheet and toolbar together. */\ninterface BottomLifts {\n readonly start: number;\n readonly end: number;\n}\n\n/**\n * The top of the bottom row once each slot has been lifted by its own lift:\n * the highest of the slots that show.\n */\nfunction liftedRowTop(m: Measurements, lifts: BottomLifts): number {\n const tops = [\n m.bottomStartTop === null ? null : m.bottomStartTop + lifts.start,\n m.bottomEndTop === null ? null : m.bottomEndTop + lifts.end,\n ].filter((top): top is number => top !== null);\n return tops.length > 0\n ? Math.min(...tops)\n : m.bottomRowTop + Math.min(lifts.start, lifts.end);\n}\n\n/**\n * Whether the tour card has to give way: the bottom row (lifted above the\n * sheet or a toolbar) comes up to it, or a bottom-centre slot it shares width\n * with does.\n */\nfunction isTourCrowded(\n m: Measurements | null,\n lifts: BottomLifts,\n centreTop: number | null,\n): boolean {\n if (m === null || m.tourBottom === null) {\n return false;\n }\n const centreEdge =\n m.centreSharesTour && centreTop !== null\n ? centreTop\n : Number.POSITIVE_INFINITY;\n return (\n m.tourBottom + CHROME_GAP_PX > Math.min(liftedRowTop(m, lifts), centreEdge)\n );\n}\n\n/**\n * How far the map key is lifted for the key's placement: with the bottom-start\n * slot, and further where the key, which can be wider than the readout,\n * shares width with the bottom-centre slot and has to clear its top.\n */\nfunction mapKeyLiftAbove(\n m: Measurements | null,\n lifts: BottomLifts,\n centreTop: number | null,\n): number {\n return m?.centreSharesKey && centreTop !== null\n ? Math.min(lifts.start, centreTop - m.bottomRowTop)\n : lifts.start;\n}\n\n/**\n * Vertical room between the end stack and the bottom row, once each bottom\n * slot has been lifted. The end stack stops a gap above that row, and the\n * credits popover, which grows up from bottom-end and rises over the whole row\n * (`bottomEndRise` is how much higher than the bottom-end slot the row is),\n * stops a gap below the end stack. Placed beside the end stack instead, the\n * popover may rise to a gap below the top-start slot.\n */\nfunction verticalRoom(m: Measurements, lifts: BottomLifts) {\n const rowTop = liftedRowTop(m, lifts);\n return {\n endStackMaxHeight: computeEndStackMaxHeight({\n viewportHeight: m.height,\n topOffset: m.endStackTop,\n bottomReserved: m.height - rowTop + CHROME_GAP_PX - CHROME_INSET_PX,\n inset: CHROME_INSET_PX,\n }),\n bottomEndRise:\n m.bottomStartTop === null || m.bottomEndTop === null\n ? 0\n : Math.max(\n 0,\n m.bottomEndTop + lifts.end - (m.bottomStartTop + lifts.start),\n ),\n bottomEndRoom: Math.max(0, rowTop - CHROME_GAP_PX - m.endStackBottom),\n bottomEndBesideRoom: Math.max(0, rowTop - CHROME_GAP_PX - m.topStartBottom),\n };\n}\n\nfunction sameMeasurements(a: Measurements | null, b: Measurements): boolean {\n return (\n a !== null &&\n (Object.keys(b) as (keyof Measurements)[]).every((key) => a[key] === b[key])\n );\n}\n\n/** How far a fitted feature must stay above the visible key at the bottom. */\nfunction clearanceAboveMapKey(\n measurements: Measurements | null,\n crowded: boolean,\n placement: ReturnType<typeof placeMapKey>,\n): number | null {\n if (\n !measurements ||\n measurements.mapKeyBottom === null ||\n placement === null ||\n crowded\n ) {\n return null;\n }\n const top =\n measurements.mapKeyBottom - measurements.mapKeyHeight + placement.shift;\n return measurements.height - top;\n}\n\n/** Places the key from a complete measurement, when one exists. */\nfunction mapKeyPlacementAt(\n measurements: Measurements | null,\n lift: number,\n tourBottom: number | null,\n): ReturnType<typeof placeMapKey> {\n return measurements ? placeMapKey(measurements, lift, tourBottom) : null;\n}\n\n/** The tour edge that competes with the key, when the tour is shown. */\nfunction keyTourBottom(\n hidden: boolean,\n measurements: Measurements | null,\n): number | null {\n return hidden ? null : (measurements?.tourBottom ?? null);\n}\n\n/**\n * The one owner of everything floating over the map. It draws the map\n * full-bleed inside `main`, lays the slots out with flow layout, and keeps\n * the bottom slots clear of the sheet, the side panel and the measure\n * toolbar.\n *\n * @remarks\n * - DOM order is reading order: top-start, tour, end-stack, the sheet, the map\n * (`main`), the map key, then bottom-start, bottom-centre and bottom-end.\n * The app renders the skip link before this component and the page's h1\n * itself.\n * - While `modal`, every group except the sheet gets `inert`. That is one\n * inert attribute per group rather than one wrapper, because the sheet sits\n * between the groups in reading order.\n * - The container ignores the pointer; each slot takes it back, so the map\n * stays draggable in every gap. Every slot wrapper has `data-chrome` with\n * its slot name; the sheet carries its own `data-chrome=\"sheet\"`.\n * - A `ResizeObserver` measures the container (which already reflects the\n * visual viewport) and the slots. From that it chooses the layout, gives\n * `ChromeLayoutProvider` the viewport and the pointer preference, and sets\n * the {@link chromeVars} on the root with CSSOM: never a `style` attribute,\n * because production CSP is `style-src 'self'`.\n * - The sheet publishes its top edge (`publishSheetTop`) and detent, and the\n * side panel its right edge. Whatever is shown in bottom-centre, a toolbar\n * first, is an obstruction too, measured from its slot.\n * `computeBottomSlotLayout` turns these into the lift and shift of the\n * bottom slots, which hide at the full detent.\n * - The bottom row rides above the sheet with a `transform`, which slides, and\n * above the bottom-centre slot with the separate `translate` property\n * (`bottomStartRaise`, `bottomEndRaise` and `mapKeyRaise`, each zero for a slot\n * that shares no width with the bottom-centre slot), which does not, and which\n * the measuring observer sets in\n * its own callback. A toolbar that changes height therefore never has the\n * row over it, in any frame, with motion or without.\n * - Before the first measurement (and in server rendering) the layout is the\n * bottom sheet, the narrow-screen default.\n */\nexport function MapChrome({\n background,\n topStart,\n endStack,\n bottomStart,\n bottomEnd,\n bottomCentre,\n tour,\n tourSide = \"start\",\n mapKey,\n sheet,\n modal,\n onViewportChange,\n}: MapChromeProps) {\n const rootRef = useRef<HTMLDivElement>(null);\n const slots = useRef(new Map<SlotName, HTMLElement>());\n const { finePointer } = usePreferences();\n const [measurements, setMeasurements] = useState<Measurements | null>(null);\n const [sheetTop, publishSheetTop] = useState<number | null>(null);\n const [sheetDetent, publishSheetDetent] = useState<SheetDetent | null>(null);\n const [panelEdge, publishPanelEdge] = useState<number | null>(null);\n const mapKeyTourBottomRef = useRef<number | null>(null);\n // The sideways shift the bottom-start slot is about to rest at, which the\n // measurement needs to tell whether a toolbar would cover the slot.\n const startShiftXRef = useRef(0);\n\n const observerRef = useRef<ResizeObserver | null>(null);\n const popoverChangesRef = useRef<MutationObserver | null>(null);\n const update = useCallback(() => {\n const root = rootRef.current;\n if (!root || !observerRef.current) {\n return;\n }\n const next = measure(root, slots.current, startShiftXRef.current);\n // A container with no size has not been laid out (or is hidden); its\n // zero height would otherwise pick the panel layout.\n if (next.width === 0 && next.height === 0) {\n return;\n }\n // Written here, in the observer's own callback, and not from the render\n // that follows: the observer runs before the frame paints, so the bottom\n // row rises with the slot it clears in the frame that slot changes size,\n // where state set from here would be applied a frame later.\n root.style.setProperty(\n chromeVars.bottomStartRaise,\n `${next.bottomStartRaise}px`,\n );\n root.style.setProperty(\n chromeVars.bottomEndRaise,\n `${next.bottomEndRaise}px`,\n );\n root.style.setProperty(chromeVars.mapKeyRaise, `${next.mapKeyRaise}px`);\n root.style.setProperty(\n chromeVars.popoverCentreRise,\n `${next.popoverCentreRise}px`,\n );\n const popover = root.querySelector<HTMLElement>(\n '[data-chrome=\"attribution-popover\"]',\n );\n if (popover) {\n observerRef.current.observe(popover);\n }\n applyMapKeyPlacement(\n root,\n placeMapKey(next, 0, mapKeyTourBottomRef.current),\n );\n setMeasurements((current) =>\n sameMeasurements(current, next) ? current : next,\n );\n }, []);\n\n // One stable ref callback per slot: a slot that appears later is observed\n // (which reports its first size), and one that goes triggers a re-measure.\n const slotRefs = useMemo(() => {\n const make = (name: SlotName) => (element: HTMLElement | null) => {\n const previous = slots.current.get(name);\n if (element) {\n slots.current.set(name, element);\n observerRef.current?.observe(element);\n if (name === \"bottom-end\") {\n popoverChangesRef.current?.observe(element, POPOVER_CHANGES);\n }\n return;\n }\n if (previous) {\n observerRef.current?.unobserve(previous);\n }\n slots.current.delete(name);\n update();\n };\n return {\n \"top-start\": make(\"top-start\"),\n tour: make(\"tour\"),\n \"map-key\": make(\"map-key\"),\n \"end-stack\": make(\"end-stack\"),\n \"bottom-start\": make(\"bottom-start\"),\n \"bottom-centre\": make(\"bottom-centre\"),\n \"bottom-end\": make(\"bottom-end\"),\n } satisfies Record<SlotName, (element: HTMLElement | null) => void>;\n }, [update]);\n\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root || typeof ResizeObserver === \"undefined\") {\n return;\n }\n const observer = new ResizeObserver(update);\n observerRef.current = observer;\n observer.observe(root);\n for (const element of slots.current.values()) {\n observer.observe(element);\n }\n // The credits popover opens, closes and moves beside the end stack by\n // attribute, with no change of size that the observer above would report.\n // Only the slot that holds it is watched.\n const popoverChanges = new MutationObserver(() => {\n update();\n });\n popoverChangesRef.current = popoverChanges;\n const endSlot = slots.current.get(\"bottom-end\");\n if (endSlot) {\n popoverChanges.observe(endSlot, POPOVER_CHANGES);\n }\n return () => {\n observer.disconnect();\n popoverChanges.disconnect();\n popoverChangesRef.current = null;\n observerRef.current = null;\n };\n }, [update]);\n\n const width = measurements?.width ?? 0;\n const height = measurements?.height ?? 0;\n const viewport = useMemo(() => ({ width, height }), [width, height]);\n const layout: ChromeLayout = measurements ? chooseLayout(viewport) : \"sheet\";\n\n // A new layout changes the grid, which can move slots without resizing\n // any of them, so nothing would report it.\n // biome-ignore lint/correctness/useExhaustiveDependencies: the layout is the trigger; the measurement reads the DOM it produced.\n useLayoutEffect(() => {\n update();\n }, [layout, update]);\n\n // A slot that comes or goes can move another without resizing it (the row a\n // toolbar made taller shrinks back), and the measurement a slot's ref makes\n // as it leaves still sees it in the page, so measure once the page has\n // updated. On the reference site `mapKey == null` is never true, because\n // `<MapKey />` is always an element, so the map key's own resize is what\n // re-measures it.\n const presence = [\n topStart,\n tour,\n mapKey,\n endStack,\n bottomStart,\n bottomCentre,\n bottomEnd,\n ]\n .map((content) => (content == null ? \"-\" : \"+\"))\n .join(\"\");\n const measuredPresence = useRef(presence);\n useLayoutEffect(() => {\n if (measuredPresence.current !== presence) {\n measuredPresence.current = presence;\n update();\n }\n }, [presence, update]);\n\n const onViewportChangeRef = useLatestRef(onViewportChange);\n useEffect(() => {\n if (measurements) {\n onViewportChangeRef.current?.(viewport);\n }\n }, [viewport, measurements, onViewportChangeRef]);\n\n // Where the bottom row rests above the bottom edge.\n const inset = measurements?.bottomInset ?? CHROME_INSET_PX;\n const sheetOnly = computeBottomSlotLayout({\n layout,\n viewportWidth: width,\n viewportHeight: height,\n sheetTopEdge: sheetTop,\n sheetDetent,\n panelRightEdge: panelEdge,\n measureToolbarTop: null,\n inset,\n });\n const centreTop =\n measurements?.bottomCentreTop == null\n ? null\n : measurements.bottomCentreTop + sheetOnly.bottomStartTranslateY;\n // A toolbar lifts only the slots it shares width with.\n const bottomAbove = (sharesWidthWithCentre: boolean | undefined) =>\n computeBottomSlotLayout({\n layout,\n viewportWidth: width,\n viewportHeight: height,\n sheetTopEdge: sheetTop,\n sheetDetent,\n panelRightEdge: panelEdge,\n measureToolbarTop: sharesWidthWithCentre ? centreTop : null,\n inset,\n });\n const startLayout = bottomAbove(measurements?.centreSharesStart);\n const endLayout = bottomAbove(measurements?.centreSharesEnd);\n const lifts: BottomLifts = {\n start: startLayout.bottomStartTranslateY,\n end: endLayout.bottomEndTranslateY,\n };\n const keyLift = mapKeyLiftAbove(measurements, lifts, centreTop);\n\n const room = measurements ? verticalRoom(measurements, lifts) : null;\n // The tour card does not shrink or scroll, so when the bottom row (lifted\n // above the sheet or a toolbar) comes up to it, it gives way, as it does at\n // the full detent, and returns when there is room. Only vertical edges are\n // compared: in the panel layout the row can sit beside the card, so the card\n // may hide where it would have fitted, which is accepted for the simpler rule.\n const tourCrowded = isTourCrowded(measurements, lifts, centreTop);\n const tourHidden = modal || tourCrowded;\n const keyTourEdge = keyTourBottom(tourHidden, measurements);\n // The measuring observer reads the tour edge this render decided on. A card\n // hidden by state alone (a modal, or the row reaching it) resizes no slot,\n // so no observer round follows: place the key again here.\n useLayoutEffect(() => {\n if (mapKeyTourBottomRef.current === keyTourEdge) {\n return;\n }\n mapKeyTourBottomRef.current = keyTourEdge;\n update();\n }, [keyTourEdge, update]);\n // The map key gives way to the tour card, which is there for a first visit\n // and is shown first, and hides when the room under the search pill is too\n // small for its chip.\n // MapChrome's measuring observer writes this placement synchronously, before\n // paint. Do not repeat it from render, which would put an older placement\n // back for one frame when another slot changes size.\n const mapKeyLivePlacement = mapKeyPlacementAt(\n measurements,\n keyLift,\n keyTourEdge,\n );\n const mapKeyCrowded = isMapKeyCrowded(mapKeyLivePlacement);\n const mapKeyClearance = clearanceAboveMapKey(\n measurements,\n mapKeyCrowded,\n mapKeyLivePlacement,\n );\n const endStackMaxHeight = room?.endStackMaxHeight ?? null;\n const bottomEndRise = room?.bottomEndRise ?? null;\n const bottomEndRoom = room?.bottomEndRoom ?? null;\n const bottomEndBesideRoom = room?.bottomEndBesideRoom ?? null;\n\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (\n !root ||\n !measurements ||\n endStackMaxHeight === null ||\n bottomEndRise === null ||\n bottomEndRoom === null ||\n bottomEndBesideRoom === null\n ) {\n return;\n }\n const set = (name: string, px: number) => {\n root.style.setProperty(name, `${px}px`);\n };\n set(chromeVars.width, measurements.width);\n set(chromeVars.topStartBottom, measurements.topStartBottom);\n set(chromeVars.endStackMaxHeight, endStackMaxHeight);\n set(chromeVars.endStackWidth, measurements.endStackWidth);\n set(chromeVars.bottomEndRise, bottomEndRise);\n set(chromeVars.bottomEndRoom, bottomEndRoom);\n set(chromeVars.bottomEndBesideRoom, bottomEndBesideRoom);\n set(chromeVars.bottomLift, sheetOnly.bottomStartTranslateY);\n set(chromeVars.bottomStartX, startLayout.bottomStartTranslateX);\n // A new shift moves the slots without resizing them, so measure again\n // against it; the raise it changes is written by that measurement.\n if (startShiftXRef.current !== startLayout.bottomStartTranslateX) {\n startShiftXRef.current = startLayout.bottomStartTranslateX;\n update();\n }\n }, [\n measurements,\n endStackMaxHeight,\n bottomEndRise,\n bottomEndRoom,\n bottomEndBesideRoom,\n startLayout.bottomStartTranslateX,\n sheetOnly.bottomStartTranslateY,\n update,\n ]);\n\n const layoutValue = useMemo<ChromeLayoutValue>(\n () => ({\n layout,\n viewport,\n finePointer,\n panelEdge,\n mapKeyClearance,\n publishSheetTop,\n }),\n [layout, viewport, finePointer, panelEdge, mapKeyClearance],\n );\n const surfaceValue = useMemo<ChromeSurfaceValue>(\n () => ({\n publishSheetDetent,\n publishPanelEdge,\n endStackMaxHeight,\n tourHidden,\n }),\n [endStackMaxHeight, tourHidden],\n );\n\n const slot = (\n name: SlotName,\n className: string,\n content: ReactNode | undefined,\n ) =>\n content == null ? null : (\n <div\n ref={slotRefs[name]}\n data-chrome={name}\n className={className}\n inert={modal}\n >\n {content}\n </div>\n );\n\n return (\n <ChromeLayoutProvider value={layoutValue}>\n <ChromeSurfaceContext.Provider value={surfaceValue}>\n <div\n ref={rootRef}\n data-chrome-root=\"\"\n data-testid=\"map-chrome\"\n data-layout={layout}\n data-hide-bottom={startLayout.hideBottomSlots ? \"true\" : \"false\"}\n className={styles.root}\n >\n {slot(\"top-start\", styles.topStart, topStart)}\n {tour == null ? null : (\n <div\n ref={slotRefs.tour}\n data-chrome=\"tour\"\n data-side={tourSide}\n data-crowded={tourCrowded ? \"true\" : \"false\"}\n className={styles.tour}\n inert={tourHidden}\n >\n {tour}\n </div>\n )}\n {slot(\"end-stack\", styles.endStack, endStack)}\n {sheet}\n <main className={styles.background} inert={modal}>\n {background}\n </main>\n {mapKey == null ? null : (\n <div\n ref={slotRefs[\"map-key\"]}\n data-chrome=\"map-key\"\n data-crowded={mapKeyCrowded ? \"true\" : \"false\"}\n className={styles.mapKey}\n inert={modal || mapKeyCrowded}\n >\n {mapKey}\n </div>\n )}\n {slot(\"bottom-start\", styles.bottomStart, bottomStart)}\n {slot(\"bottom-centre\", styles.bottomCentre, bottomCentre)}\n {slot(\"bottom-end\", styles.bottomEnd, bottomEnd)}\n </div>\n </ChromeSur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a;EAAW;CAAe,CAC5D;CACA,MAAM,eAAe,eACZ;EACL;EACA;EACA;EACA;CACF,IACA,CAAC,mBAAmB,UAAU,CAChC;CAEA,MAAM,QACJ,MACA,WACA,YAEA,WAAW,OAAO,OAChB,oBAAC,OAAD;EACE,KAAK,SAAS;EACd,eAAa;EACF;EACX,OAAO;EAEN,UAAA;CACE,CAAA;CAGT,OACE,oBAAC,sBAAD;EAAsB,OAAO;EAC3B,UAAA,oBAAC,qBAAqB,UAAtB;GAA+B,OAAO;GACpC,UAAA,qBAAC,OAAD;IACE,KAAK;IACL,oBAAiB;IACjB,eAAY;IACZ,eAAa;IACb,oBAAkB,YAAY,kBAAkB,SAAS;IACzD,WAAWC;IANb,UAAA;KAQG,KAAK,aAAaC,UAAiBR,UAAQ;KAC3CC,UAAQ,OAAO,OACd,oBAAC,OAAD;MACE,KAAK,SAAS;MACd,eAAY;MACZ,aAAW;MACX,gBAAc,cAAc,SAAS;MACrC,WAAWQ;MACX,OAAO;MAEN,UAAAR;KACE,CAAA;KAEN,KAAK,aAAaS,UAAiBP,UAAQ;KAC3C;KACD,oBAAC,QAAD;MAAM,WAAWQ;MAAmB,OAAO;MACxC,UAAAC;KACG,CAAA;KACLV,YAAU,OAAO,OAChB,oBAAC,OAAD;MACE,KAAK,SAAS;MACd,eAAY;MACZ,gBAAc,gBAAgB,SAAS;MACvC,WAAWW;MACX,OAAO,SAAS;MAEf,UAAAX;KACE,CAAA;KAEN,KAAK,gBAAgBY,aAAoBV,aAAW;KACpD,KAAK,iBAAiBW,cAAqBV,cAAY;KACvD,KAAK,cAAcW,WAAkBV,WAAS;IAC5C;;EACwB,CAAA;CACX,CAAA;AAE1B"}
@@ -0,0 +1,15 @@
1
+ /* empty css */
2
+ // src/chrome/MapChrome/MapChrome.css.ts
3
+ var root = "d4qk3g0";
4
+ var skeletonRoot = "d4qk3g1 d4qk3g0";
5
+ var background = "d4qk3g2";
6
+ var topStart = "d4qk3g3";
7
+ var endStack = "d4qk3g4";
8
+ var bottomStart = "d4qk3g5";
9
+ var bottomCentre = "d4qk3g6";
10
+ var tour = "d4qk3g7";
11
+ var mapKey = "d4qk3g8";
12
+ var bottomEnd = "d4qk3g9";
13
+ export { background, bottomCentre, bottomEnd, bottomStart, endStack, mapKey, root, skeletonRoot, topStart, tour };
14
+
15
+ //# sourceMappingURL=MapChrome.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MapChrome.styles.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext } from "react";
2
+ /** Provided by `MapChrome` only. */
3
+ var ChromeSurfaceContext = createContext({
4
+ publishSheetDetent() {},
5
+ publishPanelEdge() {},
6
+ endStackMaxHeight: null,
7
+ tourHidden: false
8
+ });
9
+ /**
10
+ * Reads the internal chrome surface value. Outside a `MapChrome` it returns
11
+ * no-op publishers and an unmeasured end stack, so components test alone.
12
+ */
13
+ function useChromeSurface() {
14
+ return useContext(ChromeSurfaceContext);
15
+ }
16
+ export { ChromeSurfaceContext, useChromeSurface };
17
+
18
+ //# sourceMappingURL=chromeSurface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chromeSurface.js","names":[],"sources":["../../../src/chrome/MapChrome/chromeSurface.tsx"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-only\n// Copyright MapCairn contributors\nimport type { SheetDetent } from \"@mapcairn/core\";\nimport { createContext, useContext } from \"react\";\n\n/**\n * Facts that pass between `MapChrome` and the chrome components it lays out,\n * beyond the public `ChromeLayoutValue`. Internal to the chrome directory.\n *\n * @remarks `computeBottomSlotLayout` needs the sheet's detent (to hide the\n * bottom slots at full) and, in the panel layout, the panel's right edge\n * (to move bottom-start clear of it). The `Sheet` publishes both here,\n * next to the top edge it publishes through `useChromeLayout()`. Going the\n * other way, `MapChrome` tells the `EndStack` how tall it may be, so the\n * zoom group can yield on short screens.\n */\nexport interface ChromeSurfaceValue {\n /** The sheet publishes its detent while open in the sheet layout, else null. */\n publishSheetDetent(detent: SheetDetent | null): void;\n /**\n * The side panel publishes its right edge (px from the container's left)\n * while open in the panel layout, else null.\n */\n publishPanelEdge(px: number | null): void;\n /** The tallest the end stack may be, or null before the first measurement. */\n readonly endStackMaxHeight: number | null;\n /**\n * True while the tour card's slot is inert and hidden (the sheet is modal\n * or the bottom row has come up to the card), so the card does not ask for\n * focus it cannot take and gives focus up when it hides.\n */\n readonly tourHidden: boolean;\n}\n\nconst defaultValue: ChromeSurfaceValue = {\n publishSheetDetent() {},\n publishPanelEdge() {},\n endStackMaxHeight: null,\n tourHidden: false,\n};\n\n/** Provided by `MapChrome` only. */\nexport const ChromeSurfaceContext =\n createContext<ChromeSurfaceValue>(defaultValue);\n\n/**\n * Reads the internal chrome surface value. Outside a `MapChrome` it returns\n * no-op publishers and an unmeasured end stack, so components test alone.\n */\nexport function useChromeSurface(): ChromeSurfaceValue {\n return useContext(ChromeSurfaceContext);\n}\n"],"mappings":";;AA0CA,IAAa,uBACX,cAAkC;CARlC,qBAAqB,CAAC;CACtB,mBAAmB,CAAC;CACpB,mBAAmB;CACnB,YAAY;AAKsB,CAAY;;;;;AAMhD,SAAgB,mBAAuC;CACrD,OAAO,WAAW,oBAAoB;AACxC"}