@mountaya/studio 0.0.0-stage → 0.1.0

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 (524) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +917 -2
  5. package/dist/agent/index.cjs +2854 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1257 -0
  8. package/dist/agent/index.d.ts +1257 -0
  9. package/dist/agent/index.js +2818 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/bus-BwiNiXdH.d.ts +514 -0
  12. package/dist/bus-DzmhPwdK.d.cts +514 -0
  13. package/dist/chainModel-B23pEP_1.d.cts +127 -0
  14. package/dist/chainModel-B23pEP_1.d.ts +127 -0
  15. package/dist/chunk-2HFY7ETU.js +5721 -0
  16. package/dist/chunk-2HFY7ETU.js.map +1 -0
  17. package/dist/chunk-355TOXSB.js +72 -0
  18. package/dist/chunk-355TOXSB.js.map +1 -0
  19. package/dist/chunk-4ZCUZVSV.js +10275 -0
  20. package/dist/chunk-4ZCUZVSV.js.map +1 -0
  21. package/dist/chunk-6HEKY3NF.js +95 -0
  22. package/dist/chunk-6HEKY3NF.js.map +1 -0
  23. package/dist/chunk-7GFLGGBX.cjs +8 -0
  24. package/dist/chunk-7GFLGGBX.cjs.map +1 -0
  25. package/dist/chunk-7NBRCENN.cjs +19 -0
  26. package/dist/chunk-7NBRCENN.cjs.map +1 -0
  27. package/dist/chunk-AF5GCXE3.js +8 -0
  28. package/dist/chunk-AF5GCXE3.js.map +1 -0
  29. package/dist/chunk-CJDIFRGZ.cjs +2005 -0
  30. package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
  31. package/dist/chunk-CNPZY7N3.js +349 -0
  32. package/dist/chunk-CNPZY7N3.js.map +1 -0
  33. package/dist/chunk-DZJHTWSF.cjs +45 -0
  34. package/dist/chunk-DZJHTWSF.cjs.map +1 -0
  35. package/dist/chunk-EABIHHWA.js +42 -0
  36. package/dist/chunk-EABIHHWA.js.map +1 -0
  37. package/dist/chunk-EKZWV6RS.cjs +415 -0
  38. package/dist/chunk-EKZWV6RS.cjs.map +1 -0
  39. package/dist/chunk-EOKRXXAC.cjs +24 -0
  40. package/dist/chunk-EOKRXXAC.cjs.map +1 -0
  41. package/dist/chunk-F73W2ZTJ.js +1126 -0
  42. package/dist/chunk-F73W2ZTJ.js.map +1 -0
  43. package/dist/chunk-H4DVOZ5O.js +1897 -0
  44. package/dist/chunk-H4DVOZ5O.js.map +1 -0
  45. package/dist/chunk-HI52PBFT.cjs +10314 -0
  46. package/dist/chunk-HI52PBFT.cjs.map +1 -0
  47. package/dist/chunk-IDBXFBLG.cjs +1225 -0
  48. package/dist/chunk-IDBXFBLG.cjs.map +1 -0
  49. package/dist/chunk-LBWTJZUJ.js +297 -0
  50. package/dist/chunk-LBWTJZUJ.js.map +1 -0
  51. package/dist/chunk-NCLA6DKD.cjs +310 -0
  52. package/dist/chunk-NCLA6DKD.cjs.map +1 -0
  53. package/dist/chunk-O4MC5DPD.js +19 -0
  54. package/dist/chunk-O4MC5DPD.js.map +1 -0
  55. package/dist/chunk-OP37FKW6.cjs +98 -0
  56. package/dist/chunk-OP37FKW6.cjs.map +1 -0
  57. package/dist/chunk-OQSYFH3Z.cjs +5945 -0
  58. package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
  59. package/dist/chunk-PACIO4NS.cjs +26 -0
  60. package/dist/chunk-PACIO4NS.cjs.map +1 -0
  61. package/dist/chunk-PSZ2R3TC.cjs +75 -0
  62. package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
  63. package/dist/chunk-QFO5CZG2.cjs +136 -0
  64. package/dist/chunk-QFO5CZG2.cjs.map +1 -0
  65. package/dist/chunk-QL63MUEW.cjs +140 -0
  66. package/dist/chunk-QL63MUEW.cjs.map +1 -0
  67. package/dist/chunk-RFUPPVZO.js +17 -0
  68. package/dist/chunk-RFUPPVZO.js.map +1 -0
  69. package/dist/chunk-RPG2LWMP.js +23 -0
  70. package/dist/chunk-RPG2LWMP.js.map +1 -0
  71. package/dist/chunk-TIBXK6B7.cjs +12 -0
  72. package/dist/chunk-TIBXK6B7.cjs.map +1 -0
  73. package/dist/chunk-UU65VNEV.js +381 -0
  74. package/dist/chunk-UU65VNEV.js.map +1 -0
  75. package/dist/chunk-VGX6TR2I.js +209 -0
  76. package/dist/chunk-VGX6TR2I.js.map +1 -0
  77. package/dist/chunk-WUTDDBVP.js +130 -0
  78. package/dist/chunk-WUTDDBVP.js.map +1 -0
  79. package/dist/chunk-WVQQLKCI.cjs +224 -0
  80. package/dist/chunk-WVQQLKCI.cjs.map +1 -0
  81. package/dist/chunk-WZYXG3SE.js +111 -0
  82. package/dist/chunk-WZYXG3SE.js.map +1 -0
  83. package/dist/chunk-XDI2X3KE.js +6 -0
  84. package/dist/chunk-XDI2X3KE.js.map +1 -0
  85. package/dist/chunk-XKHLRIC7.cjs +381 -0
  86. package/dist/chunk-XKHLRIC7.cjs.map +1 -0
  87. package/dist/context-DNtd2WUv.d.cts +11666 -0
  88. package/dist/context-DgB72Bur.d.ts +11666 -0
  89. package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
  90. package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
  91. package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
  92. package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
  93. package/dist/engines/index.cjs +3446 -0
  94. package/dist/engines/index.cjs.map +1 -0
  95. package/dist/engines/index.d.cts +2216 -0
  96. package/dist/engines/index.d.ts +2216 -0
  97. package/dist/engines/index.js +3416 -0
  98. package/dist/engines/index.js.map +1 -0
  99. package/dist/handlers/index.cjs +99 -0
  100. package/dist/handlers/index.cjs.map +1 -0
  101. package/dist/handlers/index.d.cts +445 -0
  102. package/dist/handlers/index.d.ts +445 -0
  103. package/dist/handlers/index.js +42 -0
  104. package/dist/handlers/index.js.map +1 -0
  105. package/dist/index.cjs +4562 -0
  106. package/dist/index.cjs.map +1 -0
  107. package/dist/index.d.cts +7297 -0
  108. package/dist/index.d.ts +7297 -0
  109. package/dist/index.js +3223 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/plugins/index.cjs +977 -0
  112. package/dist/plugins/index.cjs.map +1 -0
  113. package/dist/plugins/index.d.cts +313 -0
  114. package/dist/plugins/index.d.ts +313 -0
  115. package/dist/plugins/index.js +933 -0
  116. package/dist/plugins/index.js.map +1 -0
  117. package/dist/saveFile-j-1kkApx.d.cts +123 -0
  118. package/dist/saveFile-j-1kkApx.d.ts +123 -0
  119. package/dist/seams/index.cjs +152 -0
  120. package/dist/seams/index.cjs.map +1 -0
  121. package/dist/seams/index.d.cts +485 -0
  122. package/dist/seams/index.d.ts +485 -0
  123. package/dist/seams/index.js +79 -0
  124. package/dist/seams/index.js.map +1 -0
  125. package/dist/shareLink-B6hlt942.d.ts +144 -0
  126. package/dist/shareLink-C7rIMb7x.d.ts +527 -0
  127. package/dist/shareLink-CnTxxXjp.d.cts +144 -0
  128. package/dist/shareLink-DyZVYH2V.d.cts +527 -0
  129. package/dist/strings/fr/index.cjs +2121 -0
  130. package/dist/strings/fr/index.cjs.map +1 -0
  131. package/dist/strings/fr/index.d.cts +19 -0
  132. package/dist/strings/fr/index.d.ts +19 -0
  133. package/dist/strings/fr/index.js +2119 -0
  134. package/dist/strings/fr/index.js.map +1 -0
  135. package/dist/strings/index.cjs +2678 -0
  136. package/dist/strings/index.cjs.map +1 -0
  137. package/dist/strings/index.d.cts +731 -0
  138. package/dist/strings/index.d.ts +731 -0
  139. package/dist/strings/index.js +2644 -0
  140. package/dist/strings/index.js.map +1 -0
  141. package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
  142. package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
  143. package/dist/tabs-B2nRO4p_.d.cts +15 -0
  144. package/dist/tabs-B2nRO4p_.d.ts +15 -0
  145. package/dist/testing/index.cjs +292 -0
  146. package/dist/testing/index.cjs.map +1 -0
  147. package/dist/testing/index.d.cts +306 -0
  148. package/dist/testing/index.d.ts +306 -0
  149. package/dist/testing/index.js +284 -0
  150. package/dist/testing/index.js.map +1 -0
  151. package/dist/time/index.cjs +28 -0
  152. package/dist/time/index.cjs.map +1 -0
  153. package/dist/time/index.d.cts +43 -0
  154. package/dist/time/index.d.ts +43 -0
  155. package/dist/time/index.js +26 -0
  156. package/dist/time/index.js.map +1 -0
  157. package/dist/types-BzJRV6UI.d.cts +845 -0
  158. package/dist/types-BzJRV6UI.d.ts +845 -0
  159. package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
  160. package/dist/zoneForm-mG85yt5e.d.ts +320 -0
  161. package/package.json +225 -4
  162. package/src/agent/engines/agentThreads.ts +1601 -0
  163. package/src/agent/engines/directorChat.ts +500 -0
  164. package/src/agent/index.ts +67 -0
  165. package/src/agent/rules/agentEditLock.ts +115 -0
  166. package/src/agent/rules/agentErrorCopy.ts +44 -0
  167. package/src/agent/rules/copilotOrganization.ts +36 -0
  168. package/src/agent/rules/playbook.gen.ts +444 -0
  169. package/src/agent/rules/router.ts +518 -0
  170. package/src/agent/rules/stateDelta.ts +28 -0
  171. package/src/agent/rules/studioRouter.ts +123 -0
  172. package/src/agent/rules/surfaces.gen.ts +633 -0
  173. package/src/agent/rules/threadsUrl.ts +48 -0
  174. package/src/agent/rules/transcriptObserver.ts +90 -0
  175. package/src/agent/stores/agentThreads.ts +454 -0
  176. package/src/bus/contracts/noData.ts +18 -0
  177. package/src/bus/contracts/shared.ts +172 -0
  178. package/src/bus/contracts/studioTools.ts +224 -0
  179. package/src/bus/rules/bus.ts +858 -0
  180. package/src/bus/rules/confirmation.ts +22 -0
  181. package/src/bus/rules/defineRegistry.ts +26 -0
  182. package/src/bus/rules/errors.ts +401 -0
  183. package/src/bus/rules/handlerErrors.ts +103 -0
  184. package/src/bus/rules/handlerRegistry.ts +627 -0
  185. package/src/bus/rules/inputSchema.ts +232 -0
  186. package/src/bus/rules/invalidInput.ts +441 -0
  187. package/src/bus/rules/lateBoundTools.ts +100 -0
  188. package/src/bus/rules/studioRegistry.ts +324 -0
  189. package/src/bus/rules/studioToolBus.ts +73 -0
  190. package/src/bus/rules/types.ts +805 -0
  191. package/src/chrome/contracts/alert.ts +42 -0
  192. package/src/chrome/contracts/itinerary.ts +26 -0
  193. package/src/chrome/contracts/map.ts +23 -0
  194. package/src/chrome/contracts/overlay.ts +46 -0
  195. package/src/chrome/contracts/panel.ts +29 -0
  196. package/src/chrome/contracts/question.ts +52 -0
  197. package/src/chrome/contracts/selection.ts +26 -0
  198. package/src/chrome/contracts/sidenav.ts +23 -0
  199. package/src/chrome/contracts/snapshot.ts +319 -0
  200. package/src/chrome/contracts/state.ts +22 -0
  201. package/src/chrome/contracts/tabs.ts +56 -0
  202. package/src/chrome/handlers/alert.ts +91 -0
  203. package/src/chrome/handlers/introspection.ts +180 -0
  204. package/src/chrome/handlers/panels.ts +42 -0
  205. package/src/chrome/handlers/question.ts +24 -0
  206. package/src/chrome/handlers/sidenav.ts +116 -0
  207. package/src/chrome/handlers/snapshot.ts +451 -0
  208. package/src/chrome/handlers/stateDelta.ts +125 -0
  209. package/src/chrome/handlers/tabs.ts +143 -0
  210. package/src/chrome/handlers/timestamp.ts +19 -0
  211. package/src/chrome/rules/agentSelectors.ts +210 -0
  212. package/src/chrome/rules/mapAlert.ts +13 -0
  213. package/src/chrome/rules/question.ts +25 -0
  214. package/src/chrome/rules/tabs.ts +13 -0
  215. package/src/chrome/stores/activeDraftSession.ts +134 -0
  216. package/src/chrome/stores/chrome.ts +527 -0
  217. package/src/chrome/stores/uiStore.ts +573 -0
  218. package/src/collab/contracts/collab.ts +261 -0
  219. package/src/collab/handlers/collab.ts +468 -0
  220. package/src/collab/rules/toolNames.ts +33 -0
  221. package/src/collab/stores/collab.ts +899 -0
  222. package/src/collections/contracts/collection.ts +182 -0
  223. package/src/collections/handlers/collectionAttach.ts +141 -0
  224. package/src/collections/handlers/collections.ts +499 -0
  225. package/src/collections/handlers/heldCollection.ts +42 -0
  226. package/src/collections/handlers/restCollections.ts +386 -0
  227. package/src/collections/rules/collections.ts +138 -0
  228. package/src/collections/rules/entityCollections.ts +53 -0
  229. package/src/collections/stores/collections.ts +133 -0
  230. package/src/data/contracts/data.ts +233 -0
  231. package/src/data/contracts/itinerary.ts +71 -0
  232. package/src/data/handlers/activityResolve.ts +76 -0
  233. package/src/data/handlers/data.ts +200 -0
  234. package/src/data/handlers/graphql.ts +26 -0
  235. package/src/data/handlers/mutationSink.ts +1577 -0
  236. package/src/data/handlers/profile.ts +83 -0
  237. package/src/data/handlers/writeThrough.ts +417 -0
  238. package/src/data/rules/cache.ts +181 -0
  239. package/src/data/rules/dataTypes.ts +40 -0
  240. package/src/data/rules/keys.ts +106 -0
  241. package/src/data/rules/persistence.ts +1058 -0
  242. package/src/data/rules/requestBody.ts +43 -0
  243. package/src/data/rules/restErrors.ts +354 -0
  244. package/src/data/rules/sessionSurface.ts +156 -0
  245. package/src/data/rules/toolResultData.ts +73 -0
  246. package/src/data/rules/uuid.ts +24 -0
  247. package/src/edit/contracts/edit.ts +37 -0
  248. package/src/edit/contracts/itinerary.ts +57 -0
  249. package/src/edit/handlers/draftCommit.ts +257 -0
  250. package/src/edit/handlers/editDiscard.ts +34 -0
  251. package/src/edit/handlers/editLock.ts +949 -0
  252. package/src/edit/handlers/editor.ts +203 -0
  253. package/src/edit/handlers/formUnsaved.ts +24 -0
  254. package/src/edit/rules/draftMetadata.ts +117 -0
  255. package/src/edit/rules/editKeyboard.ts +222 -0
  256. package/src/edit/rules/editShortcuts.ts +102 -0
  257. package/src/edit/rules/editTooltip.ts +174 -0
  258. package/src/edit/rules/editorTaken.ts +49 -0
  259. package/src/edit/rules/history.ts +26 -0
  260. package/src/edit/rules/unsavedWork.ts +60 -0
  261. package/src/edit/stores/editorReservation.ts +70 -0
  262. package/src/edit/stores/formsUnsaved.ts +54 -0
  263. package/src/embed/contracts/embed.ts +48 -0
  264. package/src/embed/engines/embedFraming.ts +1329 -0
  265. package/src/embed/engines/embedReady.ts +353 -0
  266. package/src/embed/engines/framingPageSession.ts +169 -0
  267. package/src/embed/handlers/embed.ts +130 -0
  268. package/src/embed/rules/allowedDomains.ts +71 -0
  269. package/src/embed/rules/bridgeMessages.ts +224 -0
  270. package/src/embed/rules/defaults.ts +173 -0
  271. package/src/embed/rules/displaySeed.ts +115 -0
  272. package/src/embed/rules/embedAllowlist.ts +146 -0
  273. package/src/embed/rules/embedConstraints.ts +215 -0
  274. package/src/embed/rules/embedElements.ts +277 -0
  275. package/src/embed/rules/embedSectionFields.ts +126 -0
  276. package/src/embed/rules/embedSecurity.ts +116 -0
  277. package/src/embed/rules/fieldDependencies.ts +87 -0
  278. package/src/embed/rules/fieldOptions.ts +138 -0
  279. package/src/embed/rules/layerOptions.ts +161 -0
  280. package/src/embed/rules/readyProtocol.ts +66 -0
  281. package/src/embed/rules/safetyRules.ts +213 -0
  282. package/src/embed/rules/snippet.ts +531 -0
  283. package/src/embed/rules/tableCode.ts +269 -0
  284. package/src/embed/stores/embed.ts +60 -0
  285. package/src/embed/stores/embedContent.ts +77 -0
  286. package/src/engines/index.ts +81 -0
  287. package/src/handlers/index.ts +66 -0
  288. package/src/index.ts +1086 -0
  289. package/src/itinerary/contracts/itinerary.ts +705 -0
  290. package/src/itinerary/engines/itineraryPace.ts +612 -0
  291. package/src/itinerary/engines/profileMarker.ts +238 -0
  292. package/src/itinerary/handlers/importStaging.ts +352 -0
  293. package/src/itinerary/handlers/itinerary.ts +572 -0
  294. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  295. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  296. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  297. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  298. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  299. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  300. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  301. package/src/itinerary/handlers/publicationScope.ts +118 -0
  302. package/src/itinerary/handlers/restItineraries.ts +752 -0
  303. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  304. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  305. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  306. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  307. package/src/itinerary/handlers/suggestParams.ts +379 -0
  308. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  309. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  310. package/src/itinerary/rules/activity.ts +139 -0
  311. package/src/itinerary/rules/analysis.ts +42 -0
  312. package/src/itinerary/rules/ceiling.ts +49 -0
  313. package/src/itinerary/rules/createFlow.ts +107 -0
  314. package/src/itinerary/rules/densify.ts +440 -0
  315. package/src/itinerary/rules/draftSurface.ts +219 -0
  316. package/src/itinerary/rules/editorView.ts +83 -0
  317. package/src/itinerary/rules/export.ts +159 -0
  318. package/src/itinerary/rules/friendlyName.ts +77 -0
  319. package/src/itinerary/rules/import.ts +1052 -0
  320. package/src/itinerary/rules/importFiles.ts +140 -0
  321. package/src/itinerary/rules/importTotals.ts +77 -0
  322. package/src/itinerary/rules/liveSegment.ts +712 -0
  323. package/src/itinerary/rules/lngLat.ts +17 -0
  324. package/src/itinerary/rules/mapSync.ts +100 -0
  325. package/src/itinerary/rules/previewRender.ts +416 -0
  326. package/src/itinerary/rules/profileReadout.ts +216 -0
  327. package/src/itinerary/rules/routing.ts +707 -0
  328. package/src/itinerary/rules/suggest.ts +522 -0
  329. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  330. package/src/itinerary/rules/view.ts +61 -0
  331. package/src/itinerary/stores/importSession.ts +319 -0
  332. package/src/itinerary/stores/itinerary.ts +331 -0
  333. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  334. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  335. package/src/itinerary/stores/suggestSession.ts +418 -0
  336. package/src/layers/contracts/itinerary.ts +46 -0
  337. package/src/layers/contracts/overlay.ts +132 -0
  338. package/src/layers/handlers/enrichment.ts +36 -0
  339. package/src/layers/handlers/overlay.ts +406 -0
  340. package/src/layers/handlers/restLayers.ts +94 -0
  341. package/src/layers/handlers/tiles.ts +25 -0
  342. package/src/layers/rules/layers.ts +212 -0
  343. package/src/layers/rules/overlayInstant.ts +12 -0
  344. package/src/layers/rules/reachabilityIcon.ts +18 -0
  345. package/src/layers/rules/readout.ts +102 -0
  346. package/src/layers/stores/layers.ts +262 -0
  347. package/src/map/contracts/contextmenu.ts +33 -0
  348. package/src/map/contracts/geolocate.ts +37 -0
  349. package/src/map/contracts/map.ts +146 -0
  350. package/src/map/contracts/streetview.ts +53 -0
  351. package/src/map/contracts/terrain.ts +152 -0
  352. package/src/map/handlers/contextMenu.ts +135 -0
  353. package/src/map/handlers/geolocate.ts +52 -0
  354. package/src/map/handlers/map.ts +391 -0
  355. package/src/map/handlers/streetview.ts +94 -0
  356. package/src/map/handlers/terrain.ts +663 -0
  357. package/src/map/rules/baseTerrain.ts +75 -0
  358. package/src/map/rules/clickTargets.ts +464 -0
  359. package/src/map/rules/constraints.ts +32 -0
  360. package/src/map/rules/contextMenuReadout.ts +67 -0
  361. package/src/map/rules/coordinates.ts +71 -0
  362. package/src/map/rules/itineraryFit.ts +8 -0
  363. package/src/map/rules/mapEvents.ts +64 -0
  364. package/src/map/rules/mapProjection.ts +476 -0
  365. package/src/map/rules/terrainReading.ts +62 -0
  366. package/src/plugins/contracts/ids.ts +66 -0
  367. package/src/plugins/contracts/plugin.ts +200 -0
  368. package/src/plugins/contracts/slots.ts +137 -0
  369. package/src/plugins/engines/studioPlugin.ts +1365 -0
  370. package/src/plugins/index.ts +111 -0
  371. package/src/plugins/rules/contributions.ts +152 -0
  372. package/src/plugins/rules/errors.ts +60 -0
  373. package/src/plugins/rules/ids.ts +42 -0
  374. package/src/plugins/rules/validation.ts +249 -0
  375. package/src/rules/listeners.ts +57 -0
  376. package/src/rules/origin.ts +13 -0
  377. package/src/rules/storeWrite.ts +37 -0
  378. package/src/rules/types.ts +136 -0
  379. package/src/seams/index.ts +79 -0
  380. package/src/seams/rules/clock.ts +28 -0
  381. package/src/seams/rules/formatters.ts +209 -0
  382. package/src/seams/rules/ids.ts +102 -0
  383. package/src/seams/rules/links.ts +66 -0
  384. package/src/seams/rules/navigation.ts +222 -0
  385. package/src/seams/rules/notify.ts +49 -0
  386. package/src/seams/rules/persistenceDrawer.ts +220 -0
  387. package/src/seams/rules/saveFile.ts +101 -0
  388. package/src/seams/rules/seams.ts +156 -0
  389. package/src/seams/rules/storage.ts +116 -0
  390. package/src/search/contracts/overlay.ts +74 -0
  391. package/src/search/contracts/search.ts +197 -0
  392. package/src/search/handlers/pois.ts +57 -0
  393. package/src/search/handlers/search.ts +280 -0
  394. package/src/search/rules/params.ts +925 -0
  395. package/src/search/rules/poiGroups.ts +138 -0
  396. package/src/search/rules/searchFetch.ts +139 -0
  397. package/src/search/rules/timeWindow.ts +30 -0
  398. package/src/search/stores/search.ts +51 -0
  399. package/src/segments/contracts/itinerary.ts +433 -0
  400. package/src/segments/contracts/segment.ts +35 -0
  401. package/src/segments/engines/segmentDraft.ts +926 -0
  402. package/src/segments/handlers/chainGuards.ts +67 -0
  403. package/src/segments/handlers/directions.ts +44 -0
  404. package/src/segments/handlers/itineraryEcho.ts +45 -0
  405. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  406. package/src/segments/handlers/segment.ts +111 -0
  407. package/src/segments/handlers/segmentEdit.ts +1341 -0
  408. package/src/segments/handlers/segmentGroups.ts +347 -0
  409. package/src/segments/handlers/segmentStructure.ts +1144 -0
  410. package/src/segments/rules/chain.ts +196 -0
  411. package/src/segments/rules/chainModel.ts +217 -0
  412. package/src/segments/rules/colors.ts +11 -0
  413. package/src/segments/rules/commit.ts +76 -0
  414. package/src/segments/rules/draft.ts +90 -0
  415. package/src/segments/rules/draftDisposition.ts +43 -0
  416. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  417. package/src/segments/rules/engine.ts +222 -0
  418. package/src/segments/rules/groupSave.ts +234 -0
  419. package/src/segments/rules/hazardPrompt.ts +60 -0
  420. package/src/segments/rules/itineraryEcho.ts +40 -0
  421. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  422. package/src/segments/rules/merge.ts +51 -0
  423. package/src/segments/rules/metrics.ts +456 -0
  424. package/src/segments/rules/naming.ts +168 -0
  425. package/src/segments/rules/segmentArming.ts +144 -0
  426. package/src/segments/rules/splitPick.ts +84 -0
  427. package/src/segments/rules/viaSimplify.ts +230 -0
  428. package/src/segments/stores/directions.ts +77 -0
  429. package/src/segments/stores/roadAccessDialog.ts +58 -0
  430. package/src/segments/stores/segmentEdit.ts +922 -0
  431. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  432. package/src/segments/stores/segmentSplit.ts +77 -0
  433. package/src/share/contracts/share.ts +39 -0
  434. package/src/share/contracts/shareLink.ts +63 -0
  435. package/src/share/engines/shareLink.ts +1053 -0
  436. package/src/share/handlers/share.ts +47 -0
  437. package/src/share/handlers/shareLink.ts +231 -0
  438. package/src/share/handlers/shareScope.ts +54 -0
  439. package/src/share/rules/link.ts +89 -0
  440. package/src/share/rules/shareLink.ts +218 -0
  441. package/src/share/rules/targets.ts +92 -0
  442. package/src/share/rules/viewConfig.ts +95 -0
  443. package/src/share/stores/share.ts +58 -0
  444. package/src/strings/fr/index.ts +18 -0
  445. package/src/strings/fr/rules/fr.ts +2368 -0
  446. package/src/strings/index.ts +98 -0
  447. package/src/strings/rules/confirmCopy.ts +156 -0
  448. package/src/strings/rules/draftToolNames.ts +94 -0
  449. package/src/strings/rules/en.ts +2519 -0
  450. package/src/strings/rules/failureAlert.ts +115 -0
  451. package/src/strings/rules/formError.ts +400 -0
  452. package/src/strings/rules/maneuvers.ts +107 -0
  453. package/src/strings/rules/outputOptions.ts +126 -0
  454. package/src/strings/rules/publicationState.ts +100 -0
  455. package/src/strings/rules/routeHazardCopy.ts +62 -0
  456. package/src/strings/rules/searchLabels.ts +50 -0
  457. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  458. package/src/strings/rules/studioCopy.ts +130 -0
  459. package/src/strings/rules/unitOptions.ts +119 -0
  460. package/src/testing/checkedBus.ts +226 -0
  461. package/src/testing/index.ts +34 -0
  462. package/src/testing/plugins.ts +106 -0
  463. package/src/testing/studio.ts +267 -0
  464. package/src/testing/urlSeam.ts +153 -0
  465. package/src/time/index.ts +12 -0
  466. package/src/time/rules/sun.ts +78 -0
  467. package/src/video/contracts/cameraSchemas.ts +266 -0
  468. package/src/video/contracts/profileSchemas.ts +37 -0
  469. package/src/video/contracts/video.ts +601 -0
  470. package/src/video/handlers/video.ts +1638 -0
  471. package/src/video/handlers/videoDirector.ts +114 -0
  472. package/src/video/rules/previewRefresh.ts +76 -0
  473. package/src/video/rules/profileSource.ts +51 -0
  474. package/src/video/rules/routeSpans.ts +79 -0
  475. package/src/video/rules/shotDefaults.ts +28 -0
  476. package/src/video/rules/stepOrder.ts +17 -0
  477. package/src/video/rules/videoSnapshot.ts +136 -0
  478. package/src/video/stores/directorThreads.ts +167 -0
  479. package/src/video/stores/videoExport.ts +290 -0
  480. package/src/viewer/contracts/preferences.ts +40 -0
  481. package/src/viewer/handlers/preferences.ts +91 -0
  482. package/src/viewer/rules/capabilities.ts +42 -0
  483. package/src/viewer/rules/config.ts +266 -0
  484. package/src/viewer/rules/context.ts +375 -0
  485. package/src/viewer/rules/ownership.ts +134 -0
  486. package/src/viewer/rules/platformViewer.ts +198 -0
  487. package/src/viewer/rules/scope.ts +197 -0
  488. package/src/viewer/rules/url.ts +145 -0
  489. package/src/viewer/rules/viewer.ts +307 -0
  490. package/src/viewer/rules/viewerSeam.ts +49 -0
  491. package/src/viewer/rules/viewerUnits.ts +34 -0
  492. package/src/waypoints/contracts/itinerary.ts +417 -0
  493. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  494. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  495. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  496. package/src/waypoints/rules/amenities.ts +30 -0
  497. package/src/waypoints/rules/defaults.ts +31 -0
  498. package/src/waypoints/rules/details.ts +213 -0
  499. package/src/waypoints/rules/detailsDraft.ts +312 -0
  500. package/src/waypoints/rules/detailsPreview.ts +76 -0
  501. package/src/waypoints/rules/detailsSave.ts +356 -0
  502. package/src/waypoints/rules/draftDirty.ts +45 -0
  503. package/src/waypoints/rules/icons.ts +32 -0
  504. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  505. package/src/waypoints/rules/naming.ts +185 -0
  506. package/src/waypoints/rules/sections.ts +77 -0
  507. package/src/waypoints/rules/waypointDraft.ts +62 -0
  508. package/src/waypoints/stores/waypointDetails.ts +62 -0
  509. package/src/waypoints/stores/waypointEdit.ts +566 -0
  510. package/src/zones/contracts/collection.ts +37 -0
  511. package/src/zones/contracts/zone.ts +528 -0
  512. package/src/zones/engines/zoneForm.ts +1773 -0
  513. package/src/zones/handlers/restZones.ts +287 -0
  514. package/src/zones/handlers/zonePublish.ts +206 -0
  515. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  516. package/src/zones/handlers/zones.ts +2254 -0
  517. package/src/zones/rules/geometry.ts +946 -0
  518. package/src/zones/rules/zoneDefaults.ts +34 -0
  519. package/src/zones/rules/zoneDraft.ts +54 -0
  520. package/src/zones/rules/zoneForm.ts +563 -0
  521. package/src/zones/rules/zoneMetadata.ts +29 -0
  522. package/src/zones/rules/zoneSource.ts +87 -0
  523. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  524. package/src/zones/stores/zoneEdit.ts +998 -0
@@ -0,0 +1,2216 @@
1
+ import { ItineraryWithDetails, ItinerarySegment, SegmentEditMode } from '@mountaya/elements/data';
2
+ import { BoundingBox, MapClient, FitBoundsPadding } from '@mountaya/elements/map-client';
3
+ import { EmbedProfileSections, ElevationPoint } from '@mountaya/elements/profile';
4
+ import { EmbedCanvasSize, EmbedZoomRange, ZoneFormFields } from '../index.js';
5
+ import { Clock } from '@mountaya/elements/seams';
6
+ import { ReadyMessage, ItinerarySurface, UiStoreApi, StudioToolInputs, StudioToolOutputs, ZoneCreateMethod } from '../index.js';
7
+ import { RestSchema, ItineraryPaceSegment, Mountaya } from '@mountaya/client';
8
+ import { ToolBusDispatch, ToolBusContext, CategoryActivities, ToolResultOf, ToolFailure } from '../index.js';
9
+ import { StudioStrings } from '../strings/index.js';
10
+ export { S as ShareLinkActionOutcome, a as ShareLinkConfig, b as ShareLinkDispatch, c as ShareLinkEngine, d as ShareLinkEngineOptions, e as ShareLinkFailure, f as ShareLinkRead, g as ShareLinkReadResult, h as ShareLinkSnapshot } from '../shareLink-C7rIMb7x.js';
11
+ import { MapLanguage } from '@mountaya/elements/i18n';
12
+ import { StudioIds } from '../seams/index.js';
13
+ import 'zod';
14
+ import '@mountaya/elements/camera';
15
+ import 'geojson';
16
+ import 'zustand/vanilla';
17
+ import '@mountaya/elements/errors';
18
+ import '../shareLink-B6hlt942.js';
19
+
20
+ /**
21
+ * EmbedFramingCollection is a collection an embed frames: its id, and the extent of the
22
+ * itineraries its tiles draw, as the collection's specification states it (`bbox`).
23
+ */
24
+ interface EmbedFramingCollection {
25
+ /**
26
+ * The extent, `[west, south, east, north]`: the box the collection's specification answers for
27
+ * the credential and the surface its tiles are asked with.
28
+ */
29
+ readonly bounds: BoundingBox;
30
+ /** The collection's id, which tells one collection's framing from the next one's. */
31
+ readonly id: string;
32
+ }
33
+ /**
34
+ * EmbedFramingConfig is what an embed's initial framing runs against, all of it replaceable
35
+ * mid-life through {@link EmbedFramingEngine.configure}.
36
+ */
37
+ interface EmbedFramingConfig {
38
+ /**
39
+ * The size of the map's canvas, or null while it is unmeasured: the size a fit frames. It
40
+ * sizes the pan lock from the view the embed opens on (see `embedConstraintsFor`). A change
41
+ * while a fit is on its way frames again with it, except a change to a canvas that measures
42
+ * nothing (null, or no area): there is nothing to frame on one, so the fit on its way stands,
43
+ * and a canvas that comes back at the size it had asks nothing new. Another input that changes
44
+ * while the canvas measures nothing is a question of its own: under no size at all it is
45
+ * framed as it stands, and under a canvas with no area no fit starts for it, so the canvas that
46
+ * comes back is the one framed. The fit on its way then settles nothing if it lands first: it
47
+ * framed the inputs as they were. A change that can start no fit (after the settle, under a
48
+ * publisher's own view, or while the next itinerary loads) moves no camera: the pan lock alone
49
+ * is widened for a canvas that outgrew it, and it is never tightened for one that shrank.
50
+ *
51
+ * An embed that opens on a canvas with no area, a frame the page has laid out and not shown,
52
+ * starts no fit and settles nothing: a renderer gives such a container a canvas of its own
53
+ * default size, and a fit would frame that. The organization's zoom range applies at once, and
54
+ * the itinerary is framed in the first canvas with an area. Null is another statement: a host
55
+ * that measures no canvas at all is framed at once, as it stands.
56
+ *
57
+ * WHEN a host hands a size over decides what the renderer makes of it, and the two uses want
58
+ * opposite orders. A fit frames the canvas the renderer holds, so a size that frames again is
59
+ * handed over once the renderer has resized: earlier, the fit frames the canvas as it was. The
60
+ * renderer enforces the lock as IT resizes, so a size that widens a lock is handed over before
61
+ * the renderer has resized: later, the lock is widened under a camera the renderer has
62
+ * already zoomed in. One size cannot arrive at both moments. A host that learns a size ahead
63
+ * of the renderer states it as {@link EmbedFramingConfig.lockCanvasSize}, and states it here
64
+ * once the renderer has resized to it.
65
+ */
66
+ readonly canvasSize: EmbedCanvasSize | null;
67
+ /**
68
+ * The map client the embed frames and locks, or null while there is no map, in which case
69
+ * nothing is framed.
70
+ *
71
+ * Required even so, because an engine without a client is silent: a key the caller has to write
72
+ * makes forgetting it a compile error rather than an embed that never frames. Compared by
73
+ * identity: a replaced client is framed and locked afresh.
74
+ */
75
+ readonly client: MapClient | null;
76
+ /**
77
+ * The collection the embed frames while no itinerary is active or expected, or null when there
78
+ * is none to frame: no collection is configured, its specification has not answered, or it
79
+ * answered no extent (a `bbox` that is null or absent, since its tiles draw no itinerary). An
80
+ * itinerary wins over it: while one is active or expected, the collection is not framed.
81
+ *
82
+ * It is framed as an itinerary is, through `fitCollection`, with the same padding and the same
83
+ * zoom ceiling, and once: a collection that stays the one stated is not framed again after its
84
+ * view settled, whatever extent a later answer states. A content switch to another collection,
85
+ * or back to the same one after an itinerary, is framed in its turn. Compared by value: the id
86
+ * and the four edges.
87
+ *
88
+ * Read only with `fitCollection` stated: a configuration that states none frames no collection.
89
+ *
90
+ * @default No collection: the embed frames an itinerary, or the base map alone.
91
+ */
92
+ readonly collection?: EmbedFramingCollection | null | undefined;
93
+ /**
94
+ * The id of the itinerary the embed is configured with, or null for an embed of the base map
95
+ * alone. A change of it while no itinerary is active is a content switch owed one settle,
96
+ * whatever `expectsItinerary` says: the base map's, on its next paint, when no itinerary is
97
+ * expected, and otherwise the settle the expectation ends on, the itinerary's framing or the
98
+ * base map's. So a host that already holds the failure of the itinerary it switches to, and
99
+ * never expects one, still hears how the switch ended. A change made while the base map's
100
+ * settle is on its way shares that settle. While an itinerary is active the switch is read off
101
+ * `itinerary`, and a change here settles nothing by itself.
102
+ *
103
+ * The id's change and `expectsItinerary` each signal a switch, and they are one settle only
104
+ * when one configure brings both. An expectation that rises in a later configure, once the
105
+ * base map has started to settle for the id's change, is a wait of its own and is owed its own
106
+ * settle: a host whose data layer shows the failure it holds and then fetches again hears a
107
+ * report for each, the first of them possibly while the itinerary is expected. Such a host
108
+ * raises `expectsItinerary` in the configure that brings the id.
109
+ *
110
+ * @default No id is stated: a content switch is read off `itinerary` and `expectsItinerary`
111
+ * alone, so one that changes neither settles nothing.
112
+ */
113
+ readonly configuredItineraryId?: string | null | undefined;
114
+ /**
115
+ * Whether a collection will frame this embed: one is configured and its specification has not
116
+ * answered yet. While it holds and nothing is framed, the settle waits for the collection as it
117
+ * waits for an expected itinerary (see `expectsItinerary`), except on the cold load of a map a
118
+ * publisher's own view frames. An expectation that ends with no collection to frame (the read
119
+ * failed, or it answered no extent) settles the base map again, so a host hears how it ended.
120
+ *
121
+ * Read only with `fitCollection` stated.
122
+ *
123
+ * @default false
124
+ */
125
+ readonly expectsCollection?: boolean | undefined;
126
+ /**
127
+ * Whether an itinerary will frame this embed: one is configured and its detail has not failed to
128
+ * load. While it holds and no itinerary is active, the settle waits for one, except on the cold
129
+ * load of a map a publisher's own view frames; otherwise the view settles on the map's next
130
+ * paint. An expectation that ends with no itinerary (its detail failed to load) settles the base
131
+ * map again, so a host hears how the switch ended.
132
+ *
133
+ * A flag the host states rather than one read off the active itinerary, so the moment between
134
+ * the itinerary's detail arriving and the store activating it never settles an off-route view.
135
+ */
136
+ readonly expectsItinerary: boolean;
137
+ /**
138
+ * Frames the whole active itinerary with `padding`, at once rather than animated, so the first
139
+ * painted frame is already the route. It goes through the bus in a studio
140
+ * (`studio.map.fitBoundsToSegment` with a null segment), the one camera mutation surface, and
141
+ * resolves once the camera has moved. Read when a framing starts.
142
+ */
143
+ readonly fit: (padding: FitBoundsPadding) => Promise<void>;
144
+ /**
145
+ * Frames `bounds`, the collection's extent, with `padding` and no closer than `maxZoom`, at once
146
+ * rather than animated: the collection's twin of `fit`, under the zoom ceiling an itinerary's
147
+ * fit holds. It goes through the bus in a studio (`studio.map.fitBounds` with `animate: false`),
148
+ * and resolves once the camera has moved. Read when a framing of the collection starts.
149
+ *
150
+ * @default No collection is framed: `collection` and `expectsCollection` are read as absent.
151
+ */
152
+ readonly fitCollection?: ((bounds: BoundingBox, padding: FitBoundsPadding, maxZoom: number) => Promise<void>) | undefined;
153
+ /** The itinerary the store has active, or null while none is. */
154
+ readonly itinerary: ItineraryWithDetails | null;
155
+ /**
156
+ * The size the page has laid the canvas out at, or null while it is unmeasured, for a host
157
+ * that learns it before the renderer has resized to it. The pan lock is widened from it and no
158
+ * fit ever frames it: the lock covers the wider and the taller of this size and `canvasSize`,
159
+ * so the renderer resizes inside a lock already sized for the canvas it grows to.
160
+ *
161
+ * While it measures a canvas `canvasSize` does not state, a resize is under way: the renderer
162
+ * has yet to resize, and `canvasSize` has yet to follow. A fit asked for then would frame the
163
+ * canvas as it was, so none starts, and one already on its way settles nothing when it
164
+ * paints. The framing runs once the two sizes agree, on the canvas the renderer holds by then,
165
+ * so the view settles on the fit of the last canvas. A host that states this size therefore
166
+ * states the same one as `canvasSize` once the renderer has resized, or a fitted itinerary
167
+ * never settles: the organization's zoom range and the lock of the last framing are all that
168
+ * stand on the map meanwhile. Under a publisher's own view no fit reads the canvas, and nothing
169
+ * waits.
170
+ *
171
+ * @default The size `canvasSize` states: the pan lock is widened when `canvasSize` changes,
172
+ * and no resize is ever under way.
173
+ */
174
+ readonly lockCanvasSize?: EmbedCanvasSize | null | undefined;
175
+ /**
176
+ * The docked elevation profile's measured height, in CSS pixels, or null before it is measured
177
+ * or when no profile is docked. It sizes the fit's bottom inset (`embedFitPadding`), and a change
178
+ * before the framing has settled frames again with it.
179
+ */
180
+ readonly measuredPanelHeight: number | null;
181
+ /**
182
+ * Receives each settle of the initial view, framed on the `[west, south, east, north]` extent
183
+ * of the itinerary or the collection that frames it, or null when neither does. An embed lifts
184
+ * its loading cover and posts its ready event from it (see `EmbedReadyEngine`). Read when a
185
+ * framing settles. One that throws stops nothing: the settle stands, and its fault reaches the
186
+ * program as an uncaught error on a microtask.
187
+ */
188
+ readonly onFramed?: ((bounds: BoundingBox | null) => void) | undefined;
189
+ /** The profile sections the embed docks, which size the fit's bottom inset. */
190
+ readonly sections: EmbedProfileSections;
191
+ /**
192
+ * The organization's zoom range. One that changes, or first arrives, is applied at once,
193
+ * whatever stands on the map: with the next framing, or over the framing that stands, at the
194
+ * floor that framing lowered and with no fit. One that leaves is released the same way: a
195
+ * configuration that states no range over a map this engine wrote one to hands the map a null
196
+ * for each end, which gives it back its own window.
197
+ */
198
+ readonly zoomRange: EmbedZoomRange;
199
+ }
200
+ /**
201
+ * EmbedFramingSnapshot is what an {@link EmbedFramingEngine} answers: whether the initial view of
202
+ * what the embed frames (the active itinerary, the collection, or the base map alone) has
203
+ * settled, and on what.
204
+ *
205
+ * It names what it answers for, so a reader holding a snapshot never takes one content's framing
206
+ * for the next one's: after a content switch it reads unframed, under the new id, until the new
207
+ * framing settles. Both ids are null for the base map alone.
208
+ */
209
+ interface EmbedFramingSnapshot {
210
+ /**
211
+ * The extent the view was framed on, the itinerary's or the collection's, or null while
212
+ * unframed or with none to frame.
213
+ */
214
+ readonly bounds: BoundingBox | null;
215
+ /** The collection the answer is for: the one framed while no itinerary is, or null. */
216
+ readonly collectionId: string | null;
217
+ /**
218
+ * Whether the initial view has painted: after the framing fit or, with no fit to wait for, on
219
+ * the map's next paint.
220
+ */
221
+ readonly framed: boolean;
222
+ /** The itinerary the answer is for: the active one, or null while none is. */
223
+ readonly itineraryId: string | null;
224
+ }
225
+ /**
226
+ * EmbedFramingEngine is the machine behind an embed's initial framing: it frames the active
227
+ * itinerary, or the collection an embed of one is configured with, locks the camera to it, and
228
+ * reports when the initial view has painted, so the embed's loading cover never shows a visitor
229
+ * the map's default, off-route centre.
230
+ *
231
+ * A collection is framed as an itinerary is. While no itinerary is active or expected, the
232
+ * collection's extent (`collection`, the `bbox` its specification answers) is what the embed
233
+ * frames: fitted through `fitCollection` with the same padding and under the same zoom ceiling,
234
+ * locked to, deferred to a publisher's own view, and reported on its extent, once per
235
+ * collection. While its specification has not answered (`expectsCollection`) the settle waits for
236
+ * it, and an answer with no extent leaves the base map alone, which settles as it does with
237
+ * nothing to frame. What follows says "itinerary" for either, a content switch included, except
238
+ * where `configuredItineraryId` and a failed detail are concerned, which are the itinerary's own.
239
+ *
240
+ * What it does, in the order a cold load meets it:
241
+ *
242
+ * - **Constraints.** As soon as a client is set, the organization's zoom range is applied; once
243
+ * the itinerary is active, the pan lock too, both decided by `embedConstraintsFor` and handed to
244
+ * `client.setConstraints` in one call. Constraints that already stand on the map as decided
245
+ * are not written again, so a step that decides nothing new costs the renderer nothing.
246
+ * - **Framing.** The whole itinerary is framed through `fit`, with the profile-aware padding
247
+ * `embedFitPadding` sizes to the docked profile, unless the map was built with a publisher's own
248
+ * `#view` (`client.hadInitialViewHash()`), which the embed defers to. The camera the fit lands on
249
+ * (`client.cameraForBounds` under the same ceiling, `ITINERARY_FIT_MAX_ZOOM`) lowers the zoom
250
+ * floor for a short viewport and sizes the pan lock. Under a publisher's own view the lock is
251
+ * sized from the camera the map shows (`client.getViewport()`) and the itinerary together, so it
252
+ * never zooms that view in.
253
+ * - **The settle.** The view has settled on the first render after the fit
254
+ * (`client.waitForRender()`), not merely once the fit is dispatched, so the cover lifts on the
255
+ * painted framing. With nothing to fit (an embed of the base map alone, an itinerary that failed
256
+ * to load, a publisher's own view) it settles on the map's next render instead. Each settle is
257
+ * reported once, through `onFramed` and the snapshot.
258
+ *
259
+ * The framing is the INITIAL view only. Before it settles, a change to what it is decided from (a
260
+ * measured profile height, a measured canvas, the itinerary's detail arriving again) frames again
261
+ * and the earlier fit's settle is dropped, so the cover lifts on the final framing. After it
262
+ * settles, nothing reframes that itinerary while it stays active, so a visitor's own pan, tilt or
263
+ * zoom is never pulled back to the route.
264
+ *
265
+ * The pan lock grows with the canvas for as long as it stands. A canvas that grows after the
266
+ * settle, at any moment under a publisher's own view, or while the next itinerary loads under
267
+ * the lock of the outgoing one, shows more ground at the same camera, so the lock alone is
268
+ * applied again, sized from the same camera on the larger canvas: no fit, no report, and the
269
+ * zoom range is left as the framing set it. It never shrinks back: a lock tightened ahead of the
270
+ * renderer's own resize would be narrower than the canvas the renderer still holds, and zoom the
271
+ * camera in. See {@link EmbedFramingConfig.canvasSize} for when a host hands the size over.
272
+ *
273
+ * That is a choice, and it has two costs. A reader of a frame that left full screen keeps the
274
+ * full screen's lock, so they can pan and zoom out as far as it allowed: tightening it would
275
+ * take a second step once the renderer has resized, and a lock looser than the canvas harms
276
+ * nothing. And under a publisher's own view, a host that measures its canvas after the first
277
+ * step gets the bare route's lock until the size arrives, which can zoom that view in for a
278
+ * moment: such a host states the size with the client, as `MountayaStudioViewer` does.
279
+ *
280
+ * The zoom range follows the configuration for as long as a framing stands. One that changes, or
281
+ * first arrives, after the settle is applied over the standing framing, decided by
282
+ * `embedConstraintsFor` from that framing's own inputs: the ceiling as stated and the floor no
283
+ * higher than the zoom the fit landed on. No fit runs and nothing is reported, so a visitor's
284
+ * camera is moved only when the new floor is above it, and then only up to that floor, which is
285
+ * where the embed would have opened under the same range. The same holds while the next
286
+ * itinerary loads under the outgoing framing.
287
+ *
288
+ * A host that learns of a resize before the renderer states two sizes: `lockCanvasSize`, the
289
+ * canvas the page has laid out, and `canvasSize`, the one the renderer holds. While the first
290
+ * measures a canvas the second does not state, the renderer has yet to resize, and the two uses
291
+ * of a size part ways. The lock is widened for the size ahead at once, whatever stands on the
292
+ * map, the lock of a fit still on its way included, so the renderer never resizes under a lock
293
+ * narrower than its canvas. A fit waits: none starts, and one that paints meanwhile settles
294
+ * nothing, since it framed a canvas that is gone. The zoom range does not wait with it: on a
295
+ * client nothing was framed on it applies at once, as it does while an itinerary loads. The
296
+ * framing runs in full once the two sizes agree, so a burst of resizes ends on one fit, of the
297
+ * last canvas, and that fit is the settle reported. A view no fit moves waits for nothing.
298
+ *
299
+ * A content switch starts over, whichever way the view settles: another active itinerary, or the
300
+ * same one activated again after it was cleared, is framed, locked and reported in its turn. A
301
+ * settle on its way for an itinerary that is switched away from, or cleared, before it painted is
302
+ * dropped, so a report never names an itinerary that is no longer active, and so is the base
303
+ * map's for an itinerary activated before it painted: a switch is one report, whichever drawing
304
+ * lands first. A replaced client starts over too, subscribed to or not. The snapshot is the
305
+ * record: it reads unframed from the switch until that settle.
306
+ *
307
+ * What stands between two itineraries depends on whether another one is expected:
308
+ *
309
+ * - **One is.** The constraints of the last framing stay until the next framing replaces them,
310
+ * and the pan lock among them still follows the canvas. Putting the organization's zoom floor
311
+ * back under a view framed below it would make the renderer zoom the camera in for the length
312
+ * of a load, and under a publisher's own view no fit follows the load to put right a camera
313
+ * zoomed in by a lock the canvas outgrew.
314
+ * - **None is.** The embed is the base map alone: the pan lock is released (a null `maxBounds`,
315
+ * as it is for a next itinerary with no extent to lock to), the organization's zoom range
316
+ * applies as it is, and the view settles again, to be reported.
317
+ * That holds for an itinerary that was cleared and for one that never came: a base-map embed
318
+ * switched to an itinerary whose detail fails to load settles on the base map once more, which
319
+ * is the settle a host hears `"not_found"` from. A switch to an itinerary whose failure the
320
+ * host already holds changes neither `itinerary` nor `expectsItinerary`, so it is read off
321
+ * `configuredItineraryId`: a change of it with no itinerary active and none expected settles
322
+ * the base map once more. The id's change and an expectation each signal a switch, and they
323
+ * are one settle only when one configure brings both (see
324
+ * {@link EmbedFramingConfig.configuredItineraryId}).
325
+ *
326
+ * Under a publisher's own view no fit will move the camera, so the cold load does not wait for the
327
+ * itinerary: the first settle on a client is the map's next render, whatever is active then. While
328
+ * the itinerary's detail is still loading that is the base map, reported with null bounds, and
329
+ * the itinerary settles in its turn, on its own extent, once it is active; an itinerary active
330
+ * before that first render lands takes its place, so the two are reported as one settle. After
331
+ * that first settle a content switch waits for its itinerary, as a fitted one does, so the
332
+ * switch is reported on its itinerary and not on the base map first.
333
+ *
334
+ * It reads the itinerary and the collection it is handed and never writes a store: the camera
335
+ * moves through `fit` and `fitCollection` and the constraints through the client, so the tool bus
336
+ * stays the one mutation surface.
337
+ *
338
+ * It holds no timer and takes no `Clock`: it waits on the map's own paint, never on time.
339
+ *
340
+ * A host's `onFramed` that throws, and a listener that throws, stop neither the engine nor the
341
+ * listeners after it: the settle is the engine's to complete, and a throw left to travel would
342
+ * surface as an unhandled rejection from the paint the settle waited on, or as a `configure`
343
+ * that failed. The fault leaves through `surfaceFault` and `notifyListeners`: an uncaught error
344
+ * on a microtask, for the program that handed the callback over.
345
+ *
346
+ * The lifecycle is the listeners. Constructing one touches no client; the first subscriber frames
347
+ * the current configuration; the last unsubscribe parks: a settle that arrives while parked is
348
+ * dropped, with or without a fit, and the next subscriber settles again what it left unsettled.
349
+ * React's StrictMode mounts, unmounts and mounts again before a fit can settle, which parks and
350
+ * resumes and leaves one fit in flight and one settle. `dispose()` is the latch, for an owner that
351
+ * is not a component.
352
+ *
353
+ * @example
354
+ * ```ts
355
+ * declare const client: MapClient;
356
+ * declare const ready: EmbedReadyEngine;
357
+ *
358
+ * const framing = new EmbedFramingEngine({
359
+ * canvasSize: { height: 480, width: 800 },
360
+ * client,
361
+ * expectsItinerary: true,
362
+ * fit: (padding) =>
363
+ * bus
364
+ * .dispatch(ctx, "studio.map.fitBoundsToSegment", { animate: false, padding, segmentId: null })
365
+ * .then(() => undefined),
366
+ * itinerary: store.getState().activeItinerary,
367
+ * measuredPanelHeight: null,
368
+ * onFramed: (bounds) => ready.settle(bounds),
369
+ * sections: { showAnalysis: true, showCharacteristics: true, showElevation: true },
370
+ * zoomRange: { zoomMax: 14, zoomMin: 9 },
371
+ * });
372
+ * const release = framing.subscribe(() => undefined);
373
+ * ```
374
+ */
375
+ declare class EmbedFramingEngine {
376
+ private config;
377
+ private snapshot;
378
+ private readonly listeners;
379
+ /** The client the framing below was made on; a replaced one starts from nothing. */
380
+ private framingClient;
381
+ /** The question the last framing step answered, or null when the next step must run in full. */
382
+ private asked;
383
+ /** The fit waiting for its paint, or null. */
384
+ private pendingFit;
385
+ /** The settle with no fit waiting for its paint, or null. */
386
+ private pendingReveal;
387
+ /**
388
+ * Whether a settle has been reported on {@link framingClient}. Until one has, a publisher's own
389
+ * view settles without waiting for its itinerary, which is what lifts a cold load's cover.
390
+ */
391
+ private reported;
392
+ /**
393
+ * The constraints the last itinerary or collection framed on {@link framingClient} left
394
+ * standing, or null.
395
+ */
396
+ private standing;
397
+ /**
398
+ * Every constraint written to {@link framingClient}, each member as it was written last. A
399
+ * member never written is absent, so the first write of anything is news.
400
+ */
401
+ private applied;
402
+ /**
403
+ * Whether a pan lock stands on {@link framingClient}. The next constraints that decide no lock
404
+ * (the base map alone, an itinerary with no extent) release it.
405
+ */
406
+ private locked;
407
+ /**
408
+ * Whether a content switch made with nothing framed is still unanswered: an itinerary or a
409
+ * collection is, or was, expected, or the configured id changed, and since then nothing was
410
+ * framed and the base map alone was not set to settle again. A switch that ends with nothing to
411
+ * frame settles the base map again. Answered when that settle starts, not when it paints, so an
412
+ * expectation that rises after it is a wait of its own, owed its own settle.
413
+ */
414
+ private awaited;
415
+ /** The configured itinerary's id as last stated, or undefined when it was left out. */
416
+ private configuredId;
417
+ /** Whether nobody is watching. A parked engine frames nothing and reports nothing. */
418
+ private parked;
419
+ private disposed;
420
+ /**
421
+ * Constructing one holds the configuration and does nothing else: no client is read, framed or
422
+ * constrained. A React binding constructs during a render React is free to throw away, and a
423
+ * constructor with a side effect would leave the discarded copy framing.
424
+ */
425
+ constructor(config: EmbedFramingConfig);
426
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
427
+ getSnapshot(): EmbedFramingSnapshot;
428
+ /**
429
+ * subscribe registers a listener for every change of the snapshot, and returns its own
430
+ * unsubscribe, which is idempotent.
431
+ *
432
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
433
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
434
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
435
+ * dead engine.
436
+ */
437
+ subscribe(listener: () => void): () => void;
438
+ /**
439
+ * configure replaces the configuration, and frames again only when what a framing is decided
440
+ * from changed.
441
+ *
442
+ * A binding calls it after every render, so it compares the inputs a framing reads (the client
443
+ * and the itinerary by identity, the rest by value) and does nothing more when they are
444
+ * unchanged: `fit`, `fitCollection` and `onFramed` are read when they are used, so a fresh
445
+ * closure per render costs nothing. Parked or not, the snapshot answers for the new content,
446
+ * and for a replaced client, before this returns: unframed, under the active id, until its
447
+ * framing settles. Only the framing waits for a subscriber.
448
+ */
449
+ configure(config: EmbedFramingConfig): void;
450
+ /**
451
+ * dispose parks the engine and drops every listener, for good: a settle still on its way reports
452
+ * nothing.
453
+ *
454
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
455
+ * mid-load should not have to guard the calls it already queued.
456
+ */
457
+ dispose(): void;
458
+ /**
459
+ * step brings the framing in line with the configuration. It runs in full only when the question
460
+ * changed since the last step, when the active itinerary did, or when work the last one started
461
+ * was dropped while parked.
462
+ */
463
+ private step;
464
+ /**
465
+ * whileFitting answers `question` as the fit on its way was asked it, when the canvas has since
466
+ * gone to nothing: neither size the configuration states measures anything (see
467
+ * `measuredCanvas`). A canvas with no area has nothing to frame, so it asks nothing new, the fit
468
+ * on its way stands, and a canvas that comes back at the size that fit was asked for is the
469
+ * question already answered. With no fit on its way, or while either size still measures
470
+ * something, the question is the configuration's own.
471
+ *
472
+ * It is read to compare and never to record: another input that changes while the canvas
473
+ * measures nothing is a question of its own, recorded with the sizes the configuration states.
474
+ * It starts no fit while the page has laid the canvas out at no area (see {@link unlaid}), so
475
+ * the canvas that comes back is the one framed for it.
476
+ */
477
+ private whileFitting;
478
+ /**
479
+ * restart forgets every framing made on the previous client, so a replaced client (or the map
480
+ * arriving) frames and locks from nothing. A settle still on its way for the previous client is
481
+ * dropped.
482
+ */
483
+ private restart;
484
+ /** frame runs one framing step for `question` on `client`. */
485
+ private frame;
486
+ /**
487
+ * resizing reports whether the page has laid the canvas out at a size the renderer has yet to
488
+ * resize to: `lockCanvasSize` measures a canvas `canvasSize` does not state. Never with no
489
+ * `lockCanvasSize`, and never while it measures nothing.
490
+ */
491
+ private resizing;
492
+ /**
493
+ * unlaid reports whether the page has laid the canvas out at no area: no size the
494
+ * configuration states measures anything, and one of them, `canvasSize` or `lockCanvasSize`,
495
+ * states a layout with no area (see {@link laidOutAtNoArea}). An embed mounted in a frame
496
+ * nobody is shown yet reads so. Never for a host that states no size at all, or one that is
497
+ * not a number: neither is a layout, and the embed is framed as it stands.
498
+ *
499
+ * A renderer gives a container with no area a canvas of its own default size, so a fit asked
500
+ * for now would frame a canvas nobody sees, and its settle would report a view the reader is
501
+ * never shown.
502
+ */
503
+ private unlaid;
504
+ /**
505
+ * awaitResize runs the framing step for an itinerary a fit frames while there is no canvas to
506
+ * frame yet: the page has laid it out at no area (see {@link unlaid}), or the renderer has yet
507
+ * to resize to it (see {@link resizing}). It starts no fit, since one asked for now would
508
+ * frame the canvas as it was, and it leaves a fit already on its way in flight. The step that
509
+ * finds a canvas with an area, at a size the two agree on, frames in full, and the fit it
510
+ * starts replaces that one.
511
+ *
512
+ * What stands on the client meanwhile is what {@link awaitContent} leaves there. The pan lock
513
+ * of the last framing, this itinerary's or the outgoing one's, is widened for the size ahead
514
+ * (see {@link lockAgain}), so the renderer resizes inside it. On a client nothing was framed
515
+ * on, the organization's zoom range applies at once: it reads no canvas, so it has nothing to
516
+ * wait for, and a host whose two sizes never agree is not left with a map no range holds.
517
+ */
518
+ private awaitResize;
519
+ /**
520
+ * awaitContent runs the framing step for an itinerary or a collection that is expected and not
521
+ * framed yet: the itinerary's detail is loading, a content switch cleared the outgoing one
522
+ * first, or the collection's specification has not answered.
523
+ *
524
+ * The constraints of the last itinerary or collection framed on this client stay until the next
525
+ * framing replaces them, the zoom floor that framing lowered included; the pan lock among them
526
+ * still follows a canvas that outgrows it (see {@link lockAgain}). On a client nothing was
527
+ * framed on, the organization's zoom range applies at once.
528
+ */
529
+ private awaitContent;
530
+ /**
531
+ * showBaseMap runs the framing step for the base map alone: no itinerary or collection is
532
+ * framed and none is expected. The organization's zoom range applies as it is, the pan lock an
533
+ * itinerary or a collection left standing is released (see {@link constrain}), and the view
534
+ * settles on the map's next render.
535
+ */
536
+ private showBaseMap;
537
+ /** zoomRangeAlone decides the constraints with no itinerary to lock to: the zoom range alone. */
538
+ private zoomRangeAlone;
539
+ /**
540
+ * rangeAgain applies the configuration's zoom range over the framing of `content` when it is not
541
+ * the range that framing was decided from: the same route, camera, canvas and padding, under
542
+ * the range as it is stated now. The zoom range alone, so the pan lock stays as it is and no
543
+ * camera is moved by a fit.
544
+ *
545
+ * The floor is the one a framing under this range would have set, lowered to the zoom the fit
546
+ * landed on, so a range that arrives late leaves the embed where it would have opened. A range
547
+ * that does not state both ends decides no clamp, so the one on the map is released
548
+ * (see {@link rangeRelease}).
549
+ */
550
+ private rangeAgain;
551
+ /**
552
+ * rangeRelease is the constraints that release the zoom range this engine wrote to the client:
553
+ * a null for each end, which hands the map back its own window. Nothing while no range of the
554
+ * engine's stands there, so a map no range was written to is told nothing.
555
+ */
556
+ private rangeRelease;
557
+ /**
558
+ * lockAgain widens the pan lock of the framing of `content` when the canvas has outgrown the one
559
+ * it was sized for: the same route, camera and padding, on a canvas as wide as the widest and as
560
+ * tall as the tallest it has been handed since the framing, as `canvasSize` or as
561
+ * `lockCanvasSize`. The lock alone, so the zoom range stays as the framing set it, and no
562
+ * camera is moved.
563
+ *
564
+ * The lock only grows. The renderer keeps its canvas inside the lock at the size the canvas has
565
+ * when the lock is applied, and a new size is handed over before the renderer resizes: a lock
566
+ * sized for a smaller canvas would be narrower than the one the renderer still holds. A canvas
567
+ * that reads unmeasured changes nothing either.
568
+ */
569
+ private lockAgain;
570
+ /**
571
+ * constrain applies one framing step's constraints, in one call, and only when they decide
572
+ * something.
573
+ *
574
+ * Constraints that decide no pan lock release the one standing, with a null `maxBounds`: there
575
+ * is no route left to hold the camera to, whether the embed is the base map alone or its next
576
+ * itinerary has no extent. Constraints that decide no zoom range release the one standing the
577
+ * same way (see {@link rangeRelease}): the configuration states none any more.
578
+ */
579
+ private constrain;
580
+ /**
581
+ * apply writes `constraints` to the client, unless they decide nothing or every member they
582
+ * state already stands there as stated. A resize under the zoom range alone, and a framing
583
+ * asked again for the inputs it had, decide what the map already holds, and writing it again
584
+ * would have the renderer enforce an unchanged range and lock once more.
585
+ *
586
+ * The set is written whole when any member is news, so a caller's one call stays one call.
587
+ */
588
+ private apply;
589
+ /**
590
+ * revealWithoutFit settles the view on the map's next render, for a view no fit will move: an
591
+ * embed of the base map alone, an itinerary that failed to load, or a publisher's own view.
592
+ *
593
+ * Once for what it answers, `content`: a view already settled for it, or settling, is left
594
+ * alone. A settle on its way for anything else is replaced, since both would wait on the same
595
+ * render and only the active one is worth reporting.
596
+ */
597
+ private revealWithoutFit;
598
+ /**
599
+ * settledFor reports whether the initial view of `content` has settled on the current client.
600
+ * The snapshot is the one record of it: it answers for the active content and reads unframed
601
+ * from a content switch, or a replaced client, until that settle.
602
+ */
603
+ private settledFor;
604
+ /**
605
+ * settle reports one settle: through the snapshot, then to `onFramed`. A settle on its way for
606
+ * anything but the active content is dropped before it lands (see {@link frame}), so the
607
+ * snapshot is written only for the content it answers for, and never goes back to a content
608
+ * the reader has left.
609
+ */
610
+ private settle;
611
+ /** publish shows `snapshot` and tells every listener. */
612
+ private publish;
613
+ }
614
+
615
+ /**
616
+ * EmbedReadyConfig is what an embed's ready events are assembled from, all of it replaceable
617
+ * mid-life through {@link EmbedReadyEngine.configure} and read when an event is posted.
618
+ */
619
+ interface EmbedReadyConfig {
620
+ /** The itinerary the store has active, or null while none is, reported as the settled content. */
621
+ readonly activeItineraryId: string | null;
622
+ /** The store's terrain slug, empty until the display seed has landed. */
623
+ readonly activeTerrain: string;
624
+ /** The embed config's terrain slug, reported while the store's terrain is still empty. */
625
+ readonly configTerrain: string;
626
+ /** The itinerary the embed config asks for, or null for an embed of the base map alone. */
627
+ readonly configuredItineraryId: string | null;
628
+ /**
629
+ * Whether the configured itinerary's detail failed to load, which a settle reports as
630
+ * `"not_found"`: the host asked for content that never resolved.
631
+ */
632
+ readonly itineraryFailed: boolean;
633
+ /**
634
+ * Receives each ready event, everything but the `type` the host bridge stamps on: an embed in an
635
+ * iframe posts it to the parent page. Omitted where nobody listens (a share page), and the cover
636
+ * still lifts. One that throws stops nothing: the cover has lifted by then, and its fault
637
+ * reaches the program as an uncaught error on a microtask.
638
+ */
639
+ readonly onReady?: ((payload: Omit<ReadyMessage, "type">) => void) | undefined;
640
+ }
641
+ /**
642
+ * EmbedReadyEngineOptions is the {@link EmbedReadyConfig} an engine starts with, plus the settings
643
+ * fixed for its life.
644
+ */
645
+ interface EmbedReadyEngineOptions extends EmbedReadyConfig {
646
+ /**
647
+ * Where the deadline's time comes from. The deadline is a duration the product chose rather than
648
+ * a rate, so it waits on the studio's `Clock` seam, and a host that renders an embed frame by
649
+ * frame, or tests one, moves it by hand.
650
+ */
651
+ readonly clock: Clock;
652
+ /**
653
+ * How long the cover waits for the initial view to settle before it lifts anyway, in
654
+ * milliseconds, counted from the first subscriber. When it passes with no settle, the host is
655
+ * told `"timeout"`. A whole or fractional number from 0 to 2,147,483,647, the longest delay a
656
+ * timer honours.
657
+ *
658
+ * @default 8000
659
+ */
660
+ readonly timeoutMs?: number | undefined;
661
+ }
662
+ /** EmbedReadySnapshot is what an {@link EmbedReadyEngine} answers: whether the cover still shows. */
663
+ interface EmbedReadySnapshot {
664
+ /**
665
+ * Whether the loading cover is up: true from the start until the first settle or the deadline,
666
+ * and false for good after either.
667
+ */
668
+ readonly covered: boolean;
669
+ }
670
+ /**
671
+ * EmbedReadyEngine is the machine behind an embed's cold-load cover and its ready handshake with
672
+ * the page that hosts it.
673
+ *
674
+ * The cover is up from the start, so a visitor never sees the map's default, off-route centre
675
+ * before the embed frames its content. It lifts on the first of two things:
676
+ *
677
+ * - **A settle.** {@link EmbedReadyEngine.settle} reports that the initial view has painted,
678
+ * framed on the given bounds (see `EmbedFramingEngine`). The cover lifts and a ready event is
679
+ * posted through `onReady`, assembled by `buildReadyPayload` with the error `resolveFramedError`
680
+ * answers. Every settle posts one, the cold load's and each content switch's alike, so a host
681
+ * learns what settled after every switch.
682
+ * - **The deadline.** `timeoutMs` after the first subscriber with nothing settled, the cover lifts
683
+ * whatever the framing reports, so a stalled tile fetch or a failure the framing cannot observe
684
+ * never leaves a visitor facing an opaque plate, and a ready event with the error `"timeout"` is
685
+ * posted, so a host waiting on the event is never left hanging. A settle drops the deadline, so
686
+ * it never contradicts an event already sent.
687
+ *
688
+ * Once lifted the cover stays down: a content switch reframes under the reader's eyes rather than
689
+ * behind a plate.
690
+ *
691
+ * The configuration is read when an event is posted, so a settle reports the itinerary and the
692
+ * terrain as they stand then. Replacing it never moves the deadline, which is counted from the
693
+ * first subscriber however often the surface re-renders.
694
+ *
695
+ * Time follows the engines' rule: the deadline is a duration the product chose, so it waits on
696
+ * the `clock` option, the studio's `Clock` seam, and never on the runtime's own timer.
697
+ *
698
+ * A host's `onReady` that throws, and a listener that throws, stop neither the engine nor the
699
+ * listeners after it. Each is called from a settle the framing engine reports at the end of a
700
+ * paint's promise, or from the clock's own timer at the deadline, where a throw left to travel
701
+ * would read as that caller's own failure. The fault leaves through `surfaceFault` and
702
+ * `notifyListeners`: an uncaught error on a microtask, for the program that handed the callback
703
+ * over.
704
+ *
705
+ * The lifecycle is the listeners. Constructing one arms nothing; the first subscriber arms the
706
+ * deadline while the cover is up; the last unsubscribe parks: the deadline is dropped, and a
707
+ * settle reported while parked lifts nothing and posts nothing. The next subscriber arms a fresh
708
+ * deadline. React's StrictMode mounts, unmounts and mounts again in one pass, which parks and
709
+ * resumes and leaves one deadline armed. {@link EmbedReadyEngine.dispose} is the latch, for an
710
+ * owner that is not a component.
711
+ *
712
+ * @example
713
+ * ```ts
714
+ * declare function notifyHostPage(payload: Omit<ReadyMessage, "type">): void;
715
+ * declare const cover: { toggle(covered: boolean): void };
716
+ *
717
+ * const ready = new EmbedReadyEngine({
718
+ * activeItineraryId: null,
719
+ * activeTerrain: "",
720
+ * clock: systemClock(),
721
+ * configTerrain: "topo",
722
+ * configuredItineraryId: "itin-1",
723
+ * itineraryFailed: false,
724
+ * onReady: (payload) => notifyHostPage(payload),
725
+ * });
726
+ * const release = ready.subscribe(() => cover.toggle(ready.getSnapshot().covered));
727
+ *
728
+ * ready.settle([6.8, 45.8, 7.1, 46]);
729
+ * release();
730
+ * ```
731
+ */
732
+ declare class EmbedReadyEngine {
733
+ private config;
734
+ private readonly clock;
735
+ private readonly timeoutMs;
736
+ private snapshot;
737
+ private readonly listeners;
738
+ /** The deadline waiting on the clock, or null while none is. */
739
+ private deadline;
740
+ /** Whether nobody is watching. A parked engine arms nothing and posts nothing. */
741
+ private parked;
742
+ private disposed;
743
+ /**
744
+ * Constructing one holds the options and does nothing else: no deadline is armed and nothing is
745
+ * posted. A React binding constructs during a render React is free to throw away, and a
746
+ * constructor with a side effect would leave the discarded copy waiting.
747
+ *
748
+ * @throws {MountayaElementsError} When `timeoutMs` is not a finite number from 0 to
749
+ * 2,147,483,647.
750
+ */
751
+ constructor(options: EmbedReadyEngineOptions);
752
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
753
+ getSnapshot(): EmbedReadySnapshot;
754
+ /**
755
+ * subscribe registers a listener for every change of the snapshot, and returns its own
756
+ * unsubscribe, which is idempotent.
757
+ *
758
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
759
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
760
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
761
+ * dead engine. A binding hands its framework a STABLE `subscribe`; a fresh closure per render
762
+ * parks and resumes on every render.
763
+ */
764
+ subscribe(listener: () => void): () => void;
765
+ /**
766
+ * configure replaces the configuration the next ready event is assembled from. It moves nothing:
767
+ * the deadline stays where it is and a posted event stays posted, so a binding calls it after
768
+ * every render at the cost of an assignment.
769
+ */
770
+ configure(config: EmbedReadyConfig): void;
771
+ /**
772
+ * settle reports that the initial view has painted, framed on `bounds` (`[west, south, east,
773
+ * north]`, the itinerary's or the collection's, or null when neither frames it): the cover lifts
774
+ * and a ready event is posted.
775
+ * Called on the cold load and again after every content switch, and each call posts. A call
776
+ * while parked, or after {@link EmbedReadyEngine.dispose}, does nothing.
777
+ */
778
+ settle(bounds: BoundingBox | null): void;
779
+ /**
780
+ * dispose drops the deadline and every listener, for good.
781
+ *
782
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
783
+ * mid-load should not have to guard the calls it already queued.
784
+ */
785
+ dispose(): void;
786
+ /** arm waits out the deadline while the cover is up. */
787
+ private arm;
788
+ /** disarm drops the deadline, if one is armed. */
789
+ private disarm;
790
+ /**
791
+ * expire lifts the cover at the deadline and says `"timeout"`. It runs only for the deadline the
792
+ * engine still holds, so the engine is watched and nothing has settled: a settle, a park and a
793
+ * dispose each drop the deadline, and a lifted cover arms no other.
794
+ */
795
+ private expire;
796
+ /** post hands one ready event to the host, assembled from the configuration as it stands. */
797
+ private post;
798
+ /** reveal lifts the cover, and tells every listener when that is news. */
799
+ private reveal;
800
+ }
801
+
802
+ /**
803
+ * The hosted embed's session token, asked of the page that frames it.
804
+ *
805
+ * An organization that sets `require_session_token` has every read of its hosted embed carry a
806
+ * session token, the map's tiles included, and a token lives minutes. The embed cannot mint
807
+ * one: minting takes the organization's secret key, which only the integrator's server holds. So
808
+ * the embed asks the page that frames it, and that page asks the server: the snippet's script
809
+ * answers each request from the integrator's own endpoint.
810
+ *
811
+ * {@link askFramingPageForSession} is one such ask, shaped as the `mint` a `SessionTokenEngine`
812
+ * of `@mountaya/client` takes, so the engine schedules the next one a minute before the answer's
813
+ * `expires_at` and retries a page that did not answer:
814
+ *
815
+ * ```ts
816
+ * import { SessionTokenEngine } from "@mountaya/client";
817
+ * import { askFramingPageForSession } from "@mountaya/studio/engines";
818
+ * import { systemClock } from "@mountaya/studio/seams";
819
+ *
820
+ * const session = new SessionTokenEngine({
821
+ * mint: () => askFramingPageForSession({ clock: systemClock(), embed: window }),
822
+ * });
823
+ * ```
824
+ */
825
+
826
+ /** FRAMING_PAGE_SESSION_TIMEOUT_MS is how long an ask waits for the framing page by default. */
827
+ declare const FRAMING_PAGE_SESSION_TIMEOUT_MS = 10000;
828
+ /**
829
+ * FramingPageMessage is the part of a window `message` event an ask reads: the payload, and the
830
+ * window that posted it.
831
+ */
832
+ interface FramingPageMessage {
833
+ readonly data: unknown;
834
+ readonly source: unknown;
835
+ }
836
+ /**
837
+ * FramingPageWindow is the part of the embed's own window an ask uses: its parent, the page that
838
+ * frames it, and the `message` listener the answer arrives through. A browser `Window` is one.
839
+ */
840
+ interface FramingPageWindow {
841
+ readonly addEventListener: (type: "message", listener: (event: FramingPageMessage) => void) => void;
842
+ readonly parent: {
843
+ readonly postMessage: (message: unknown, targetOrigin: string) => void;
844
+ };
845
+ readonly removeEventListener: (type: "message", listener: (event: FramingPageMessage) => void) => void;
846
+ }
847
+ /** AskFramingPageForSessionOptions is what {@link askFramingPageForSession} takes. */
848
+ interface AskFramingPageForSessionOptions {
849
+ /**
850
+ * Where the wait's time comes from: `systemClock()` of `@mountaya/studio/seams` in a page, which
851
+ * the host chooses as it chooses every seam.
852
+ */
853
+ readonly clock: Clock;
854
+ /**
855
+ * How long to wait for the framing page's answer, in milliseconds, before the ask rejects. A
856
+ * whole or fractional number from 1 to 2,147,483,647, the longest delay a timer honours.
857
+ *
858
+ * @default 10000
859
+ */
860
+ readonly timeoutMs?: number | undefined;
861
+ /**
862
+ * The embed's own window, whose parent is the page that frames it. Handed in rather than read
863
+ * off the global, so a host decides which window asks, and a suite hands it a stand-in.
864
+ */
865
+ readonly embed: FramingPageWindow;
866
+ }
867
+ /**
868
+ * askFramingPageForSession asks the page that frames the embed for a session token, and resolves
869
+ * with the first valid `mountaya:setSessionToken` that page posts back.
870
+ *
871
+ * Only the framing page is heard: a message from any other window (a frame beside the embed, a
872
+ * popup, a frame inside it) is ignored, as is one that does not parse, so a script the framing
873
+ * page did not run itself never hands the embed a token. The answer resolves as a `Session` whose
874
+ * `user_id` is null: the hosted embed reads what is published and acts as no member.
875
+ *
876
+ * @param options - The embed's own window, and how long to wait.
877
+ * @returns The session, as `POST /v1/sessions` answers one.
878
+ * @throws {MountayaElementsError} Where `timeoutMs` is no delay a timer honours. The promise
879
+ * rejects with one where the embed is not framed, since there is no page to ask, and where the
880
+ * framing page has not answered within `timeoutMs`; the listener is removed either way, so an
881
+ * unanswered ask holds nothing.
882
+ */
883
+ declare const askFramingPageForSession: (options: AskFramingPageForSessionOptions) => Promise<RestSchema.Session>;
884
+
885
+ /**
886
+ * ItineraryPaceResult is one itinerary re-timed at one pace: the total in
887
+ * seconds, and every segment that made it up, indexed by the segment's own id.
888
+ *
889
+ * It is a Map rather than the wire's array because every consumer joins it to a
890
+ * chain it already holds. Joining by position across two calls is the failure the
891
+ * server's per-segment `id` exists to prevent, and handing the caller an array
892
+ * would invite it right back.
893
+ */
894
+ interface ItineraryPaceResult {
895
+ bySegmentId: ReadonlyMap<string, ItineraryPaceSegment>;
896
+ durationSeconds: number;
897
+ }
898
+
899
+ /**
900
+ * ItineraryPaceConfig is what one re-time is asked with, all of it replaceable mid-life through
901
+ * {@link ItineraryPaceEngine.configure}.
902
+ */
903
+ interface ItineraryPaceConfig {
904
+ /**
905
+ * The client the re-time is asked through, or undefined while the host has none, in which case
906
+ * the engine asks nothing and answers null.
907
+ *
908
+ * Required even so, because an engine without a client is silent: a key the caller has to
909
+ * write makes forgetting it a compile error rather than a pace readout that never moves.
910
+ *
911
+ * Compared by identity. The client carries the credential, and with no `surface` named the
912
+ * credential decides which copy is re-timed, so a replaced client drops every answer the
913
+ * previous one gave and asks again: hand over the same object for as long as the credential
914
+ * stands.
915
+ */
916
+ readonly client: Mountaya | undefined;
917
+ /** The itinerary to re-time, or null while there is none. */
918
+ readonly itineraryId: string | null;
919
+ /**
920
+ * The reader's own pace on level ground, in km/h, or null while no rate is set.
921
+ *
922
+ * km/h whatever the surface displays: it is the wire unit, so a surface showing mph, min/km or
923
+ * min/mi converts before it gets here.
924
+ */
925
+ readonly speedKmh: number | null;
926
+ /**
927
+ * Which copy of the itinerary to re-time. Omitted, the credential decides, which is the draft
928
+ * for a member; `"published"` re-times the last publication whoever asks.
929
+ */
930
+ readonly surface?: ItinerarySurface | undefined;
931
+ /**
932
+ * Which state of the itinerary the re-time is asked about: any value that differs whenever the
933
+ * itinerary changed under the id it keeps, such as its last-update instant or a counter the
934
+ * host steps on each edit.
935
+ *
936
+ * Two revisions are one when they are of one type and write the same text, which is what `===`
937
+ * answers for every value but `NaN`: the number 1 and the string "1" are two revisions, and a
938
+ * `NaN`, which `Date.parse` answers for an instant it cannot read, is one revision however
939
+ * often it is handed.
940
+ *
941
+ * An answer is kept for one revision of its itinerary. A configuration that names another
942
+ * revision drops the answers the engine kept for that itinerary, aborts its re-time in flight,
943
+ * shows null and asks again, since a draft edited under the same id is another route at the
944
+ * same rate. Omitted, the itinerary is taken as unchanged for as long as the client stands,
945
+ * which holds for a publication and not for a draft a member is editing.
946
+ */
947
+ readonly revision?: string | number | undefined;
948
+ }
949
+ /**
950
+ * ItineraryPaceEngineOptions is the {@link ItineraryPaceConfig} an engine starts with, plus the
951
+ * one setting that is fixed for its life.
952
+ */
953
+ interface ItineraryPaceEngineOptions extends ItineraryPaceConfig {
954
+ /**
955
+ * How long a rate holds still before its re-time is asked for, in milliseconds. Zero asks at
956
+ * once. A whole or fractional number from 0 to 2,147,483,647, the longest delay a timer
957
+ * honours.
958
+ *
959
+ * @default 250
960
+ */
961
+ readonly debounceMs?: number | undefined;
962
+ }
963
+ /**
964
+ * ItineraryPaceEngine resolves the reader's OWN pace into the re-timed figures a profile
965
+ * overlays: the itinerary's total at that rate, and every segment's duration and resolved speed
966
+ * band, keyed by the segment's own id.
967
+ *
968
+ * The snapshot is null while no rate, itinerary or client is set, which is what restores the
969
+ * author's committed figures with no request: dropping the override is a render away rather
970
+ * than a round trip. Otherwise it is the answer for the current configuration. While the next
971
+ * answer is being asked for after a RATE STEP (the same itinerary at the same revision and on the
972
+ * same surface, through the same client, at another rate) it is the PREVIOUS one, deliberately:
973
+ * clearing it would snap a header back to the author's duration for one frame per step, which
974
+ * reads as the control losing the value the reader just typed. After any other change it is null
975
+ * until the answer lands, because another itinerary's, another revision's, another surface's or
976
+ * another credential's figures describe nothing the reader is looking at. A failed re-time
977
+ * answers null, because the author's figures are still correct, and nothing reports the failure:
978
+ * a pace readout that cannot be re-timed has nothing better to show than the figures it started
979
+ * with.
980
+ *
981
+ * Every answer is the platform's, asked through {@link fetchItineraryPace}, whose docblock says
982
+ * why a re-time is never rescaled on this side of the wire.
983
+ *
984
+ * Answers are kept by itinerary, revision, rate and surface for as long as the client stands, up to
985
+ * a fixed number of them, the least recently read leaving first, and a request waits for the rate
986
+ * to hold still for `debounceMs`, so a dragged stepper costs one request rather than one per click,
987
+ * and a reader stepping back to a rate they already saw pays nothing. A replaced client drops them
988
+ * all, since the credential it carries can change the answer, and a configuration that names
989
+ * another {@link ItineraryPaceConfig.revision} drops the ones kept for its itinerary, since the
990
+ * route they timed stands no longer. The debounce runs on the runtime's timer (`setTimeout`), not
991
+ * the studio's `Clock` seam, because it keeps the rate a request is worth making at, which is no
992
+ * duration the product chose, and a host that froze its clock would freeze every re-time with it.
993
+ *
994
+ * At most one re-time is in flight, and it is aborted the moment its question stops being the
995
+ * one asked: the configuration moved on, the client was replaced, the last listener left, or the
996
+ * engine was disposed. An aborted re-time leaves no answer behind, even one its transport
997
+ * delivers anyway.
998
+ *
999
+ * The lifecycle is the listeners. Constructing one asks for nothing; the first subscriber asks
1000
+ * for the current configuration; the last unsubscribe parks, dropping the pending debounce and
1001
+ * aborting the request in flight. A parked engine asks for nothing and still answers by the rules
1002
+ * above, from the answers it keeps: a configuration handed to it before anybody subscribes shows
1003
+ * the answer kept for that question, the previous one across a rate step, and null otherwise.
1004
+ * React's StrictMode mounts, unmounts and mounts again, which parks and resumes within the
1005
+ * debounce and asks once. {@link ItineraryPaceEngine.dispose} is the latch, for an owner that is
1006
+ * not a component: a disposed engine keeps the snapshot it showed and every later call does
1007
+ * nothing.
1008
+ *
1009
+ * Every listener is told of a change, and one that throws stops neither the engine nor the
1010
+ * listeners after it: its fault reaches the program as an uncaught error on a microtask, and
1011
+ * never as the outcome of {@link ItineraryPaceEngine.configure}.
1012
+ *
1013
+ * @example
1014
+ * ```ts
1015
+ * declare const client: Mountaya;
1016
+ * declare const render: (pace: ReturnType<ItineraryPaceEngine["getSnapshot"]>) => void;
1017
+ *
1018
+ * const pace = new ItineraryPaceEngine({ client, itineraryId: "itin-1", speedKmh: 4.5 });
1019
+ * const release = pace.subscribe(() => render(pace.getSnapshot()));
1020
+ *
1021
+ * pace.configure({ client, itineraryId: "itin-1", speedKmh: 5 });
1022
+ * release();
1023
+ * ```
1024
+ */
1025
+ declare class ItineraryPaceEngine {
1026
+ private config;
1027
+ private readonly debounceMs;
1028
+ private snapshot;
1029
+ /** The question the snapshot answers, or null while it is null. */
1030
+ private shown;
1031
+ private readonly listeners;
1032
+ /**
1033
+ * The answers the current client has given and the engine keeps, by their {@link paceKey}, in
1034
+ * the order they were last read: the first is the least recently read.
1035
+ */
1036
+ private readonly answers;
1037
+ /** The re-time on its way, or null. */
1038
+ private inFlight;
1039
+ private timer;
1040
+ /** Whether nobody is watching. A parked engine asks for nothing. */
1041
+ private parked;
1042
+ private disposed;
1043
+ /**
1044
+ * Constructing one holds the options and does nothing else: no timer and no request. A React
1045
+ * binding constructs during a render React is free to throw away, and a constructor with a
1046
+ * side effect would leave the discarded copy asking.
1047
+ *
1048
+ * @throws {MountayaElementsError} When `debounceMs` is not a finite number from 0 to
1049
+ * 2,147,483,647.
1050
+ */
1051
+ constructor(options: ItineraryPaceEngineOptions);
1052
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
1053
+ getSnapshot(): ItineraryPaceResult | null;
1054
+ /**
1055
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1056
+ * unsubscribe.
1057
+ *
1058
+ * The first listener resumes the engine and the last one leaving parks it, which is the whole
1059
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1060
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1061
+ * dead engine. A binding hands its framework a STABLE `subscribe`; a fresh closure per render
1062
+ * parks and resumes on every render.
1063
+ *
1064
+ * After {@link ItineraryPaceEngine.dispose} the listener is not held and is never told, and
1065
+ * the function returned does nothing.
1066
+ */
1067
+ subscribe(listener: () => void): () => void;
1068
+ /**
1069
+ * configure replaces the configuration, and asks again only when the question changed.
1070
+ *
1071
+ * A binding calls it on every render, so it compares the question the configuration asks (the
1072
+ * itinerary, its revision, the rate, the surface, and whether there is a client at all) and
1073
+ * does nothing when that is unchanged and the client is the same object. A client replaced by
1074
+ * another is a new question even when the rest is not: the credential it carries decides which
1075
+ * copy a re-time without a surface answers for, so the answers the previous client gave are
1076
+ * dropped, its request in flight is aborted, and the question is asked again through the new
1077
+ * client. Another {@link ItineraryPaceConfig.revision} of the same itinerary is a new question
1078
+ * too: the answers kept for that itinerary are dropped, its re-time in flight is aborted, and
1079
+ * the snapshot is null until the answer lands.
1080
+ *
1081
+ * Parked or not, the snapshot is settled for the new configuration before this returns: the
1082
+ * answer kept for it, the previous one across a rate step, or null. Only the request waits for a
1083
+ * subscriber.
1084
+ *
1085
+ * After {@link ItineraryPaceEngine.dispose} it does nothing: the configuration is not taken and
1086
+ * the snapshot stays the one the engine showed.
1087
+ */
1088
+ configure(config: ItineraryPaceConfig): void;
1089
+ /**
1090
+ * dispose drops the pending debounce and every listener and aborts the re-time in flight, for
1091
+ * good.
1092
+ *
1093
+ * It changes nothing a reader holds: {@link ItineraryPaceEngine.getSnapshot} goes on returning
1094
+ * the snapshot the engine showed when it was disposed, the answer included, and no listener is
1095
+ * told. Idempotent, and every call after it is a no-op rather than an error: an owner torn
1096
+ * down mid-step should not have to guard the calls it already queued.
1097
+ */
1098
+ dispose(): void;
1099
+ /** request resolves the current configuration into the re-time it asks for, or null. */
1100
+ private request;
1101
+ /** readKept answers the answer kept for `key`, which becomes the most recently read. */
1102
+ private readKept;
1103
+ /**
1104
+ * keep holds an answer as the most recently read, and drops the least recently read beyond
1105
+ * {@link PACE_ANSWER_CAPACITY}.
1106
+ */
1107
+ private keep;
1108
+ /**
1109
+ * forgetOtherRevisions drops every answer kept for the itinerary `request` names under another
1110
+ * revision than the one it names, two revisions being one as {@link revisionKey} writes them.
1111
+ * Another itinerary's answers stay.
1112
+ */
1113
+ private forgetOtherRevisions;
1114
+ /**
1115
+ * schedule answers the current configuration: at once when it can, after the debounce
1116
+ * otherwise. The re-time in flight for any other question is aborted first, and the previous
1117
+ * answer stays on screen only across a rate step (see {@link isRateStep}). A parked engine
1118
+ * answers as far as it can without asking, and its first subscriber asks the rest.
1119
+ */
1120
+ private schedule;
1121
+ /**
1122
+ * ask resolves one request, unless the same question is already on its way, in which case the
1123
+ * answer that lands serves it.
1124
+ */
1125
+ private ask;
1126
+ /**
1127
+ * settle retires a re-time that has landed, and reports whether its answer still counts: false
1128
+ * for one aborted before it landed, whatever its transport delivered.
1129
+ */
1130
+ private settle;
1131
+ /**
1132
+ * abandon aborts the re-time in flight unless it asks `keep`, the key the configuration asks
1133
+ * for now; null keeps none.
1134
+ */
1135
+ private abandon;
1136
+ /** isLive reports whether an answer for `key` is still the one the snapshot should show. */
1137
+ private isLive;
1138
+ private cancelPending;
1139
+ /** commit shows `snapshot`, the answer to `answers`, and tells every listener when it changed. */
1140
+ private commit;
1141
+ }
1142
+
1143
+ /**
1144
+ * ProfileMarkerEngineOptions is the one setting of a {@link ProfileMarkerEngine}, fixed for its
1145
+ * life.
1146
+ */
1147
+ interface ProfileMarkerEngineOptions {
1148
+ /**
1149
+ * The least time between two placements of the marker while the pointer stays on the chart,
1150
+ * in milliseconds. Zero places it at every hover. A whole or fractional number from 0 to
1151
+ * 2,147,483,647, the longest delay a timer honours.
1152
+ *
1153
+ * @default 60
1154
+ */
1155
+ readonly throttleMs?: number | undefined;
1156
+ }
1157
+ /**
1158
+ * ProfileMarkerEngine decides where the map marker that follows the pointer along an elevation
1159
+ * profile rests, at a rate a map can redraw at.
1160
+ *
1161
+ * A chart reports a hover for every pixel the pointer crosses. A surface hands each one to
1162
+ * {@link ProfileMarkerEngine.hover}, and the snapshot is the sample the marker rests on, or null
1163
+ * while there is none. A listener is told when it moves, and writes the marker from it (through
1164
+ * `studio.itinerary.profileMarker.set`). The contract, which `PROFILE_MARKER_THROTTLE_MS`
1165
+ * states for every surface:
1166
+ *
1167
+ * - the first hover of a burst moves the marker at once, and opens a window of `throttleMs`;
1168
+ * - a hover inside the window is held, and a later one inside the same window replaces it;
1169
+ * - when the window ends the held hover moves the marker and opens the next window, so a scrub
1170
+ * that keeps moving moves the marker once per window and it comes to rest where the pointer
1171
+ * did. A window that ends with nothing held closes;
1172
+ * - a leave (`hover(null)`) clears the marker at once, drops the held hover and ends the window,
1173
+ * so the hover that follows is the first of a new burst.
1174
+ *
1175
+ * The window runs on the runtime's timer (`setTimeout`), not on the studio's `Clock` seam,
1176
+ * because it keeps a rate and no duration the product chose: a host that froze its clock would
1177
+ * otherwise freeze the marker with it.
1178
+ *
1179
+ * The listeners are the lifecycle. The last one to leave ends the open window and drops the held
1180
+ * hover, and a hover made while nobody listens moves the snapshot and opens no window, so a
1181
+ * framework that mounts, unmounts and mounts again in one tick leaves no timer behind.
1182
+ * {@link ProfileMarkerEngine.dispose} is the latch, for an owner that is not a component.
1183
+ *
1184
+ * @example
1185
+ * ```ts
1186
+ * import { ProfileMarkerEngine } from "@mountaya/studio/engines";
1187
+ *
1188
+ * declare const placeMarker: (lngLat: readonly [number, number] | null) => void;
1189
+ *
1190
+ * const marker = new ProfileMarkerEngine();
1191
+ * const release = marker.subscribe(() => placeMarker(marker.getSnapshot()?.lngLat ?? null));
1192
+ *
1193
+ * // The chart's hover handler, a leave included.
1194
+ * marker.hover({ distance: 1200, elevation: 1840, index: 12, lngLat: [6.86, 45.83] });
1195
+ * marker.hover(null);
1196
+ * release();
1197
+ * ```
1198
+ */
1199
+ declare class ProfileMarkerEngine {
1200
+ private readonly throttleMs;
1201
+ private readonly listeners;
1202
+ /** The sample the marker rests on, or null while it is cleared. */
1203
+ private resting;
1204
+ /** The hover waiting for the open window to end, or null while none waits. */
1205
+ private held;
1206
+ /** The window that is open, or null between two bursts. */
1207
+ private timer;
1208
+ private disposed;
1209
+ /**
1210
+ * The constructor reads its option and does nothing else: no timer starts until a hover is
1211
+ * made under a listener.
1212
+ *
1213
+ * @throws {MountayaElementsError} When `throttleMs` is not a finite number from 0 to
1214
+ * 2,147,483,647.
1215
+ */
1216
+ constructor(options?: ProfileMarkerEngineOptions);
1217
+ /** getSnapshot answers the sample the marker rests on, or null while it is cleared. */
1218
+ getSnapshot: () => ElevationPoint | null;
1219
+ /**
1220
+ * subscribe holds a listener until the release it returns is called, and tells it each time
1221
+ * the marker moves or is cleared.
1222
+ *
1223
+ * The last listener to leave ends the open window and drops the held hover unwritten. After
1224
+ * {@link ProfileMarkerEngine.dispose} the listener is not held and is never told, and the
1225
+ * release does nothing.
1226
+ */
1227
+ subscribe: (listener: () => void) => (() => void);
1228
+ /**
1229
+ * hover takes one hover of the chart: the sample under the pointer, or null as the pointer
1230
+ * leaves.
1231
+ *
1232
+ * A sample moves the marker at once when no window is open, and waits for the open window to
1233
+ * end otherwise. Null clears the marker at once, whatever is held. After
1234
+ * {@link ProfileMarkerEngine.dispose} it does nothing.
1235
+ */
1236
+ hover(point: ElevationPoint | null): void;
1237
+ /**
1238
+ * dispose ends the open window, drops the held hover and every listener, for good. The
1239
+ * snapshot keeps the sample the marker rested on, no listener is told, and every later call
1240
+ * does nothing. Calling it twice is safe.
1241
+ */
1242
+ dispose(): void;
1243
+ /** rest moves the marker to `point` and tells the listeners, unless it rests there already. */
1244
+ private rest;
1245
+ /**
1246
+ * openWindow starts the window a write opens, unless one is open already. With nobody
1247
+ * listening, or with a throttle of zero, there is no rate to keep and no window.
1248
+ */
1249
+ private openWindow;
1250
+ /** endWindow closes the open window, if any, and drops the hover it held. */
1251
+ private endWindow;
1252
+ }
1253
+
1254
+ /**
1255
+ * SegmentDraftContext is the part of a tool context a {@link SegmentDraftEngine} reads: the UI
1256
+ * store the segment edit session lives in, the client a routed edit resolves through, and the
1257
+ * confirm gate a route's hazards are put to.
1258
+ *
1259
+ * A studio's own tool context satisfies it structurally, so a binding hands over the context it
1260
+ * already dispatches with.
1261
+ */
1262
+ interface SegmentDraftContext extends ToolBusContext {
1263
+ /**
1264
+ * Where the client a directions edit routes through and a freehand edit analyses through comes
1265
+ * from. Absent, the editor is armed with neither resolver.
1266
+ */
1267
+ readonly api?: {
1268
+ readonly client: Mountaya;
1269
+ } | undefined;
1270
+ /** The store holding the segment edit session the engine arms for and records into. */
1271
+ readonly ui: UiStoreApi;
1272
+ }
1273
+ /**
1274
+ * SegmentDraftConfig is what a segment edit's drafts run against, all of it replaceable mid-life
1275
+ * through {@link SegmentDraftEngine.configure}.
1276
+ */
1277
+ interface SegmentDraftConfig {
1278
+ /**
1279
+ * The bus the via ceiling's warning is raised through, as `studio.alert.show`, and a session
1280
+ * whose begin the map client refused is ended through, as `studio.itinerary.segment.editCancel`,
1281
+ * then told of through, as `studio.alert.show` again.
1282
+ *
1283
+ * A bus that rejects a dispatch is held, so the engine leaves no rejection unhandled: a
1284
+ * rejected cancel closes the refused session directly, and a rejected alert is dropped, since
1285
+ * nothing follows one.
1286
+ */
1287
+ readonly bus: ToolBusDispatch<SegmentDraftContext, StudioToolInputs, StudioToolOutputs>;
1288
+ /**
1289
+ * The map client the edit is armed on and its drafts are read from, or null while there is no
1290
+ * map, in which case nothing is armed.
1291
+ *
1292
+ * Required even so, because an engine without a client is silent: a key the caller has to write
1293
+ * makes forgetting it a compile error rather than an edit that never arms.
1294
+ *
1295
+ * Compared by identity. A replaced client is armed afresh and read from then on, and the
1296
+ * previous client's editor is left to the tool path, which owns every disposal.
1297
+ */
1298
+ readonly client: MapClient | null;
1299
+ /**
1300
+ * The live collaboration session the edit's live segment is handed to as the person drags, so
1301
+ * a peer previews it. Null or omitted on an itinerary nobody else is editing. The session paces
1302
+ * what it sends at its own rate, so every write the engine makes is handed over.
1303
+ */
1304
+ readonly collab?: {
1305
+ /**
1306
+ * Sends the draft a peer should preview for one entity: the edit's live segment. A
1307
+ * session that relays any value, as `CollabEngine.sendDraft` does, fits.
1308
+ */
1309
+ readonly sendDraft: (entity: {
1310
+ readonly id: string;
1311
+ readonly kind: "segment";
1312
+ }, draft: ItinerarySegment) => void;
1313
+ } | null | undefined;
1314
+ /**
1315
+ * The tool context the edit runs in. Compared by identity: another context arms the open
1316
+ * session again, since its client and its store may differ.
1317
+ */
1318
+ readonly context: SegmentDraftContext;
1319
+ /**
1320
+ * The words the via ceiling's warning and the route-hazard prompt are written in, and the
1321
+ * sentence a refused begin is told in (`editing.segmentEditBeginFailed`).
1322
+ */
1323
+ readonly strings: Pick<StudioStrings, "editing">;
1324
+ }
1325
+ /**
1326
+ * SegmentDraftEngineOptions is the {@link SegmentDraftConfig} an engine starts with, plus the one
1327
+ * setting that is fixed for its life.
1328
+ */
1329
+ interface SegmentDraftEngineOptions extends SegmentDraftConfig {
1330
+ /**
1331
+ * The window a burst of routed drafts is paced to before the live segment is written, in
1332
+ * milliseconds. The first route of a burst is written at once and the last one on the window's
1333
+ * trailing edge, so the profile never ends a step behind the geometry. Zero writes every route
1334
+ * as it arrives. A whole or fractional number from 0 to 2,147,483,647, the longest delay a timer
1335
+ * honours.
1336
+ *
1337
+ * The default is the rate a collaboration session sends the same live segment at, so a peer's
1338
+ * preview advances as smoothly as the local profile.
1339
+ *
1340
+ * @default 60
1341
+ */
1342
+ readonly throttleMs?: number | undefined;
1343
+ }
1344
+ /**
1345
+ * SegmentDraftEngineSnapshot is what a {@link SegmentDraftEngine} answers: whether a segment edit
1346
+ * is armed, which one, and how many handles its latest draft holds.
1347
+ *
1348
+ * It names the segment it answers for, so a reader holding a snapshot knows which edit it counts
1349
+ * and never takes one edit's count for the next one's.
1350
+ */
1351
+ interface SegmentDraftEngineSnapshot {
1352
+ /** Whether an edit is armed on the configured map client and its drafts are being read. */
1353
+ readonly armed: boolean;
1354
+ /** How the armed edit is authored, or null while nothing is armed. */
1355
+ readonly mode: SegmentEditMode | null;
1356
+ /** The segment the armed edit stands for, or null while nothing is armed. */
1357
+ readonly segmentId: string | null;
1358
+ /**
1359
+ * The handles the armed edit's latest draft holds: the vias of a directions edit, the vertices
1360
+ * of a freehand one. Zero until the first draft, and while nothing is armed.
1361
+ */
1362
+ readonly viaCount: number;
1363
+ }
1364
+ /**
1365
+ * SegmentDraftEngine is the machine behind a segment edit's drafts: it arms the map's segment
1366
+ * editor for the open edit session and turns every draft the editor reports into the store's
1367
+ * history, the live segment the elevation profile reads and the preview a collaborator sees.
1368
+ *
1369
+ * What it does, in the order a session meets it:
1370
+ *
1371
+ * - **Arming.** While a segment edit session is open in `context.ui` and a map client is set, the
1372
+ * client is armed through `beginSegmentEdit` with {@link buildSegmentEditOptions}: a directions
1373
+ * edit routes through `context.api.client`, a freehand edit analyses its line through it, and a
1374
+ * click past the router's via ceiling raises a warning through `bus`. It is armed again when an
1375
+ * arming input changes (the segment, the mode, the activity, the colour, a pin, the seed, the
1376
+ * client or the context). The engine never ends an edit: the tool path that commits or cancels
1377
+ * one owns the disposal, so parking or disposing leaves the map's editor where it is.
1378
+ * - **A refused begin.** A map client that refuses the begin (a directions edit with no activity
1379
+ * or no router, a seed its drawing library refuses) has taken no edit. Nothing is armed, the
1380
+ * session is ended through `studio.itinerary.segment.editCancel` on `bus`, the reader is told
1381
+ * the edit did not open through `studio.alert.show`, in the bundle's
1382
+ * `editing.segmentEditBeginFailed`, and the refusal reaches the program as an uncaught error on
1383
+ * a microtask, never through the store write that woke the engine. Each happens once per
1384
+ * refused session, however many times a surface parks and resumes the engine before the cancel
1385
+ * lands. The session that follows is armed afresh.
1386
+ * - **Disposition.** Every draft is handed to {@link draftChangeDisposition}: a person's change
1387
+ * while the co-pilot drives is dropped whole, a programmatic change is previewed and never
1388
+ * recorded, and a person's change is recorded.
1389
+ * - **History.** A recorded draft is routed by its phase: a `live` frame of a drag moves the draft
1390
+ * through `setSegmentEditLiveDraft`, and the `settled` draft closing it records one undo step
1391
+ * through `pushSegmentDraft`, so a drag of any length is one step.
1392
+ * - **Live segment.** A draft carrying a route projects it onto the live segment through
1393
+ * {@link buildLiveSegmentForDraft}, paced to `throttleMs`: the first route of a burst lands at
1394
+ * once and the last one on the window's trailing edge. The same segment goes to `collab`. The
1395
+ * map's editor hands its cached route to every draft until a new one resolves, so a draft
1396
+ * carrying the route the last write read writes nothing while the store still holds what that
1397
+ * write produced: a drag over one route rebuilds the profile once. A
1398
+ * `live` frame with no route leaves the live segment as it stands. A `settled` draft with no
1399
+ * route drops any pending route and falls back: to nothing for a persisted segment, so the
1400
+ * profile shows the segment as saved, and to the draft's synthetic segment for one drawn from
1401
+ * scratch, so its row stays visible. A programmatic draft with no route is the echo of an undo
1402
+ * or a redo, which restored the live segment itself, so it is left untouched.
1403
+ * - **Hazards.** A routed line crossing a hazard the session has not accepted is put to
1404
+ * `context.confirm` as {@link routeHazardConfirmation}, once per question however many routing
1405
+ * round trips ask it, and the answer is remembered in the session, so the same way is not asked
1406
+ * about twice in one edit. With no confirm gate the line is adopted.
1407
+ *
1408
+ * The snapshot names the armed edit and counts its latest draft's handles (see
1409
+ * {@link SegmentDraftEngineSnapshot}). It changes only when one of those does, never per frame of
1410
+ * a drag, so a surface following it re-renders once per handle added or removed. Every listener
1411
+ * is told of a change. One that throws stops neither the engine nor the listeners after it, and
1412
+ * its fault reaches the program as an uncaught error on a microtask.
1413
+ *
1414
+ * Time follows the engines' rule: the throttle keeps the rate a profile is worth rebuilding at,
1415
+ * which is no duration the product chose, so it runs on the runtime's timer through
1416
+ * `TrailingThrottle` with its window as the `throttleMs` option, and the engine takes no `Clock`.
1417
+ * A host that froze its clock would otherwise freeze every live profile with it.
1418
+ *
1419
+ * The lifecycle is the listeners. Constructing one arms nothing, reads no store and writes
1420
+ * nothing; the first subscriber starts watching the store and arms the open session; the last
1421
+ * unsubscribe parks: it stops reading the map's drafts, drops the pending route and clears the
1422
+ * live segment, so a surface mounted again over the same session starts from a clean slot until
1423
+ * the next route lands. React's StrictMode mounts, unmounts and mounts again, which parks and
1424
+ * resumes and leaves one subscription to the map's drafts. `dispose()` is the latch, for an owner
1425
+ * that is not a component. The callbacks the editor was armed with read the configuration when
1426
+ * they run, so a warning or a prompt raised after a locale change reads the new words.
1427
+ *
1428
+ * @example
1429
+ * ```ts
1430
+ * declare const map: MapClient;
1431
+ * declare const strings: StudioStrings;
1432
+ * declare const session: SegmentDraftConfig["collab"];
1433
+ *
1434
+ * const drafts = new SegmentDraftEngine({ bus, client: map, context: ctx, strings });
1435
+ * const release = drafts.subscribe(() => {
1436
+ * console.log(drafts.getSnapshot().viaCount);
1437
+ * });
1438
+ *
1439
+ * drafts.configure({ bus, client: map, collab: session, context: ctx, strings });
1440
+ * release();
1441
+ * ```
1442
+ */
1443
+ declare class SegmentDraftEngine {
1444
+ private config;
1445
+ private readonly throttleMs;
1446
+ private snapshot;
1447
+ private readonly subscriptions;
1448
+ /** The store the session is watched in, and the subscription watching it, while running. */
1449
+ private watching;
1450
+ /** What the open edit was armed with, or null while nothing is armed. */
1451
+ private arming;
1452
+ /**
1453
+ * What the map client refused to arm, or null. Held until the session it was for closes or one
1454
+ * of its inputs changes, so a session on its way out is not handed to the map again. A park
1455
+ * keeps it: the session it names is still on its way out when the next subscriber arrives.
1456
+ */
1457
+ private refused;
1458
+ /** The subscription to the armed map's drafts, or null while nothing is armed. */
1459
+ private listening;
1460
+ /** The handles the armed edit's latest draft holds. */
1461
+ private viaCount;
1462
+ /** Whether a reconcile is running, so one a store write starts inside it runs after it. */
1463
+ private reconciling;
1464
+ /** Whether the store changed during the running reconcile, which then runs again. */
1465
+ private stale;
1466
+ /** Whether nobody is watching. A parked engine arms nothing and reads no draft. */
1467
+ private parked;
1468
+ private disposed;
1469
+ /**
1470
+ * One dialog per hazard question, however many routing round trips ask it. Held for the
1471
+ * engine's life rather than per arming: a gate built beside the routing function would forget
1472
+ * the dialog already on screen, which is the state it exists to track.
1473
+ */
1474
+ private readonly hazardGate;
1475
+ /**
1476
+ * The session's record of accepted hazards, read and written through the store the engine is
1477
+ * configured with when the routing function asks. The store outlives every routing function
1478
+ * the editor is armed with, which is the point: an answer outlives a re-arm.
1479
+ */
1480
+ private readonly hazardMemo;
1481
+ /**
1482
+ * Constructing one holds the options and does nothing else: nothing is armed, no store is read
1483
+ * and nothing is written. A React binding constructs during a render React is free to throw
1484
+ * away, and a constructor with a side effect would leave the discarded copy acting.
1485
+ *
1486
+ * @throws {MountayaElementsError} When `throttleMs` is not a finite number from 0 to
1487
+ * 2,147,483,647.
1488
+ */
1489
+ constructor(options: SegmentDraftEngineOptions);
1490
+ /** getSnapshot returns the current answer, by reference and stable between changes. */
1491
+ getSnapshot(): SegmentDraftEngineSnapshot;
1492
+ /**
1493
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1494
+ * unsubscribe, which is idempotent.
1495
+ *
1496
+ * The first listener starts the engine and the last one leaving parks it, which is the whole
1497
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1498
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1499
+ * dead engine. Each call is its own subscription, so two owners subscribing one shared function
1500
+ * each hold the engine until they release it.
1501
+ */
1502
+ subscribe(listener: () => void): () => void;
1503
+ /**
1504
+ * configure replaces the configuration, and arms again only when an arming input changed.
1505
+ *
1506
+ * A binding calls it on every render, so a configuration carrying the same client and the same
1507
+ * context does nothing beyond the assignment: the bus, the collaboration session and the words
1508
+ * are read when they are used. A parked engine keeps the configuration for its next subscriber.
1509
+ */
1510
+ configure(config: SegmentDraftConfig): void;
1511
+ /**
1512
+ * dispose parks the engine and drops every listener, for good.
1513
+ *
1514
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
1515
+ * mid-edit should not have to guard the calls it already queued. A disposed engine writes no
1516
+ * store either: the cancel it dispatched for a refused begin runs on the bus, and a session that
1517
+ * cancel leaves open is not closed by the engine.
1518
+ *
1519
+ * The snapshot of a disposed engine reads `armed: false`. The engine holds a session and no
1520
+ * answer to a question, so there is nothing a reader could keep showing: the session is over
1521
+ * for this engine, and the snapshot says so.
1522
+ */
1523
+ dispose(): void;
1524
+ /**
1525
+ * reconcile brings the arming and the draft subscription in line with the store and the
1526
+ * configuration, then publishes the snapshot. A store write it makes, or one a listener makes
1527
+ * while it runs, runs it again once it finishes rather than inside it.
1528
+ */
1529
+ private reconcile;
1530
+ /** step is one pass of {@link SegmentDraftEngine.reconcile}. */
1531
+ private step;
1532
+ /**
1533
+ * endRefused ends the session whose begin the map client refused, and hands the refusal to the
1534
+ * program.
1535
+ *
1536
+ * The session is ended by `studio.itinerary.segment.editCancel` through `bus`, the tool path
1537
+ * that owns every disposal: it gives back the lock the begin took and ends whatever edit the map
1538
+ * still holds. Where that tool does not answer `ok` (it is refused, it rejects, or the bus
1539
+ * states no result at all), the store's session is closed directly, so no session stays open
1540
+ * over a map that is editing nothing. A parked engine still closes it, since its surface may
1541
+ * mount again. A disposed one writes nothing, as {@link SegmentDraftEngine.dispose} promises:
1542
+ * the session is left to the engine that takes its place, which meets the same refusal.
1543
+ *
1544
+ * The refused session is the one closed directly, and no other: it is told by `mark`, its
1545
+ * {@link segmentEditSessionMark}, so a session begun since on the same segment stays open.
1546
+ *
1547
+ * The refusal names the option the map lacked. It is a defect of the program that armed the
1548
+ * session and not of the store write that woke the engine, so it leaves through
1549
+ * {@link surfaceFault}.
1550
+ *
1551
+ * The reader is told as well, since an uncaught error says nothing on screen and the session
1552
+ * closes under them: an `error` alert in the bundle's `editing.segmentEditBeginFailed`, read
1553
+ * when the refusal is told so a locale change is heard. It is raised after the cancel is asked
1554
+ * for, so a bus that answers one verb at a time ends the session first.
1555
+ */
1556
+ private endRefused;
1557
+ /**
1558
+ * raiseAlert raises one alert through the bus, and holds a bus that rejects it.
1559
+ *
1560
+ * Nothing follows an alert: the map has already declined what the alert reports, and a refused
1561
+ * begin has reached the program through {@link surfaceFault} and is closed by its cancel. So a
1562
+ * rejection is dropped, where one left unhandled would end a Node process with an error that is
1563
+ * none of the package's.
1564
+ */
1565
+ private raiseAlert;
1566
+ /** watch follows the store the session lives in, leaving the previous one if it changed. */
1567
+ private watch;
1568
+ private unwatch;
1569
+ /** listen starts reading the armed map's drafts for the edit `key` names. */
1570
+ private listen;
1571
+ /**
1572
+ * unlisten stops reading the map's drafts, drops the pending route, and clears the live segment,
1573
+ * so a surface opened again over the session reads a clean slot until the next route lands.
1574
+ */
1575
+ private unlisten;
1576
+ /** receive handles one draft the armed map reported, as the class docblock sets out. */
1577
+ private receive;
1578
+ /**
1579
+ * project writes one route onto the live segment the profile reads, and hands the same segment
1580
+ * to the collaboration session.
1581
+ */
1582
+ private project;
1583
+ /**
1584
+ * fallBack writes what the live segment is once a settled draft resolves no route: nothing for
1585
+ * a persisted segment, which the profile then shows as saved, and the draft's synthetic
1586
+ * segment for one drawn from scratch, which has no saved version to show and would otherwise
1587
+ * lose its row until a route lands.
1588
+ */
1589
+ private fallBack;
1590
+ /** refuseViaCap warns that a click was declined at the router's via ceiling. */
1591
+ private refuseViaCap;
1592
+ /**
1593
+ * askAboutHazards puts a routed line's new hazards to the context's confirm gate, in the words
1594
+ * the engine was last handed, and adopts the line when the context has no gate.
1595
+ */
1596
+ private askAboutHazards;
1597
+ /**
1598
+ * park stops watching and reading, and drops what the running engine armed.
1599
+ *
1600
+ * A refused arming is kept. Its session stays open until the cancel the engine asked for lands,
1601
+ * and a surface mounted again meanwhile would otherwise hand it to the map a second time and ask
1602
+ * for a second cancel, which closes whichever session is open when it runs. A session begun
1603
+ * since holds a seed array of its own, so it never reads as the refused one.
1604
+ */
1605
+ private park;
1606
+ /** publish settles the snapshot and tells every listener when it changed. */
1607
+ private publish;
1608
+ }
1609
+
1610
+ /** The tools a zone form runs, by name. */
1611
+ type ZoneFormTool = "studio.alert.show" | "studio.zone.beginOriginPick" | "studio.zone.create" | "studio.zone.editBegin" | "studio.zone.editCommit" | "studio.zone.reachabilityPreview" | "studio.zone.setCreateMethod" | "studio.zone.setLevel" | "studio.zone.update";
1612
+ /**
1613
+ * ZoneFormDispatch runs one of the tools a zone form runs, and resolves with the tool's result.
1614
+ *
1615
+ * The result holds that tool's own data, read from {@link StudioToolOutputs}: the form takes the
1616
+ * collections a create could not file the zone into straight off the answer of
1617
+ * `studio.zone.create`, with no parse of its own. So the dispatch a host hands over is one typed
1618
+ * by the studio's outputs: a bus built with `StudioToolInputs` and `StudioToolOutputs`, or a
1619
+ * binding's own dispatch that answers each verb's data.
1620
+ *
1621
+ * It never rejects, as a tool bus's dispatch never does: a refusal is a result whose `ok` is
1622
+ * false. A host holding such a bus and a context writes it as
1623
+ * `(name, input) => bus.dispatch(context, name, input)`.
1624
+ */
1625
+ type ZoneFormDispatch = <TName extends ZoneFormTool>(name: TName, input: StudioToolInputs[TName]) => Promise<ToolResultOf<StudioToolOutputs, TName>>;
1626
+ /**
1627
+ * ZoneFormConfig is what a zone form reads from its host, all of it replaceable mid-life through
1628
+ * {@link ZoneFormEngine.configure}.
1629
+ */
1630
+ interface ZoneFormConfig {
1631
+ /**
1632
+ * The activity catalog. A reachability zone's activity is chosen from it, seeded from its first
1633
+ * routable entry, and named from it. Empty while the host has not resolved one, in which case
1634
+ * no activity is seeded.
1635
+ *
1636
+ * Compared by identity: a replaced catalog resolves a bound computed zone's stored activity
1637
+ * again, and leaves an activity and a budget its reader moved.
1638
+ */
1639
+ readonly activities: readonly CategoryActivities[];
1640
+ /**
1641
+ * The organization a create is filed under when it inherits none from an open itinerary, or
1642
+ * null to leave it personal until the reader picks one.
1643
+ */
1644
+ readonly defaultOrganizationId: string | null;
1645
+ /** Runs the form's tools. Read when a tool is run, so the one configured last is the one used. */
1646
+ readonly dispatch: ZoneFormDispatch;
1647
+ /**
1648
+ * The collections the open itinerary belongs to, by id, which a create begun inside that
1649
+ * itinerary is filed into. Read only while such a create is open; empty otherwise, and while
1650
+ * the host is still reading them.
1651
+ */
1652
+ readonly inheritedCollectionIds: readonly string[];
1653
+ /** The reader's language, which a derived name's activity is named and lower-cased in. */
1654
+ readonly language: MapLanguage;
1655
+ /** The words a derived name and the collection warning are written in. */
1656
+ readonly strings: Pick<StudioStrings, "zoneForm">;
1657
+ /** The reader's user id, or null for a reader with none. A zone's creator may edit it. */
1658
+ readonly userId: string | null;
1659
+ /** The organizations the reader may write to. A member of a zone's organization may edit it. */
1660
+ readonly writableOrganizationIds: ReadonlySet<string>;
1661
+ }
1662
+ /**
1663
+ * ZoneFormEngineOptions is the {@link ZoneFormConfig} an engine starts with, plus the settings
1664
+ * that are fixed for its life.
1665
+ */
1666
+ interface ZoneFormEngineOptions extends ZoneFormConfig {
1667
+ /**
1668
+ * How long a reachability zone's parameters hold still before their preview is asked for, in
1669
+ * milliseconds. Zero asks at once. A whole or fractional number from 0 to 2,147,483,647, the
1670
+ * longest delay a timer honours.
1671
+ *
1672
+ * @default 600
1673
+ */
1674
+ readonly debounceMs?: number | undefined;
1675
+ /** Where the id of a zone about to be drawn comes from. */
1676
+ readonly ids: StudioIds;
1677
+ /**
1678
+ * The store the form's zone lives in: the bound zone, the draw session, and the create's method
1679
+ * and origin. Fixed for the engine's life, because the fields are seeded from it: another store
1680
+ * is another form, and takes another engine.
1681
+ */
1682
+ readonly ui: UiStoreApi;
1683
+ }
1684
+ /**
1685
+ * ZoneFormSnapshot is what a {@link ZoneFormEngine} answers: the form's fields, and what the form
1686
+ * has decided about them.
1687
+ *
1688
+ * It names the zone it answers for, so a reader holding one knows which zone the fields describe
1689
+ * and never takes one zone's fields for another's.
1690
+ *
1691
+ * It does not say who may edit. `canEditOwnedResource` answers that from the zone and the reader,
1692
+ * which a surface already holds, and a peer's lock or the co-pilot's turn are a surface's to read.
1693
+ */
1694
+ interface ZoneFormSnapshot {
1695
+ /** Whether a draw or a reshape is armed on the map. */
1696
+ readonly armed: boolean;
1697
+ /** Whether the description is one the tools accept. */
1698
+ readonly descriptionValid: boolean;
1699
+ /**
1700
+ * Why the latest {@link ZoneFormEngine.beginDraw} was refused, or null. A draw is refused when
1701
+ * another edit is armed, when a collaborator holds the zone, or when the reader may not edit.
1702
+ * It answers for the create the snapshot describes: it is cleared by the next `beginDraw`, once
1703
+ * a draw or a reshape is armed, whoever arms it, and on every change that clears `saveFailure`
1704
+ * for another form (another zone bound, the zone unbinding, another create, a create's other
1705
+ * method, a create inheriting from elsewhere). A refusal that lands after one of those is
1706
+ * dropped. Word it for a reader with `mapToolError`.
1707
+ */
1708
+ readonly drawFailure: ToolFailure | null;
1709
+ /** The form's fields. Stable by reference until one of them changes. */
1710
+ readonly fields: ZoneFormFields;
1711
+ /**
1712
+ * Whether the create takes its organization, activity and collections from the itinerary it was
1713
+ * begun inside. The three follow that itinerary while it does, and an `edit` of one does not
1714
+ * hold, so a surface names them and offers no picker for them.
1715
+ */
1716
+ readonly inherits: boolean;
1717
+ /**
1718
+ * How the zone is authored: a create reads the method it was opened with, and a saved zone is
1719
+ * a reachability zone when it carries a query.
1720
+ */
1721
+ readonly method: ZoneCreateMethod;
1722
+ /** Whether the name is one the tools accept. */
1723
+ readonly nameValid: boolean;
1724
+ /**
1725
+ * Why the latest {@link ZoneFormEngine.beginOriginPick} was refused, or null. A pick is refused
1726
+ * while an edit is armed, and when the reader may not edit. It answers for the form the snapshot
1727
+ * describes: it is cleared by the next `beginOriginPick`, once an origin is placed or moved,
1728
+ * whoever places it, and on every change that clears `saveFailure` for another form. A refusal
1729
+ * that lands after one of those, or after a later pick was asked, is dropped. Word it for a
1730
+ * reader with `mapToolError`.
1731
+ */
1732
+ readonly pickFailure: ToolFailure | null;
1733
+ /**
1734
+ * Why the latest reachability preview failed, or null. It answers for the zone the snapshot
1735
+ * names and the query the fields state: it stands until a later preview answers, and it is
1736
+ * dropped when the form's subject changes (another zone is bound or the zone unbinds, a create
1737
+ * switches method, a create starts or stops inheriting from an itinerary or inherits from
1738
+ * another one, or the create surface is entered again) and when the fields state no query at
1739
+ * all (a drawn zone, no origin, no activity). A failure that lands after a change of subject
1740
+ * is dropped too, whatever query the form then states. A reachability create is not ready to
1741
+ * save while it stands. Word it for a reader with its `detail`, or with `mapToolError`.
1742
+ */
1743
+ readonly previewFailure: ToolFailure | null;
1744
+ /**
1745
+ * Why the latest save was refused, or null. It answers for the zone the snapshot names: it is
1746
+ * cleared by the next save, by an edit of the name, the description or the window, and when
1747
+ * the form's subject changes: another zone is bound or the zone unbinds, a create switches
1748
+ * method, whoever switches it, a create starts or stops inheriting from an itinerary or
1749
+ * inherits from another one, or the create surface is entered again. A refusal that lands
1750
+ * after a change of subject is dropped. Word it for a reader with `mapToolError`.
1751
+ *
1752
+ * A refusal of the query a reachability form states is no failed save: it is `sourceFailure`.
1753
+ */
1754
+ readonly saveFailure: ToolFailure | null;
1755
+ /**
1756
+ * Whether there is anything to persist at all: a reachability create, an armed draw or reshape,
1757
+ * or a saved zone whose metadata or parameters moved. A surface shows no Save without it.
1758
+ */
1759
+ readonly saveOffered: boolean;
1760
+ /**
1761
+ * Whether {@link ZoneFormEngine.save} is worth calling now: no save is in flight, the name, the
1762
+ * description and the window are valid, and something is unsaved. A reachability create is
1763
+ * ready once its query resolves and its preview has not failed.
1764
+ */
1765
+ readonly saveReady: boolean;
1766
+ /**
1767
+ * Whether a save of the form the snapshot describes is in flight. A save sent for another zone,
1768
+ * or for a create the form has left, is not this form's: it reads false here and holds back no
1769
+ * save of this one.
1770
+ */
1771
+ readonly saving: boolean;
1772
+ /**
1773
+ * Why the latest save's reachability query was refused, or null: the API computed an area
1774
+ * from the query and cannot store it as a zone, or refuses the query itself. A surface shows
1775
+ * it where the query's fields are, since changing one of them is what answers it. Word it for
1776
+ * a reader with `mapToolError`, which reads the API's own sentence.
1777
+ *
1778
+ * It answers for the query that was sent: it is read only while the fields state that query,
1779
+ * so it leaves when the origin, the activity, the measure, the budget or the pace moves. The
1780
+ * next save clears it, and so does every change of subject that clears `saveFailure`. A form
1781
+ * that states no query, a drawn zone's, keeps such a refusal as its `saveFailure`.
1782
+ */
1783
+ readonly sourceFailure: ToolFailure | null;
1784
+ /** Whether the availability window is one the tools accept: no start after its end. */
1785
+ readonly windowValid: boolean;
1786
+ /** The saved zone the fields answer for, or null while the form creates one. */
1787
+ readonly zoneId: string | null;
1788
+ }
1789
+ /**
1790
+ * ZoneFormEngine is the machine behind a zone form: it holds the form's fields, seeds them from
1791
+ * the zone the UI store binds, keeps a create's name following its parameters until the reader
1792
+ * types one, asks for a reachability zone's preview once its parameters hold still, and saves
1793
+ * through the one tool the form's state calls for.
1794
+ *
1795
+ * What it does, in the order a form meets it:
1796
+ *
1797
+ * - **Seeding.** A saved zone seeds what it says: its name, description, severity and window,
1798
+ * and, for a computed zone, the activity, measure, budget and pace of the query it is stored
1799
+ * with. The same zone written again, by this form's save or a collaborator's, replaces only
1800
+ * what the reader has not moved: a field typed and not saved stays as typed, the window as one
1801
+ * answer and the query's parameters as one. A catalog that lands or is replaced under a
1802
+ * computed zone resolves the stored activity again, whatever the reader did to the budget
1803
+ * meanwhile, and leaves an activity the reader picked. A create is seeded per create: when the
1804
+ * zone unbinds, and on every entry into the create surface, every field returns to a create's
1805
+ * defaults, and when a create starts or stops inheriting, or the itinerary it inherits from is
1806
+ * replaced by another, its organization, activity, collections, shape and reachability
1807
+ * parameters do. A create begun inside an itinerary follows that itinerary's organization,
1808
+ * activity and collections for as long as it is open, and one inside a personal itinerary
1809
+ * stays personal. Any other create is filed under `defaultOrganizationId` and the first
1810
+ * routable activity until its reader chooses, and a reader who chooses no organization has
1811
+ * chosen: the create stays personal.
1812
+ * - **The name.** While a create's name is nobody's, it follows {@link zoneAutoName}: a
1813
+ * proposal's name, or a phrase written from the reachability parameters. The first
1814
+ * `edit({ name })` makes it the reader's and it follows nothing after. A saved zone's name is
1815
+ * never derived.
1816
+ * - **The preview.** A reachability zone's query is previewed on the map through
1817
+ * `studio.zone.reachabilityPreview`, `debounceMs` after its activity, origin, measure, budget,
1818
+ * pace or severity last changed, so a typed budget costs one request. An answer for parameters
1819
+ * that have since moved is ignored. A failure is the snapshot's `previewFailure` until the next
1820
+ * answer, and never past the zone or the query it was about.
1821
+ * - **Unsaved changes.** The snapshot says whether Save is offered and whether it is ready, from
1822
+ * {@link isZoneMetadataDirty}, the stored query, the drawn shape and the bounds the tools hold a
1823
+ * name, a description and a window to. Whether anything is unsaved at all is written on the
1824
+ * store's `zoneFormUnsaved` while the engine runs, and taken back as it parks, so
1825
+ * `studio.zone.publish` refuses to freeze a zone whose form holds what its reader has not
1826
+ * saved.
1827
+ * - **Saving.** {@link ZoneFormEngine.save} runs the request {@link zoneSaveRequest} routes, one
1828
+ * at a time for each zone, and keeps a refusal as the snapshot's `saveFailure` for as long as
1829
+ * the form answers for the zone the save was sent for. A refusal of the reachability query the
1830
+ * fields state is kept apart, as the snapshot's `sourceFailure`, for as long as they state it.
1831
+ * - **Listeners.** Every listener is told of every change. One that throws stops neither the
1832
+ * engine nor the listeners after it: its fault is raised apart, as an uncaught error, and
1833
+ * never through the command that caused the change.
1834
+ *
1835
+ * Every mutation goes through `dispatch`, so a person filling the form and an agent calling the
1836
+ * same tools drive one surface. The slots that hold what its reader typed, which no tool takes,
1837
+ * are the exception, and the engine writes them itself: the severity they pick for a create
1838
+ * (`zoneCreatePickedLevel`), which a proposal's step records, the name of a draft a proposal
1839
+ * named, which a name they type clears so that theirs is shown, and whether the form holds
1840
+ * anything unsaved (`zoneFormUnsaved`).
1841
+ *
1842
+ * Time follows the engines' rule: the debounce keeps the rate a preview request is worth making
1843
+ * at, which is no duration the product chose, so it runs on the runtime's timer (`setTimeout`)
1844
+ * with its length as the `debounceMs` option, and the engine takes no `Clock`. A host that froze
1845
+ * its clock would otherwise freeze every preview with it.
1846
+ *
1847
+ * The lifecycle is the listeners. Constructing one reads no store, arms no timer and runs no
1848
+ * tool; the first subscriber starts watching the store and asks for the preview; the last
1849
+ * unsubscribe parks: it stops watching, drops the pending preview and ignores the answer of one
1850
+ * in flight. A parked engine keeps its fields and still answers for the store's current zone when
1851
+ * read, by seeding on that read, so the render before a subscription shows the bound zone.
1852
+ * React's StrictMode mounts, unmounts and mounts again, which parks and resumes within the
1853
+ * debounce and asks once. {@link ZoneFormEngine.dispose} is the latch, for an owner that is not a
1854
+ * component.
1855
+ *
1856
+ * A command (`edit`, `setMethod`, `beginOriginPick`, `beginDraw`, `save`) sent to an engine
1857
+ * nobody subscribes to does nothing: a save run with nobody watching would show its refusal to
1858
+ * no one, and an edit nobody sees is one nobody made.
1859
+ *
1860
+ * @example
1861
+ * ```ts
1862
+ * declare const activities: CategoryActivities[];
1863
+ * declare const render: (snapshot: ZoneFormSnapshot) => void;
1864
+ *
1865
+ * const form = new ZoneFormEngine({
1866
+ * activities,
1867
+ * defaultOrganizationId: "org-1",
1868
+ * dispatch: (name, input) => bus.dispatch(ctx, name, input),
1869
+ * ids: systemStudioIds,
1870
+ * inheritedCollectionIds: [],
1871
+ * language: "en",
1872
+ * strings: studioStrings.en,
1873
+ * ui: ctx.ui,
1874
+ * userId: "user-1",
1875
+ * writableOrganizationIds: new Set(["org-1"]),
1876
+ * });
1877
+ * const release = form.subscribe(() => render(form.getSnapshot()));
1878
+ *
1879
+ * form.edit({ name: "North couloir" });
1880
+ * await form.save();
1881
+ * release();
1882
+ * ```
1883
+ */
1884
+ declare class ZoneFormEngine {
1885
+ private config;
1886
+ private readonly debounceMs;
1887
+ private readonly ids;
1888
+ private readonly ui;
1889
+ private readonly draft;
1890
+ /** Whether the name is the reader's own, which stops it following anything. */
1891
+ private nameTouched;
1892
+ /** Whether the organization is the reader's own choice, null included, which no default fills. */
1893
+ private organizationChosen;
1894
+ /** The subjects a save is in flight for. A subject saves once at a time, and each on its own. */
1895
+ private readonly saving;
1896
+ /** Whether a draw has been asked for and not answered yet. */
1897
+ private drawing;
1898
+ private drawFailure;
1899
+ private pickFailure;
1900
+ /** Counts the origin picks asked for: the refusal of an earlier one is dropped. */
1901
+ private pickSerial;
1902
+ /** The origin the last seed read, which a pick that lands moves; undefined until the first. */
1903
+ private origin;
1904
+ private saveFailure;
1905
+ /**
1906
+ * The latest save's refusal of its reachability query, with the query it was sent with, as
1907
+ * {@link queryKeyOf} writes it; null when the latest save met none.
1908
+ */
1909
+ private sourceRefusal;
1910
+ private previewFailure;
1911
+ /** Whether the store's `zoneFormUnsaved` holds this engine's true, written by it. */
1912
+ private unsavedWritten;
1913
+ /**
1914
+ * Whether the reader changed anything since the subject opened: typed a field, switched the
1915
+ * method or picked an origin. A computed create opens saveable on what it was opened with, and
1916
+ * leaving it untouched loses nothing the reader did, so it is unsaved only once this holds.
1917
+ */
1918
+ private touched;
1919
+ /** The zone the metadata was seeded from; undefined until the first seed. */
1920
+ private bound;
1921
+ /**
1922
+ * What the failures and a save in flight answer for: the bound zone, or a create, by its
1923
+ * serial, the method it is authored by and the itinerary it inherits from. Null until the
1924
+ * first seed.
1925
+ */
1926
+ private subject;
1927
+ /**
1928
+ * Counts the subjects a save or a draw can answer for: a refusal sent under an earlier one is
1929
+ * dropped.
1930
+ */
1931
+ private subjectEpoch;
1932
+ /**
1933
+ * The create the fields were last seeded for: its serial and the id of the itinerary it
1934
+ * inherits from, and undefined while a zone is bound and before the first seed.
1935
+ */
1936
+ private create;
1937
+ /** The serial of the create the fields were last seeded for, while the last seed was a create. */
1938
+ private createSerial;
1939
+ /** The zone and the catalog the reachability parameters were last seeded from. */
1940
+ private sourceSeed;
1941
+ /** The store state and the configuration the snapshot was last settled against. */
1942
+ private settled;
1943
+ /**
1944
+ * The name and the description last judged, with the verdicts, so a pass that moved neither
1945
+ * parses nothing.
1946
+ */
1947
+ private judged;
1948
+ private snapshot;
1949
+ private readonly subscriptions;
1950
+ /** Ends the watch on the store, while running. */
1951
+ private unwatch;
1952
+ /** The key of the preview asked for or waited on; undefined when none has been considered. */
1953
+ private previewKey;
1954
+ /** The preview the pending debounce asks for. */
1955
+ private previewInput;
1956
+ /**
1957
+ * Counts the questions a preview can answer, and the subjects it can answer for: an answer
1958
+ * from an earlier one is ignored.
1959
+ */
1960
+ private previewEpoch;
1961
+ private timer;
1962
+ /** Whether a reconcile is running, so one started inside it runs after it. */
1963
+ private reconciling;
1964
+ /** Whether something changed during the running reconcile, which then runs again. */
1965
+ private stale;
1966
+ /**
1967
+ * Whether nobody is watching. A parked engine watches no store, asks for no preview and answers
1968
+ * no command.
1969
+ */
1970
+ private parked;
1971
+ private disposed;
1972
+ /**
1973
+ * Constructing one holds the options and does nothing else: no store is read, no timer armed
1974
+ * and no tool run. A React binding constructs during a render React is free to throw away, and
1975
+ * a constructor with a side effect would leave the discarded copy acting.
1976
+ *
1977
+ * @throws {MountayaElementsError} When `debounceMs` is not a finite number from 0 to
1978
+ * 2,147,483,647.
1979
+ */
1980
+ constructor(options: ZoneFormEngineOptions);
1981
+ /**
1982
+ * getSnapshot returns the current answer, by reference and stable between changes.
1983
+ *
1984
+ * A parked engine settles it on the read: it reads the store and seeds the fields for the zone
1985
+ * bound now, without watching the store, arming a timer or running a tool. So a surface's first
1986
+ * render, and a server's only one, show the bound zone.
1987
+ */
1988
+ getSnapshot(): ZoneFormSnapshot;
1989
+ /**
1990
+ * subscribe registers a listener for every change of the snapshot, and returns its own
1991
+ * unsubscribe, which is idempotent.
1992
+ *
1993
+ * The first listener starts the engine and the last one leaving parks it, which is the whole
1994
+ * lifecycle a component can express correctly: React tears an effect down and sets it up again
1995
+ * with the same object under StrictMode, so a latch here would leave a live surface bound to a
1996
+ * dead engine. Each call is its own subscription, so two owners subscribing one shared function
1997
+ * each hold the engine until they release it.
1998
+ */
1999
+ subscribe(listener: () => void): () => void;
2000
+ /**
2001
+ * configure replaces the configuration, and settles the form again only when a member changed.
2002
+ *
2003
+ * A binding calls it on every render, so it compares every member by identity and does nothing
2004
+ * when all are the ones it holds. A changed one seeds what waited on it: a catalog that
2005
+ * arrives seeds the activity, collections that arrive are followed, and a name still following
2006
+ * its parameters is written again in the new language. A parked engine keeps the configuration
2007
+ * for its next read.
2008
+ */
2009
+ configure(config: ZoneFormConfig): void;
2010
+ /**
2011
+ * dispose parks the engine and drops every listener, for good.
2012
+ *
2013
+ * Idempotent, and every call after it is a no-op rather than an error: an owner torn down
2014
+ * mid-save should not have to guard the calls it already queued. A save in flight still reaches
2015
+ * the tool it was sent to; its answer changes nothing here.
2016
+ */
2017
+ dispose(): void;
2018
+ /**
2019
+ * edit writes the given fields, and applies the rule each one carries:
2020
+ *
2021
+ * - `name` makes the name the reader's own, so it stops following the parameters. On a create
2022
+ * whose draft a proposal named it also clears that name from the draft, so the one typed is
2023
+ * shown.
2024
+ * - `name`, `description`, `startAt` and `endAt` clear the previous save's failure.
2025
+ * - `windowOpen: false` clears both bounds, so a hidden window never persists a constraint its
2026
+ * reader cannot see.
2027
+ * - `rangeType` resets `range` to that measure's default and never reinterprets the number,
2028
+ * and a switch to `"distance"` drops the pace, which a distance does not depend on.
2029
+ * - `speedKmh` holds beside a time budget only: on a distance budget it is dropped, so a later
2030
+ * switch to `"time"` starts from the activity's own pace.
2031
+ * - `organizationId` makes the organization the reader's own choice, `null` included: a create
2032
+ * then stays personal beside a `defaultOrganizationId`. On a create whose draft a proposal
2033
+ * filed, or whose draw was armed under another, it is also written on the draft, so the one
2034
+ * picked is shown and saved.
2035
+ * - `level`, while a draw is armed, also runs `studio.zone.setLevel`, which recolours the draft.
2036
+ * A refusal leaves the draft as it was, and the form goes back to the severity it held. On a
2037
+ * create it is also written on the store (`zoneCreatePickedLevel`), which the step of a
2038
+ * proposal that joins the create records, so an undo of the proposal shows it again.
2039
+ *
2040
+ * `rangeType` and `windowOpen` are applied before the fields they reset, so an edit naming both
2041
+ * keeps the value it names. `mode` is the shape a draw is armed with; once armed, and for a
2042
+ * saved zone, the snapshot shows the session's or the zone's own. While the snapshot's
2043
+ * `inherits` is true, `organizationId`, `activityId` and `collectionIds` follow the itinerary
2044
+ * and an edit of one does not hold.
2045
+ *
2046
+ * A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2047
+ */
2048
+ edit(fields: Partial<ZoneFormFields>): void;
2049
+ /**
2050
+ * ask runs one tool and answers its result, or null where the host's bus rejected the call.
2051
+ *
2052
+ * A tool bus's dispatch never rejects, and a host's own may. A call it rejects made no answer:
2053
+ * the rejection is held here, so none is left unhandled by a call the form does not await, and
2054
+ * the caller goes on as it does for a tool that did nothing. A save is awaited by its caller
2055
+ * and is not asked through here: its rejection is the caller's to read.
2056
+ */
2057
+ private ask;
2058
+ /**
2059
+ * recolour sets the armed draft's severity, through `studio.zone.setLevel`. A refusal leaves
2060
+ * the draft painted as it was, and so does a call the bus rejects, so the form goes back to the
2061
+ * severity it held and a create's pick to the one the store held, unless its reader has chosen
2062
+ * another since or the form answers for another subject by then.
2063
+ */
2064
+ private recolour;
2065
+ /**
2066
+ * setMethod switches how a create is authored, through `studio.zone.setCreateMethod`, and
2067
+ * clears the preview's and the save's failures, which described the method left behind. The
2068
+ * same two are cleared when another caller of that tool switches it. A switch the tool refuses
2069
+ * left no method behind: the two failures stand again, for as long as the form answers for the
2070
+ * same create. A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2071
+ */
2072
+ setMethod(method: ZoneCreateMethod): void;
2073
+ /** switchMethod asks for the switch, and puts back what it cleared when the tool refuses. */
2074
+ private switchMethod;
2075
+ /**
2076
+ * beginOriginPick arms the map for the click that places a reachability zone's origin, through
2077
+ * `studio.zone.beginOriginPick`.
2078
+ *
2079
+ * A refusal is kept as the snapshot's `pickFailure`, for as long as the form answers for the
2080
+ * create or the zone the pick was asked for and no later pick was asked.
2081
+ *
2082
+ * A call while parked, or after {@link ZoneFormEngine.dispose}, does nothing.
2083
+ */
2084
+ beginOriginPick(): void;
2085
+ /** pick asks for the origin pick, and keeps a refusal while it is the latest and its form's. */
2086
+ private pick;
2087
+ /**
2088
+ * beginDraw arms the map to draw a new zone, through `studio.zone.editBegin`, in the form's
2089
+ * shape and severity and under its organization. The zone's id is minted by the `ids` seam: a
2090
+ * zone cannot persist empty, so the draw session needs a handle before there is a zone to name.
2091
+ *
2092
+ * A refusal is kept as the snapshot's `drawFailure`, for as long as the form answers for the
2093
+ * create the draw was asked for.
2094
+ *
2095
+ * It does nothing while a zone is bound, while a draw or a reshape is armed, while an earlier
2096
+ * call is still unanswered, while no shape is chosen, while parked, or after
2097
+ * {@link ZoneFormEngine.dispose}.
2098
+ */
2099
+ beginDraw(): void;
2100
+ /** draw asks for the draw session, and keeps a refusal while its create is the form's. */
2101
+ private draw;
2102
+ /**
2103
+ * save persists the form through the one tool call {@link zoneSaveRequest} routes it to, and
2104
+ * resolves once the tool has answered. It resolves at once, having sent nothing, when a save
2105
+ * of the same zone or the same create is already in flight, when the form has nothing to
2106
+ * send, while parked, and after {@link ZoneFormEngine.dispose}. A save in flight for another
2107
+ * zone holds back no save of this one.
2108
+ *
2109
+ * A refusal is kept as the snapshot's `saveFailure` and the fields stay as typed, so a retry is
2110
+ * one more call. A refusal that lands once the form answers for another zone, or once a create
2111
+ * has switched method or changed the itinerary it inherits from, is dropped: it describes a
2112
+ * form nobody is looking at. One that lands once the form has come back to the zone or the
2113
+ * create it was sent for is kept, since the snapshot read `saving` for it all along. A refusal
2114
+ * of the reachability query the fields stated as the save left is kept as the snapshot's
2115
+ * `sourceFailure` instead, for the surface to show at the query's fields. A create
2116
+ * that lost some of its collections raises a warning through `studio.alert.show`: the zone
2117
+ * exists, and the reader should know where it was not filed.
2118
+ *
2119
+ * It never rejects while `dispatch` does not.
2120
+ */
2121
+ save(): Promise<void>;
2122
+ /** run dispatches a save request, each arm with its own tool's input. */
2123
+ private run;
2124
+ /** saveRequest routes the form as it stands to the tool call that persists it, or to null. */
2125
+ private saveRequest;
2126
+ /** statedSource is the reachability query the fields state as the store stands, or null. */
2127
+ private statedSource;
2128
+ /**
2129
+ * publishUnsaved writes whether the form holds something unsaved on the store's
2130
+ * `zoneFormUnsaved`, where `studio.zone.publish` and the publication band read it, when that
2131
+ * answer moved. A parked engine writes nothing: its reads run inside a render, and a form
2132
+ * nobody watches holds nothing for anyone to lose.
2133
+ *
2134
+ * The store hears of the write at once, and so does this engine's own watch, which finds no slot
2135
+ * it reads moved and runs no pass.
2136
+ */
2137
+ private publishUnsaved;
2138
+ /**
2139
+ * park stops watching the store, drops the pending preview and forgets the one in flight. The
2140
+ * unsaved answer it wrote is taken back: a form that unmounts holds nothing any more.
2141
+ */
2142
+ private park;
2143
+ /** settle brings a parked engine's snapshot in line with the store and the configuration. */
2144
+ private settle;
2145
+ /**
2146
+ * watch answers one notification of the store: it runs a pass when a slot the form reads
2147
+ * moved, and nothing otherwise, so a hover or a selection costs the form one comparison.
2148
+ */
2149
+ private watch;
2150
+ /**
2151
+ * reconcile seeds the fields from the store and the configuration, publishes the snapshot and
2152
+ * follows the preview it is worth. A change made while it runs, by a listener or by a tool a
2153
+ * preview runs at once, runs it again once it finishes rather than inside it.
2154
+ */
2155
+ private reconcile;
2156
+ /** seed brings the fields in line with the bound zone, the create's context and the catalog. */
2157
+ private seed;
2158
+ /**
2159
+ * seedParameters brings the reachability parameters in line with the query `zone` is stored
2160
+ * with and with the catalog, and drops an activity the catalog lists no more.
2161
+ */
2162
+ private seedParameters;
2163
+ /**
2164
+ * seedMetadata seeds what a zone says from `zone`, and from a create's defaults for none: the
2165
+ * name, the description, the window and the severity.
2166
+ */
2167
+ private seedMetadata;
2168
+ /**
2169
+ * follow brings the fields in line with the bound zone written again: `previous` is what it
2170
+ * said and `next` what it says now.
2171
+ *
2172
+ * A field the reader has not moved off what the zone said takes what it says now, and so does
2173
+ * one that already says it, which is how the reader's own save lands in its stored spelling.
2174
+ * Any other is what the reader typed and has not saved, and stays. The window is one answer,
2175
+ * its bounds and whether it is open, taken whole from the reader once they moved any of it,
2176
+ * so no bound a collaborator chose is ever paired with one the reader did.
2177
+ *
2178
+ * The severity of a reshape armed on the zone is shown over the form's own, so it follows by
2179
+ * the same rule: while `session` still paints the severity the zone said, it is set to the one
2180
+ * the zone says now, through `studio.zone.setLevel`. One the reader moved is theirs and stays.
2181
+ * Left as it was, the form would read unsaved after a collaborator's change of severity, and
2182
+ * its save would write the old one back.
2183
+ */
2184
+ private follow;
2185
+ /**
2186
+ * resetCreate returns the fields a create seeds for itself to a create's defaults: where it is
2187
+ * filed, the shape it is drawn in and the parameters it is computed from. What the zone says
2188
+ * is seeded from the zone, bound or not.
2189
+ */
2190
+ private resetCreate;
2191
+ /** activityName is the chosen activity's name in the reader's language, or null. */
2192
+ private activityName;
2193
+ /** sourceFor is the reachability query the fields state under `facts`, or null. */
2194
+ private sourceFor;
2195
+ /** view reads the form as it stands under `facts`. */
2196
+ private view;
2197
+ /**
2198
+ * judge holds a name and a description to the bounds the tools hold them to. It parses only a
2199
+ * text it has not just judged, so a pass that moved neither, a drag's every frame among them,
2200
+ * parses nothing.
2201
+ */
2202
+ private judge;
2203
+ /** commit publishes `next` when it differs from the snapshot, and tells every listener. */
2204
+ private commit;
2205
+ /**
2206
+ * followPreview asks for the preview `view` is worth, after the debounce, unless that very
2207
+ * preview is already asked for or waited on. A parked engine asks for none.
2208
+ */
2209
+ private followPreview;
2210
+ /** askPreview runs the preview waited on, and keeps its answer while its question stands. */
2211
+ private askPreview;
2212
+ private cancelPending;
2213
+ }
2214
+
2215
+ export { EmbedFramingEngine, EmbedReadyEngine, FRAMING_PAGE_SESSION_TIMEOUT_MS, ItineraryPaceEngine, ProfileMarkerEngine, SegmentDraftEngine, ZoneFormEngine, askFramingPageForSession };
2216
+ export type { AskFramingPageForSessionOptions, EmbedFramingCollection, EmbedFramingConfig, EmbedFramingSnapshot, EmbedReadyConfig, EmbedReadyEngineOptions, EmbedReadySnapshot, FramingPageMessage, FramingPageWindow, ItineraryPaceConfig, ItineraryPaceEngineOptions, ItineraryPaceResult, ProfileMarkerEngineOptions, SegmentDraftConfig, SegmentDraftContext, SegmentDraftEngineOptions, SegmentDraftEngineSnapshot, ZoneFormConfig, ZoneFormDispatch, ZoneFormEngineOptions, ZoneFormSnapshot };