@mountaya/studio 0.0.0-stage → 0.2.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 (521) hide show
  1. package/CHANGELOG.md +69 -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 +2600 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1237 -0
  8. package/dist/agent/index.d.ts +1237 -0
  9. package/dist/agent/index.js +2581 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/chunk-3Oi_Zrtm.js +9 -0
  12. package/dist/chunk-3Oi_Zrtm.js.map +1 -0
  13. package/dist/chunk-B18OPIu_.js +6 -0
  14. package/dist/chunk-B18OPIu_.js.map +1 -0
  15. package/dist/chunk-B5Uz3Qct.cjs +15 -0
  16. package/dist/chunk-B5Uz3Qct.cjs.map +1 -0
  17. package/dist/chunk-BBEJwkd3.d.cts +839 -0
  18. package/dist/chunk-BIEc_SkR.cjs +29 -0
  19. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  20. package/dist/chunk-BKMFOe-N.js +171 -0
  21. package/dist/chunk-BKMFOe-N.js.map +1 -0
  22. package/dist/chunk-BP4uy7E1.d.ts +11583 -0
  23. package/dist/chunk-BSHTsFiB.js +1403 -0
  24. package/dist/chunk-BSHTsFiB.js.map +1 -0
  25. package/dist/chunk-BTUUABGI.js +17 -0
  26. package/dist/chunk-BTUUABGI.js.map +1 -0
  27. package/dist/chunk-BaPiaz5X.cjs +115 -0
  28. package/dist/chunk-BaPiaz5X.cjs.map +1 -0
  29. package/dist/chunk-BeCVpkYr.cjs +542 -0
  30. package/dist/chunk-BeCVpkYr.cjs.map +1 -0
  31. package/dist/chunk-BgngsvK8.cjs +6202 -0
  32. package/dist/chunk-BgngsvK8.cjs.map +1 -0
  33. package/dist/chunk-BhInd7CJ.d.cts +253 -0
  34. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  35. package/dist/chunk-By9ZnkVI.js +60 -0
  36. package/dist/chunk-By9ZnkVI.js.map +1 -0
  37. package/dist/chunk-BzqPhxsz.cjs +367 -0
  38. package/dist/chunk-BzqPhxsz.cjs.map +1 -0
  39. package/dist/chunk-C2mMX81q.d.ts +443 -0
  40. package/dist/chunk-C2rr9Q0V.cjs +1402 -0
  41. package/dist/chunk-C2rr9Q0V.cjs.map +1 -0
  42. package/dist/chunk-CDJCbwIQ.d.cts +78 -0
  43. package/dist/chunk-CLGvBOVH.d.cts +1654 -0
  44. package/dist/chunk-COdw1dc6.d.ts +525 -0
  45. package/dist/chunk-CQCJnT2i.d.ts +511 -0
  46. package/dist/chunk-CSyHY67q.cjs +353 -0
  47. package/dist/chunk-CSyHY67q.cjs.map +1 -0
  48. package/dist/chunk-CiK1Iqrv.js +950 -0
  49. package/dist/chunk-CiK1Iqrv.js.map +1 -0
  50. package/dist/chunk-CmJBgSwZ.cjs +24 -0
  51. package/dist/chunk-CmJBgSwZ.cjs.map +1 -0
  52. package/dist/chunk-CnrsRK2u.cjs +83 -0
  53. package/dist/chunk-CnrsRK2u.cjs.map +1 -0
  54. package/dist/chunk-Co782_9r.js +326 -0
  55. package/dist/chunk-Co782_9r.js.map +1 -0
  56. package/dist/chunk-Csr3KDpZ.cjs +32 -0
  57. package/dist/chunk-Csr3KDpZ.cjs.map +1 -0
  58. package/dist/chunk-CwkmccXv.js +89 -0
  59. package/dist/chunk-CwkmccXv.js.map +1 -0
  60. package/dist/chunk-D0Q4iL9B.cjs +255 -0
  61. package/dist/chunk-D0Q4iL9B.cjs.map +1 -0
  62. package/dist/chunk-DFwiSzUS.cjs +72 -0
  63. package/dist/chunk-DFwiSzUS.cjs.map +1 -0
  64. package/dist/chunk-DIFayl2P.d.cts +443 -0
  65. package/dist/chunk-DIGF58ux.d.cts +525 -0
  66. package/dist/chunk-DKuuuld5.js +101 -0
  67. package/dist/chunk-DKuuuld5.js.map +1 -0
  68. package/dist/chunk-DMePkFEo.js +5054 -0
  69. package/dist/chunk-DMePkFEo.js.map +1 -0
  70. package/dist/chunk-DO5SIBgu.js +305 -0
  71. package/dist/chunk-DO5SIBgu.js.map +1 -0
  72. package/dist/chunk-DOQ_7eE5.d.ts +6662 -0
  73. package/dist/chunk-DThaaNeb.d.cts +15 -0
  74. package/dist/chunk-DThaaNeb.d.ts +15 -0
  75. package/dist/chunk-DUQzjUJy.d.ts +78 -0
  76. package/dist/chunk-DX37IPhV.cjs +1903 -0
  77. package/dist/chunk-DX37IPhV.cjs.map +1 -0
  78. package/dist/chunk-Damps5Tk.cjs +155 -0
  79. package/dist/chunk-Damps5Tk.cjs.map +1 -0
  80. package/dist/chunk-DbK5PhpJ.d.ts +1654 -0
  81. package/dist/chunk-De0vAASv.d.ts +253 -0
  82. package/dist/chunk-DhSZ7YZt.d.cts +6662 -0
  83. package/dist/chunk-DjEvqvPA.cjs +43 -0
  84. package/dist/chunk-DjEvqvPA.cjs.map +1 -0
  85. package/dist/chunk-DkwDzwvu.d.cts +121 -0
  86. package/dist/chunk-DkwDzwvu.d.ts +121 -0
  87. package/dist/chunk-Dmszv9If.js +71 -0
  88. package/dist/chunk-Dmszv9If.js.map +1 -0
  89. package/dist/chunk-Dp_ftNWY.d.cts +511 -0
  90. package/dist/chunk-DsHQySz0.js +31 -0
  91. package/dist/chunk-DsHQySz0.js.map +1 -0
  92. package/dist/chunk-DwoUyHHh.js +281 -0
  93. package/dist/chunk-DwoUyHHh.js.map +1 -0
  94. package/dist/chunk-IaIDQflj.d.cts +2315 -0
  95. package/dist/chunk-IaIDQflj.d.ts +2315 -0
  96. package/dist/chunk-cVXLsZfL.d.ts +839 -0
  97. package/dist/chunk-mIaCX9EJ.d.cts +11583 -0
  98. package/dist/chunk-nJQxbOwQ.cjs +8962 -0
  99. package/dist/chunk-nJQxbOwQ.cjs.map +1 -0
  100. package/dist/chunk-o9jaxhCO.js +8852 -0
  101. package/dist/chunk-o9jaxhCO.js.map +1 -0
  102. package/dist/chunk-p-Tt_Lwz.js +14 -0
  103. package/dist/chunk-p-Tt_Lwz.js.map +1 -0
  104. package/dist/engines/index.cjs +2091 -0
  105. package/dist/engines/index.cjs.map +1 -0
  106. package/dist/engines/index.d.cts +2176 -0
  107. package/dist/engines/index.d.ts +2176 -0
  108. package/dist/engines/index.js +2075 -0
  109. package/dist/engines/index.js.map +1 -0
  110. package/dist/handlers/index.cjs +53 -0
  111. package/dist/handlers/index.cjs.map +1 -0
  112. package/dist/handlers/index.d.cts +403 -0
  113. package/dist/handlers/index.d.ts +403 -0
  114. package/dist/handlers/index.js +33 -0
  115. package/dist/handlers/index.js.map +1 -0
  116. package/dist/index.cjs +3511 -0
  117. package/dist/index.cjs.map +1 -0
  118. package/dist/index.d.cts +8 -0
  119. package/dist/index.d.ts +8 -0
  120. package/dist/index.js +3033 -0
  121. package/dist/index.js.map +1 -0
  122. package/dist/plugins/index.cjs +510 -0
  123. package/dist/plugins/index.cjs.map +1 -0
  124. package/dist/plugins/index.d.cts +296 -0
  125. package/dist/plugins/index.d.ts +296 -0
  126. package/dist/plugins/index.js +489 -0
  127. package/dist/plugins/index.js.map +1 -0
  128. package/dist/seams/index.cjs +89 -0
  129. package/dist/seams/index.cjs.map +1 -0
  130. package/dist/seams/index.d.cts +452 -0
  131. package/dist/seams/index.d.ts +452 -0
  132. package/dist/seams/index.js +49 -0
  133. package/dist/seams/index.js.map +1 -0
  134. package/dist/strings/fr/index.cjs +2135 -0
  135. package/dist/strings/fr/index.cjs.map +1 -0
  136. package/dist/strings/fr/index.d.cts +17 -0
  137. package/dist/strings/fr/index.d.ts +17 -0
  138. package/dist/strings/fr/index.js +2130 -0
  139. package/dist/strings/fr/index.js.map +1 -0
  140. package/dist/strings/index.cjs +2384 -0
  141. package/dist/strings/index.cjs.map +1 -0
  142. package/dist/strings/index.d.cts +3 -0
  143. package/dist/strings/index.d.ts +3 -0
  144. package/dist/strings/index.js +2353 -0
  145. package/dist/strings/index.js.map +1 -0
  146. package/dist/testing/index.cjs +230 -0
  147. package/dist/testing/index.cjs.map +1 -0
  148. package/dist/testing/index.d.cts +246 -0
  149. package/dist/testing/index.d.ts +246 -0
  150. package/dist/testing/index.js +219 -0
  151. package/dist/testing/index.js.map +1 -0
  152. package/dist/time/index.cjs +28 -0
  153. package/dist/time/index.cjs.map +1 -0
  154. package/dist/time/index.d.cts +41 -0
  155. package/dist/time/index.d.ts +41 -0
  156. package/dist/time/index.js +23 -0
  157. package/dist/time/index.js.map +1 -0
  158. package/package.json +224 -4
  159. package/src/agent/engines/agentThreads.ts +1601 -0
  160. package/src/agent/engines/directorChat.ts +500 -0
  161. package/src/agent/index.ts +67 -0
  162. package/src/agent/rules/agentEditLock.ts +115 -0
  163. package/src/agent/rules/agentErrorCopy.ts +44 -0
  164. package/src/agent/rules/copilotOrganization.ts +36 -0
  165. package/src/agent/rules/playbook.gen.ts +444 -0
  166. package/src/agent/rules/router.ts +518 -0
  167. package/src/agent/rules/stateDelta.ts +29 -0
  168. package/src/agent/rules/studioRouter.ts +123 -0
  169. package/src/agent/rules/surfaces.gen.ts +633 -0
  170. package/src/agent/rules/threadsUrl.ts +48 -0
  171. package/src/agent/rules/transcriptObserver.ts +90 -0
  172. package/src/agent/stores/agentThreads.ts +451 -0
  173. package/src/bus/contracts/noData.ts +18 -0
  174. package/src/bus/contracts/shared.ts +172 -0
  175. package/src/bus/contracts/studioTools.ts +224 -0
  176. package/src/bus/rules/bus.ts +857 -0
  177. package/src/bus/rules/confirmation.ts +22 -0
  178. package/src/bus/rules/defineRegistry.ts +24 -0
  179. package/src/bus/rules/errors.ts +401 -0
  180. package/src/bus/rules/handlerErrors.ts +103 -0
  181. package/src/bus/rules/handlerRegistry.ts +627 -0
  182. package/src/bus/rules/inputSchema.ts +232 -0
  183. package/src/bus/rules/invalidInput.ts +441 -0
  184. package/src/bus/rules/lateBoundTools.ts +100 -0
  185. package/src/bus/rules/studioRegistry.ts +324 -0
  186. package/src/bus/rules/studioToolBus.ts +73 -0
  187. package/src/bus/rules/types.ts +804 -0
  188. package/src/chrome/contracts/alert.ts +42 -0
  189. package/src/chrome/contracts/itinerary.ts +26 -0
  190. package/src/chrome/contracts/map.ts +23 -0
  191. package/src/chrome/contracts/overlay.ts +46 -0
  192. package/src/chrome/contracts/panel.ts +29 -0
  193. package/src/chrome/contracts/question.ts +52 -0
  194. package/src/chrome/contracts/selection.ts +26 -0
  195. package/src/chrome/contracts/sidenav.ts +23 -0
  196. package/src/chrome/contracts/snapshot.ts +319 -0
  197. package/src/chrome/contracts/state.ts +22 -0
  198. package/src/chrome/contracts/tabs.ts +56 -0
  199. package/src/chrome/handlers/alert.ts +91 -0
  200. package/src/chrome/handlers/introspection.ts +180 -0
  201. package/src/chrome/handlers/panels.ts +42 -0
  202. package/src/chrome/handlers/question.ts +24 -0
  203. package/src/chrome/handlers/sidenav.ts +116 -0
  204. package/src/chrome/handlers/snapshot.ts +451 -0
  205. package/src/chrome/handlers/stateDelta.ts +125 -0
  206. package/src/chrome/handlers/tabs.ts +143 -0
  207. package/src/chrome/handlers/timestamp.ts +19 -0
  208. package/src/chrome/rules/agentSelectors.ts +210 -0
  209. package/src/chrome/rules/mapAlert.ts +13 -0
  210. package/src/chrome/rules/question.ts +25 -0
  211. package/src/chrome/rules/tabs.ts +13 -0
  212. package/src/chrome/stores/activeDraftSession.ts +134 -0
  213. package/src/chrome/stores/chrome.ts +527 -0
  214. package/src/chrome/stores/uiStore.ts +575 -0
  215. package/src/collab/contracts/collab.ts +261 -0
  216. package/src/collab/handlers/collab.ts +468 -0
  217. package/src/collab/rules/toolNames.ts +33 -0
  218. package/src/collab/stores/collab.ts +899 -0
  219. package/src/collections/contracts/collection.ts +182 -0
  220. package/src/collections/handlers/collectionAttach.ts +141 -0
  221. package/src/collections/handlers/collections.ts +499 -0
  222. package/src/collections/handlers/heldCollection.ts +42 -0
  223. package/src/collections/handlers/restCollections.ts +386 -0
  224. package/src/collections/rules/collections.ts +138 -0
  225. package/src/collections/rules/entityCollections.ts +53 -0
  226. package/src/collections/stores/collections.ts +133 -0
  227. package/src/data/contracts/data.ts +233 -0
  228. package/src/data/contracts/itinerary.ts +71 -0
  229. package/src/data/handlers/activityResolve.ts +76 -0
  230. package/src/data/handlers/data.ts +200 -0
  231. package/src/data/handlers/graphql.ts +26 -0
  232. package/src/data/handlers/mutationSink.ts +1577 -0
  233. package/src/data/handlers/profile.ts +83 -0
  234. package/src/data/handlers/writeThrough.ts +417 -0
  235. package/src/data/rules/cache.ts +181 -0
  236. package/src/data/rules/dataTypes.ts +40 -0
  237. package/src/data/rules/keys.ts +106 -0
  238. package/src/data/rules/persistence.ts +1058 -0
  239. package/src/data/rules/requestBody.ts +43 -0
  240. package/src/data/rules/restErrors.ts +354 -0
  241. package/src/data/rules/sessionSurface.ts +156 -0
  242. package/src/data/rules/toolResultData.ts +73 -0
  243. package/src/data/rules/uuid.ts +24 -0
  244. package/src/edit/contracts/edit.ts +37 -0
  245. package/src/edit/contracts/itinerary.ts +57 -0
  246. package/src/edit/handlers/draftCommit.ts +257 -0
  247. package/src/edit/handlers/editDiscard.ts +34 -0
  248. package/src/edit/handlers/editLock.ts +949 -0
  249. package/src/edit/handlers/editor.ts +203 -0
  250. package/src/edit/handlers/formUnsaved.ts +24 -0
  251. package/src/edit/rules/draftMetadata.ts +117 -0
  252. package/src/edit/rules/editKeyboard.ts +222 -0
  253. package/src/edit/rules/editShortcuts.ts +102 -0
  254. package/src/edit/rules/editTooltip.ts +174 -0
  255. package/src/edit/rules/editorTaken.ts +49 -0
  256. package/src/edit/rules/history.ts +26 -0
  257. package/src/edit/rules/unsavedWork.ts +60 -0
  258. package/src/edit/stores/editorReservation.ts +70 -0
  259. package/src/edit/stores/formsUnsaved.ts +54 -0
  260. package/src/embed/contracts/embed.ts +48 -0
  261. package/src/embed/engines/embedFraming.ts +1329 -0
  262. package/src/embed/engines/embedReady.ts +353 -0
  263. package/src/embed/engines/framingPageSession.ts +169 -0
  264. package/src/embed/handlers/embed.ts +130 -0
  265. package/src/embed/rules/allowedDomains.ts +71 -0
  266. package/src/embed/rules/bridgeMessages.ts +224 -0
  267. package/src/embed/rules/defaults.ts +173 -0
  268. package/src/embed/rules/displaySeed.ts +115 -0
  269. package/src/embed/rules/embedAllowlist.ts +146 -0
  270. package/src/embed/rules/embedConstraints.ts +215 -0
  271. package/src/embed/rules/embedElements.ts +277 -0
  272. package/src/embed/rules/embedSectionFields.ts +126 -0
  273. package/src/embed/rules/embedSecurity.ts +116 -0
  274. package/src/embed/rules/fieldDependencies.ts +89 -0
  275. package/src/embed/rules/fieldOptions.ts +138 -0
  276. package/src/embed/rules/layerOptions.ts +161 -0
  277. package/src/embed/rules/readyProtocol.ts +66 -0
  278. package/src/embed/rules/safetyRules.ts +215 -0
  279. package/src/embed/rules/snippet.ts +531 -0
  280. package/src/embed/rules/tableCode.ts +270 -0
  281. package/src/embed/stores/embed.ts +60 -0
  282. package/src/embed/stores/embedContent.ts +77 -0
  283. package/src/engines/index.ts +81 -0
  284. package/src/handlers/index.ts +66 -0
  285. package/src/index.ts +1065 -0
  286. package/src/itinerary/contracts/itinerary.ts +705 -0
  287. package/src/itinerary/engines/itineraryPace.ts +612 -0
  288. package/src/itinerary/engines/profileMarker.ts +238 -0
  289. package/src/itinerary/handlers/importStaging.ts +352 -0
  290. package/src/itinerary/handlers/itinerary.ts +572 -0
  291. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  292. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  293. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  294. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  295. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  296. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  297. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  298. package/src/itinerary/handlers/publicationScope.ts +118 -0
  299. package/src/itinerary/handlers/restItineraries.ts +752 -0
  300. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  301. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  302. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  303. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  304. package/src/itinerary/handlers/suggestParams.ts +379 -0
  305. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  306. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  307. package/src/itinerary/rules/activity.ts +139 -0
  308. package/src/itinerary/rules/analysis.ts +42 -0
  309. package/src/itinerary/rules/ceiling.ts +49 -0
  310. package/src/itinerary/rules/createFlow.ts +107 -0
  311. package/src/itinerary/rules/densify.ts +440 -0
  312. package/src/itinerary/rules/draftSurface.ts +219 -0
  313. package/src/itinerary/rules/editorView.ts +83 -0
  314. package/src/itinerary/rules/export.ts +159 -0
  315. package/src/itinerary/rules/friendlyName.ts +77 -0
  316. package/src/itinerary/rules/import.ts +1050 -0
  317. package/src/itinerary/rules/importFiles.ts +140 -0
  318. package/src/itinerary/rules/importTotals.ts +77 -0
  319. package/src/itinerary/rules/liveSegment.ts +712 -0
  320. package/src/itinerary/rules/lngLat.ts +17 -0
  321. package/src/itinerary/rules/mapSync.ts +100 -0
  322. package/src/itinerary/rules/previewRender.ts +416 -0
  323. package/src/itinerary/rules/profileReadout.ts +216 -0
  324. package/src/itinerary/rules/routing.ts +707 -0
  325. package/src/itinerary/rules/suggest.ts +522 -0
  326. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  327. package/src/itinerary/rules/view.ts +61 -0
  328. package/src/itinerary/stores/importSession.ts +319 -0
  329. package/src/itinerary/stores/itinerary.ts +331 -0
  330. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  331. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  332. package/src/itinerary/stores/suggestSession.ts +418 -0
  333. package/src/layers/contracts/itinerary.ts +46 -0
  334. package/src/layers/contracts/overlay.ts +132 -0
  335. package/src/layers/handlers/enrichment.ts +36 -0
  336. package/src/layers/handlers/overlay.ts +406 -0
  337. package/src/layers/handlers/restLayers.ts +94 -0
  338. package/src/layers/handlers/tiles.ts +25 -0
  339. package/src/layers/rules/layers.ts +212 -0
  340. package/src/layers/rules/overlayInstant.ts +12 -0
  341. package/src/layers/rules/reachabilityIcon.ts +18 -0
  342. package/src/layers/rules/readout.ts +102 -0
  343. package/src/layers/stores/layers.ts +262 -0
  344. package/src/map/contracts/contextmenu.ts +33 -0
  345. package/src/map/contracts/geolocate.ts +37 -0
  346. package/src/map/contracts/map.ts +146 -0
  347. package/src/map/contracts/streetview.ts +53 -0
  348. package/src/map/contracts/terrain.ts +152 -0
  349. package/src/map/handlers/contextMenu.ts +135 -0
  350. package/src/map/handlers/geolocate.ts +52 -0
  351. package/src/map/handlers/map.ts +391 -0
  352. package/src/map/handlers/streetview.ts +94 -0
  353. package/src/map/handlers/terrain.ts +663 -0
  354. package/src/map/rules/baseTerrain.ts +75 -0
  355. package/src/map/rules/clickTargets.ts +464 -0
  356. package/src/map/rules/constraints.ts +32 -0
  357. package/src/map/rules/contextMenuReadout.ts +67 -0
  358. package/src/map/rules/coordinates.ts +71 -0
  359. package/src/map/rules/itineraryFit.ts +8 -0
  360. package/src/map/rules/mapEvents.ts +64 -0
  361. package/src/map/rules/mapProjection.ts +476 -0
  362. package/src/map/rules/terrainReading.ts +62 -0
  363. package/src/plugins/contracts/ids.ts +66 -0
  364. package/src/plugins/contracts/plugin.ts +202 -0
  365. package/src/plugins/contracts/slots.ts +137 -0
  366. package/src/plugins/engines/studioPlugin.ts +1365 -0
  367. package/src/plugins/index.ts +111 -0
  368. package/src/plugins/rules/contributions.ts +152 -0
  369. package/src/plugins/rules/errors.ts +60 -0
  370. package/src/plugins/rules/ids.ts +42 -0
  371. package/src/plugins/rules/validation.ts +249 -0
  372. package/src/rules/listeners.ts +57 -0
  373. package/src/rules/origin.ts +13 -0
  374. package/src/rules/storeWrite.ts +37 -0
  375. package/src/rules/types.ts +136 -0
  376. package/src/seams/index.ts +79 -0
  377. package/src/seams/rules/clock.ts +28 -0
  378. package/src/seams/rules/formatters.ts +211 -0
  379. package/src/seams/rules/ids.ts +102 -0
  380. package/src/seams/rules/links.ts +66 -0
  381. package/src/seams/rules/navigation.ts +222 -0
  382. package/src/seams/rules/notify.ts +49 -0
  383. package/src/seams/rules/persistenceDrawer.ts +220 -0
  384. package/src/seams/rules/saveFile.ts +101 -0
  385. package/src/seams/rules/seams.ts +156 -0
  386. package/src/seams/rules/storage.ts +116 -0
  387. package/src/search/contracts/overlay.ts +74 -0
  388. package/src/search/contracts/search.ts +197 -0
  389. package/src/search/handlers/pois.ts +57 -0
  390. package/src/search/handlers/search.ts +280 -0
  391. package/src/search/rules/params.ts +925 -0
  392. package/src/search/rules/poiGroups.ts +138 -0
  393. package/src/search/rules/searchFetch.ts +139 -0
  394. package/src/search/rules/timeWindow.ts +30 -0
  395. package/src/search/stores/search.ts +51 -0
  396. package/src/segments/contracts/itinerary.ts +433 -0
  397. package/src/segments/contracts/segment.ts +35 -0
  398. package/src/segments/engines/segmentDraft.ts +926 -0
  399. package/src/segments/handlers/chainGuards.ts +67 -0
  400. package/src/segments/handlers/directions.ts +44 -0
  401. package/src/segments/handlers/itineraryEcho.ts +45 -0
  402. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  403. package/src/segments/handlers/segment.ts +111 -0
  404. package/src/segments/handlers/segmentEdit.ts +1341 -0
  405. package/src/segments/handlers/segmentGroups.ts +347 -0
  406. package/src/segments/handlers/segmentStructure.ts +1144 -0
  407. package/src/segments/rules/chain.ts +196 -0
  408. package/src/segments/rules/chainModel.ts +217 -0
  409. package/src/segments/rules/colors.ts +11 -0
  410. package/src/segments/rules/commit.ts +76 -0
  411. package/src/segments/rules/draft.ts +90 -0
  412. package/src/segments/rules/draftDisposition.ts +43 -0
  413. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  414. package/src/segments/rules/engine.ts +222 -0
  415. package/src/segments/rules/groupSave.ts +234 -0
  416. package/src/segments/rules/hazardPrompt.ts +60 -0
  417. package/src/segments/rules/itineraryEcho.ts +40 -0
  418. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  419. package/src/segments/rules/merge.ts +51 -0
  420. package/src/segments/rules/metrics.ts +456 -0
  421. package/src/segments/rules/naming.ts +168 -0
  422. package/src/segments/rules/segmentArming.ts +144 -0
  423. package/src/segments/rules/splitPick.ts +84 -0
  424. package/src/segments/rules/viaSimplify.ts +230 -0
  425. package/src/segments/stores/directions.ts +77 -0
  426. package/src/segments/stores/roadAccessDialog.ts +58 -0
  427. package/src/segments/stores/segmentEdit.ts +922 -0
  428. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  429. package/src/segments/stores/segmentSplit.ts +77 -0
  430. package/src/share/contracts/share.ts +39 -0
  431. package/src/share/contracts/shareLink.ts +63 -0
  432. package/src/share/engines/shareLink.ts +1053 -0
  433. package/src/share/handlers/share.ts +47 -0
  434. package/src/share/handlers/shareLink.ts +231 -0
  435. package/src/share/handlers/shareScope.ts +54 -0
  436. package/src/share/rules/link.ts +89 -0
  437. package/src/share/rules/shareLink.ts +218 -0
  438. package/src/share/rules/targets.ts +92 -0
  439. package/src/share/rules/viewConfig.ts +95 -0
  440. package/src/share/stores/share.ts +58 -0
  441. package/src/strings/fr/index.ts +18 -0
  442. package/src/strings/fr/rules/fr.ts +2368 -0
  443. package/src/strings/index.ts +98 -0
  444. package/src/strings/rules/confirmCopy.ts +156 -0
  445. package/src/strings/rules/draftToolNames.ts +94 -0
  446. package/src/strings/rules/en.ts +2519 -0
  447. package/src/strings/rules/failureAlert.ts +115 -0
  448. package/src/strings/rules/formError.ts +400 -0
  449. package/src/strings/rules/maneuvers.ts +107 -0
  450. package/src/strings/rules/outputOptions.ts +126 -0
  451. package/src/strings/rules/publicationState.ts +100 -0
  452. package/src/strings/rules/routeHazardCopy.ts +62 -0
  453. package/src/strings/rules/searchLabels.ts +50 -0
  454. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  455. package/src/strings/rules/studioCopy.ts +130 -0
  456. package/src/strings/rules/unitOptions.ts +119 -0
  457. package/src/testing/checkedBus.ts +226 -0
  458. package/src/testing/index.ts +30 -0
  459. package/src/testing/plugins.ts +106 -0
  460. package/src/testing/studio.ts +267 -0
  461. package/src/testing/urlSeam.ts +153 -0
  462. package/src/time/index.ts +12 -0
  463. package/src/time/rules/sun.ts +78 -0
  464. package/src/video/contracts/cameraSchemas.ts +266 -0
  465. package/src/video/contracts/profileSchemas.ts +37 -0
  466. package/src/video/contracts/video.ts +601 -0
  467. package/src/video/handlers/video.ts +1638 -0
  468. package/src/video/handlers/videoDirector.ts +114 -0
  469. package/src/video/rules/previewRefresh.ts +76 -0
  470. package/src/video/rules/profileSource.ts +51 -0
  471. package/src/video/rules/routeSpans.ts +79 -0
  472. package/src/video/rules/shotDefaults.ts +28 -0
  473. package/src/video/rules/stepOrder.ts +17 -0
  474. package/src/video/rules/videoSnapshot.ts +136 -0
  475. package/src/video/stores/directorThreads.ts +167 -0
  476. package/src/video/stores/videoExport.ts +290 -0
  477. package/src/viewer/contracts/preferences.ts +40 -0
  478. package/src/viewer/handlers/preferences.ts +91 -0
  479. package/src/viewer/rules/capabilities.ts +42 -0
  480. package/src/viewer/rules/config.ts +266 -0
  481. package/src/viewer/rules/context.ts +375 -0
  482. package/src/viewer/rules/ownership.ts +134 -0
  483. package/src/viewer/rules/platformViewer.ts +199 -0
  484. package/src/viewer/rules/scope.ts +197 -0
  485. package/src/viewer/rules/url.ts +145 -0
  486. package/src/viewer/rules/viewer.ts +307 -0
  487. package/src/viewer/rules/viewerSeam.ts +49 -0
  488. package/src/viewer/rules/viewerUnits.ts +34 -0
  489. package/src/waypoints/contracts/itinerary.ts +417 -0
  490. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  491. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  492. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  493. package/src/waypoints/rules/amenities.ts +30 -0
  494. package/src/waypoints/rules/defaults.ts +31 -0
  495. package/src/waypoints/rules/details.ts +213 -0
  496. package/src/waypoints/rules/detailsDraft.ts +312 -0
  497. package/src/waypoints/rules/detailsPreview.ts +76 -0
  498. package/src/waypoints/rules/detailsSave.ts +356 -0
  499. package/src/waypoints/rules/draftDirty.ts +45 -0
  500. package/src/waypoints/rules/icons.ts +32 -0
  501. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  502. package/src/waypoints/rules/naming.ts +185 -0
  503. package/src/waypoints/rules/sections.ts +77 -0
  504. package/src/waypoints/rules/waypointDraft.ts +62 -0
  505. package/src/waypoints/stores/waypointDetails.ts +62 -0
  506. package/src/waypoints/stores/waypointEdit.ts +566 -0
  507. package/src/zones/contracts/collection.ts +37 -0
  508. package/src/zones/contracts/zone.ts +528 -0
  509. package/src/zones/engines/zoneForm.ts +1773 -0
  510. package/src/zones/handlers/restZones.ts +287 -0
  511. package/src/zones/handlers/zonePublish.ts +206 -0
  512. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  513. package/src/zones/handlers/zones.ts +2254 -0
  514. package/src/zones/rules/geometry.ts +946 -0
  515. package/src/zones/rules/zoneDefaults.ts +34 -0
  516. package/src/zones/rules/zoneDraft.ts +54 -0
  517. package/src/zones/rules/zoneForm.ts +563 -0
  518. package/src/zones/rules/zoneMetadata.ts +29 -0
  519. package/src/zones/rules/zoneSource.ts +87 -0
  520. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  521. package/src/zones/stores/zoneEdit.ts +998 -0
@@ -0,0 +1,2091 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, {
3
+ __esModule: { value: true },
4
+ [Symbol.toStringTag]: { value: "Module" }
5
+ });
6
+ const require_rolldown_runtime = require("../chunk-Bn6ZbxkS.cjs");
7
+ const require_shareLink = require("../chunk-BeCVpkYr.cjs");
8
+ const require_listeners = require("../chunk-BIEc_SkR.cjs");
9
+ const require_segmentArming = require("../chunk-BzqPhxsz.cjs");
10
+ const require_scope = require("../chunk-C2rr9Q0V.cjs");
11
+ const require_routeHazardCopy = require("../chunk-Csr3KDpZ.cjs");
12
+ const require_errors = require("../chunk-Damps5Tk.cjs");
13
+ const require_context = require("../chunk-B5Uz3Qct.cjs");
14
+ const require_zoneSourceRefusal = require("../chunk-DjEvqvPA.cjs");
15
+ let zod = require("zod");
16
+ zod = require_rolldown_runtime.__toESM(zod);
17
+ let _mountaya_elements_geo = require("@mountaya/elements/geo");
18
+ let _mountaya_elements_data = require("@mountaya/elements/data");
19
+ let _mountaya_elements_errors = require("@mountaya/elements/errors");
20
+ let _mountaya_elements_profile = require("@mountaya/elements/profile");
21
+
22
+ let _mountaya_elements_i18n = require("@mountaya/elements/i18n");
23
+ let _mountaya_elements_collab = require("@mountaya/elements/collab");
24
+ const baseMapContent = {
25
+ collectionId: null,
26
+ itineraryId: null
27
+ };
28
+ const sameContent = (a, b) => a.collectionId === b.collectionId && a.itineraryId === b.itineraryId;
29
+ const isBaseMap = (content) => sameContent(content, baseMapContent);
30
+ const collectionOf = (config) => config.fitCollection === void 0 ? null : config.collection ?? null;
31
+ const expectsCollectionOf = (config) => config.fitCollection !== void 0 && config.expectsCollection === true;
32
+ const expectsContent = (config) => config.expectsItinerary || expectsCollectionOf(config);
33
+ const contentOf = (config) => {
34
+ if (config.itinerary !== null) return {
35
+ collectionId: null,
36
+ itineraryId: config.itinerary.id
37
+ };
38
+ const collection = collectionOf(config);
39
+ return collection === null || config.expectsItinerary ? baseMapContent : {
40
+ collectionId: collection.id,
41
+ itineraryId: null
42
+ };
43
+ };
44
+ const lockSizeOf = (config) => config.lockCanvasSize === void 0 ? config.canvasSize : config.lockCanvasSize;
45
+ const questionOf = (config, client) => ({
46
+ canvasHeight: config.canvasSize?.height ?? null,
47
+ canvasWidth: config.canvasSize?.width ?? null,
48
+ client,
49
+ collectionBounds: collectionOf(config)?.bounds ?? null,
50
+ collectionId: collectionOf(config)?.id ?? null,
51
+ expectsCollection: expectsCollectionOf(config),
52
+ expectsItinerary: config.expectsItinerary,
53
+ itinerary: config.itinerary,
54
+ lockHeight: lockSizeOf(config)?.height ?? null,
55
+ lockWidth: lockSizeOf(config)?.width ?? null,
56
+ measuredPanelHeight: config.measuredPanelHeight,
57
+ showAnalysis: config.sections.showAnalysis,
58
+ showCharacteristics: config.sections.showCharacteristics,
59
+ showElevation: config.sections.showElevation,
60
+ zoomMax: config.zoomRange.zoomMax,
61
+ zoomMin: config.zoomRange.zoomMin
62
+ });
63
+ const sameQuestion = (a, b) => a.client === b.client && a.itinerary === b.itinerary && a.expectsItinerary === b.expectsItinerary && a.collectionId === b.collectionId && sameLock(a.collectionBounds, b.collectionBounds) && a.expectsCollection === b.expectsCollection && Object.is(a.measuredPanelHeight, b.measuredPanelHeight) && Object.is(a.canvasWidth, b.canvasWidth) && Object.is(a.canvasHeight, b.canvasHeight) && Object.is(a.lockWidth, b.lockWidth) && Object.is(a.lockHeight, b.lockHeight) && a.showAnalysis === b.showAnalysis && a.showCharacteristics === b.showCharacteristics && a.showElevation === b.showElevation && Object.is(a.zoomMax, b.zoomMax) && Object.is(a.zoomMin, b.zoomMin);
64
+ const sameSize = (a, b) => a === null || b === null ? a === b : Object.is(a.width, b.width) && Object.is(a.height, b.height);
65
+ const largestOf = (a, b) => {
66
+ const first = require_segmentArming.measuredCanvas(a);
67
+ const second = require_segmentArming.measuredCanvas(b);
68
+ if (first === null || second === null) return first ?? second;
69
+ return {
70
+ height: Math.max(first.height, second.height),
71
+ width: Math.max(first.width, second.width)
72
+ };
73
+ };
74
+ const laidOutAtNoArea = (size) => size !== null && Number.isFinite(size.width) && Number.isFinite(size.height) && (size.width <= 0 || size.height <= 0);
75
+ const isEmpty = (constraints) => constraints.maxBounds === void 0 && constraints.maxZoom === void 0 && constraints.minZoom === void 0;
76
+ const sameLock = (a, b) => a === null || a === void 0 || b === null || b === void 0 ? a === b : a.every((edge, index) => Object.is(edge, b[index]));
77
+ const standsAs = (decided, applied) => (decided.maxBounds === void 0 || sameLock(decided.maxBounds, applied.maxBounds)) && (decided.maxZoom === void 0 || Object.is(decided.maxZoom, applied.maxZoom)) && (decided.minZoom === void 0 || Object.is(decided.minZoom, applied.minZoom));
78
+ const sameRange = (a, b) => Object.is(a.zoomMax, b.zoomMax) && Object.is(a.zoomMin, b.zoomMin);
79
+ var EmbedFramingEngine = class {
80
+ config;
81
+ snapshot;
82
+ listeners = /* @__PURE__ */ new Set();
83
+ framingClient = null;
84
+ asked = null;
85
+ pendingFit = null;
86
+ pendingReveal = null;
87
+ reported = false;
88
+ standing = null;
89
+ applied = {};
90
+ locked = false;
91
+ awaited;
92
+ configuredId;
93
+ parked = true;
94
+ disposed = false;
95
+ constructor(config) {
96
+ this.config = config;
97
+ const content = contentOf(config);
98
+ this.awaited = isBaseMap(content) && expectsContent(config);
99
+ this.configuredId = config.configuredItineraryId;
100
+ this.snapshot = {
101
+ bounds: null,
102
+ framed: false,
103
+ ...content
104
+ };
105
+ }
106
+ getSnapshot() {
107
+ return this.snapshot;
108
+ }
109
+ subscribe(listener) {
110
+ if (this.disposed) return () => void 0;
111
+ const subscription = () => listener();
112
+ this.listeners.add(subscription);
113
+ if (this.parked) {
114
+ this.parked = false;
115
+ this.step();
116
+ }
117
+ return () => {
118
+ if (!this.listeners.delete(subscription) || this.listeners.size > 0 || this.parked) return;
119
+ this.parked = true;
120
+ };
121
+ }
122
+ configure(config) {
123
+ if (this.disposed) return;
124
+ this.config = config;
125
+ if (config.client !== this.framingClient) this.restart(config.client);
126
+ const content = contentOf(config);
127
+ if (!sameContent(content, this.snapshot)) {
128
+ this.asked = null;
129
+ this.publish({
130
+ bounds: null,
131
+ framed: false,
132
+ ...content
133
+ });
134
+ }
135
+ const configuredId = config.configuredItineraryId;
136
+ const switched = configuredId !== void 0 && this.configuredId !== void 0 && configuredId !== this.configuredId;
137
+ this.configuredId = configuredId;
138
+ if (isBaseMap(content) && !this.awaited && (expectsContent(config) || switched)) {
139
+ this.awaited = true;
140
+ this.asked = null;
141
+ }
142
+ this.step();
143
+ }
144
+ dispose() {
145
+ if (this.disposed) return;
146
+ this.disposed = true;
147
+ this.parked = true;
148
+ this.pendingFit = null;
149
+ this.pendingReveal = null;
150
+ this.listeners.clear();
151
+ }
152
+ step() {
153
+ if (this.parked || this.disposed) return;
154
+ const { client } = this.config;
155
+ if (client !== this.framingClient) this.restart(client);
156
+ if (client === null) return;
157
+ const question = questionOf(this.config, client);
158
+ if (this.asked !== null && (sameQuestion(this.asked, question) || sameQuestion(this.asked, this.whileFitting(question)))) return;
159
+ this.asked = question;
160
+ this.frame(client, question);
161
+ }
162
+ whileFitting(question) {
163
+ const asked = this.asked;
164
+ if (asked === null || this.pendingFit === null || largestOf(this.config.canvasSize, lockSizeOf(this.config)) !== null) return question;
165
+ return {
166
+ ...question,
167
+ canvasHeight: asked.canvasHeight,
168
+ canvasWidth: asked.canvasWidth,
169
+ lockHeight: asked.lockHeight,
170
+ lockWidth: asked.lockWidth
171
+ };
172
+ }
173
+ restart(client) {
174
+ this.framingClient = client;
175
+ this.asked = null;
176
+ this.pendingFit = null;
177
+ this.pendingReveal = null;
178
+ this.reported = false;
179
+ this.standing = null;
180
+ this.locked = false;
181
+ this.applied = {};
182
+ const content = contentOf(this.config);
183
+ if (this.snapshot.framed || !sameContent(this.snapshot, content)) this.publish({
184
+ bounds: null,
185
+ framed: false,
186
+ ...content
187
+ });
188
+ }
189
+ frame(client, question) {
190
+ const { itinerary, zoomRange } = this.config;
191
+ const deferred = client.hadInitialViewHash();
192
+ const content = contentOf(this.config);
193
+ const collection = collectionOf(this.config);
194
+ if (isBaseMap(content)) {
195
+ this.pendingFit = null;
196
+ if (this.pendingReveal !== null && !isBaseMap(this.pendingReveal)) this.pendingReveal = null;
197
+ if (expectsContent(this.config)) this.awaitContent(client, deferred);
198
+ else this.showBaseMap(client);
199
+ return;
200
+ }
201
+ this.awaited = false;
202
+ if (this.pendingReveal !== null && isBaseMap(this.pendingReveal)) this.pendingReveal = null;
203
+ if (this.settledFor(content) || this.pendingReveal !== null && sameContent(this.pendingReveal, content)) {
204
+ this.rangeAgain(client, content);
205
+ this.lockAgain(client, content);
206
+ return;
207
+ }
208
+ if (!deferred && (this.unlaid() || this.resizing())) {
209
+ this.awaitResize(client);
210
+ return;
211
+ }
212
+ const bounds = itinerary === null ? collection?.bounds ?? null : (0, _mountaya_elements_geo.boundsOf)((0, _mountaya_elements_data.segmentGeometries)((0, _mountaya_elements_data.segmentsForSelection)(itinerary, null)));
213
+ const padding = (0, _mountaya_elements_profile.embedFitPadding)({
214
+ showAnalysis: question.showAnalysis,
215
+ showCharacteristics: question.showCharacteristics,
216
+ showElevation: question.showElevation
217
+ }, question.measuredPanelHeight);
218
+ const framing = !deferred && bounds !== null ? client.cameraForBounds(bounds, padding, 13) : null;
219
+ const input = {
220
+ bounds,
221
+ canvasSize: largestOf(this.config.canvasSize, lockSizeOf(this.config)),
222
+ framing,
223
+ padding,
224
+ view: deferred ? client.getViewport() : null,
225
+ zoomRange
226
+ };
227
+ this.standing = {
228
+ content,
229
+ input
230
+ };
231
+ this.constrain(client, require_segmentArming.embedConstraintsFor(input));
232
+ if (deferred) {
233
+ this.revealWithoutFit(client, bounds, content);
234
+ return;
235
+ }
236
+ const pending = {
237
+ bounds,
238
+ ...content
239
+ };
240
+ this.pendingFit = pending;
241
+ (itinerary === null && collection !== null && this.config.fitCollection !== void 0 ? this.config.fitCollection(collection.bounds, padding, 13) : this.config.fit(padding)).then(() => client.waitForRender()).then(() => {
242
+ if (this.pendingFit !== pending) return;
243
+ this.pendingFit = null;
244
+ if (this.parked || this.disposed) {
245
+ this.asked = null;
246
+ return;
247
+ }
248
+ if (this.resizing()) return;
249
+ if (this.asked !== question && this.unlaid()) {
250
+ this.asked = null;
251
+ return;
252
+ }
253
+ this.settle(pending);
254
+ }, () => {
255
+ if (this.pendingFit === pending) this.pendingFit = null;
256
+ });
257
+ }
258
+ resizing() {
259
+ const ahead = require_segmentArming.measuredCanvas(lockSizeOf(this.config));
260
+ return ahead !== null && !sameSize(ahead, require_segmentArming.measuredCanvas(this.config.canvasSize));
261
+ }
262
+ unlaid() {
263
+ const { canvasSize } = this.config;
264
+ const lockSize = lockSizeOf(this.config);
265
+ return largestOf(canvasSize, lockSize) === null && (laidOutAtNoArea(canvasSize) || laidOutAtNoArea(lockSize));
266
+ }
267
+ awaitResize(client) {
268
+ if (this.standing === null) this.constrain(client, this.zoomRangeAlone());
269
+ else {
270
+ this.rangeAgain(client, this.standing.content);
271
+ this.lockAgain(client, this.standing.content);
272
+ }
273
+ }
274
+ awaitContent(client, deferred) {
275
+ if (this.standing === null) this.constrain(client, this.zoomRangeAlone());
276
+ else {
277
+ this.rangeAgain(client, this.standing.content);
278
+ this.lockAgain(client, this.standing.content);
279
+ }
280
+ if (deferred && !this.reported) this.revealWithoutFit(client, null, baseMapContent);
281
+ }
282
+ showBaseMap(client) {
283
+ this.standing = null;
284
+ this.constrain(client, this.zoomRangeAlone());
285
+ if (this.awaited) {
286
+ this.awaited = false;
287
+ if (this.snapshot.framed) this.publish({
288
+ bounds: null,
289
+ framed: false,
290
+ ...baseMapContent
291
+ });
292
+ }
293
+ this.revealWithoutFit(client, null, baseMapContent);
294
+ }
295
+ zoomRangeAlone() {
296
+ return require_segmentArming.embedConstraintsFor({
297
+ bounds: null,
298
+ canvasSize: null,
299
+ framing: null,
300
+ padding: 0,
301
+ zoomRange: this.config.zoomRange
302
+ });
303
+ }
304
+ rangeAgain(client, content) {
305
+ const standing = this.standing;
306
+ const { zoomRange } = this.config;
307
+ if (standing === null || !sameContent(standing.content, content) || sameRange(standing.input.zoomRange, zoomRange)) return;
308
+ const input = {
309
+ ...standing.input,
310
+ zoomRange
311
+ };
312
+ this.standing = {
313
+ content,
314
+ input
315
+ };
316
+ const { maxZoom, minZoom } = require_segmentArming.embedConstraintsFor(input);
317
+ this.apply(client, maxZoom !== void 0 && minZoom !== void 0 ? {
318
+ maxZoom,
319
+ minZoom
320
+ } : this.rangeRelease());
321
+ }
322
+ rangeRelease() {
323
+ const { maxZoom, minZoom } = this.applied;
324
+ return typeof maxZoom === "number" || typeof minZoom === "number" ? {
325
+ maxZoom: null,
326
+ minZoom: null
327
+ } : {};
328
+ }
329
+ lockAgain(client, content) {
330
+ const standing = this.standing;
331
+ if (standing === null || !sameContent(standing.content, content) || standing.input.bounds === null) return;
332
+ const sizedFor = require_segmentArming.measuredCanvas(standing.input.canvasSize);
333
+ const largest = largestOf(sizedFor, largestOf(this.config.canvasSize, lockSizeOf(this.config)));
334
+ if (largest === null || sameSize(sizedFor, largest)) return;
335
+ const input = {
336
+ ...standing.input,
337
+ canvasSize: largest
338
+ };
339
+ this.standing = {
340
+ content,
341
+ input
342
+ };
343
+ const { maxBounds } = require_segmentArming.embedConstraintsFor(input);
344
+ if (maxBounds !== void 0) this.apply(client, { maxBounds });
345
+ }
346
+ constrain(client, decided) {
347
+ const ranged = decided.maxZoom === void 0 ? {
348
+ ...decided,
349
+ ...this.rangeRelease()
350
+ } : decided;
351
+ const constraints = ranged.maxBounds === void 0 && this.locked ? {
352
+ ...ranged,
353
+ maxBounds: null
354
+ } : ranged;
355
+ this.apply(client, constraints);
356
+ if (constraints.maxBounds !== void 0) this.locked = constraints.maxBounds !== null;
357
+ }
358
+ apply(client, constraints) {
359
+ if (isEmpty(constraints) || standsAs(constraints, this.applied)) return;
360
+ client.setConstraints(constraints);
361
+ this.applied = {
362
+ ...this.applied,
363
+ ...constraints
364
+ };
365
+ }
366
+ revealWithoutFit(client, bounds, content) {
367
+ if (this.settledFor(content) || this.pendingReveal !== null && sameContent(this.pendingReveal, content)) return;
368
+ const pending = {
369
+ bounds,
370
+ ...content
371
+ };
372
+ this.pendingReveal = pending;
373
+ client.waitForRender().then(() => {
374
+ if (this.pendingReveal !== pending) return;
375
+ this.pendingReveal = null;
376
+ if (this.parked || this.disposed) {
377
+ this.asked = null;
378
+ return;
379
+ }
380
+ this.settle(pending);
381
+ }, () => {
382
+ if (this.pendingReveal === pending) this.pendingReveal = null;
383
+ });
384
+ }
385
+ settledFor(content) {
386
+ return this.snapshot.framed && sameContent(this.snapshot, content);
387
+ }
388
+ settle(pending) {
389
+ this.reported = true;
390
+ if (sameContent(pending, contentOf(this.config))) this.publish({
391
+ bounds: pending.bounds,
392
+ collectionId: pending.collectionId,
393
+ framed: true,
394
+ itineraryId: pending.itineraryId
395
+ });
396
+ try {
397
+ this.config.onFramed?.(pending.bounds);
398
+ } catch (fault) {
399
+ require_listeners.surfaceFault(fault);
400
+ }
401
+ }
402
+ publish(snapshot) {
403
+ this.snapshot = snapshot;
404
+ require_listeners.notifyListeners(this.listeners);
405
+ }
406
+ };
407
+ const MAX_TIMER_MS = 2 ** 31 - 1;
408
+ const coveredSnapshot = { covered: true };
409
+ const revealedSnapshot = { covered: false };
410
+ const timeoutFrom$1 = (timeoutMs) => {
411
+ if (timeoutMs === void 0) return require_segmentArming.EMBED_COVER_MAX_MS;
412
+ if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`EmbedReadyEngine: timeoutMs is ${String(timeoutMs)}; pass a number of milliseconds from 0 to ${MAX_TIMER_MS}, or omit it for ${require_segmentArming.EMBED_COVER_MAX_MS}.`);
413
+ return timeoutMs;
414
+ };
415
+ var EmbedReadyEngine = class {
416
+ config;
417
+ clock;
418
+ timeoutMs;
419
+ snapshot = coveredSnapshot;
420
+ listeners = /* @__PURE__ */ new Set();
421
+ deadline = null;
422
+ parked = true;
423
+ disposed = false;
424
+ constructor(options) {
425
+ const { clock, timeoutMs, ...config } = options;
426
+ this.clock = clock;
427
+ this.timeoutMs = timeoutFrom$1(timeoutMs);
428
+ this.config = config;
429
+ }
430
+ getSnapshot() {
431
+ return this.snapshot;
432
+ }
433
+ subscribe(listener) {
434
+ if (this.disposed) return () => void 0;
435
+ const subscription = () => listener();
436
+ this.listeners.add(subscription);
437
+ if (this.parked) {
438
+ this.parked = false;
439
+ this.arm();
440
+ }
441
+ return () => {
442
+ if (!this.listeners.delete(subscription) || this.listeners.size > 0 || this.parked) return;
443
+ this.parked = true;
444
+ this.disarm();
445
+ };
446
+ }
447
+ configure(config) {
448
+ if (!this.disposed) this.config = config;
449
+ }
450
+ settle(bounds) {
451
+ if (this.parked || this.disposed) return;
452
+ const { configuredItineraryId, itineraryFailed } = this.config;
453
+ this.disarm();
454
+ this.reveal();
455
+ this.post(bounds, require_segmentArming.resolveFramedError(configuredItineraryId, itineraryFailed));
456
+ }
457
+ dispose() {
458
+ if (this.disposed) return;
459
+ this.disposed = true;
460
+ this.parked = true;
461
+ this.disarm();
462
+ this.listeners.clear();
463
+ }
464
+ arm() {
465
+ if (!this.snapshot.covered || this.deadline !== null) return;
466
+ const deadline = { cancel: () => void 0 };
467
+ this.deadline = deadline;
468
+ deadline.cancel = this.clock.after(this.timeoutMs, () => {
469
+ if (this.deadline !== deadline) return;
470
+ this.deadline = null;
471
+ this.expire();
472
+ });
473
+ }
474
+ disarm() {
475
+ const deadline = this.deadline;
476
+ this.deadline = null;
477
+ deadline?.cancel();
478
+ }
479
+ expire() {
480
+ this.reveal();
481
+ this.post(null, "timeout");
482
+ }
483
+ post(bounds, error) {
484
+ const { activeItineraryId, activeTerrain, configTerrain, onReady } = this.config;
485
+ const payload = require_segmentArming.buildReadyPayload({
486
+ activeItineraryId,
487
+ activeTerrain,
488
+ bounds,
489
+ configTerrain,
490
+ error
491
+ });
492
+ try {
493
+ onReady?.(payload);
494
+ } catch (fault) {
495
+ require_listeners.surfaceFault(fault);
496
+ }
497
+ }
498
+ reveal() {
499
+ if (this.snapshot === revealedSnapshot) return;
500
+ this.snapshot = revealedSnapshot;
501
+ require_listeners.notifyListeners(this.listeners);
502
+ }
503
+ };
504
+ const FRAMING_PAGE_SESSION_TIMEOUT_MS = 1e4;
505
+ const timeoutFrom = (timeoutMs) => {
506
+ if (timeoutMs === void 0) return FRAMING_PAGE_SESSION_TIMEOUT_MS;
507
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0 || timeoutMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`askFramingPageForSession: timeoutMs is ${String(timeoutMs)}; pass a number of milliseconds from 1 to ${MAX_TIMER_MS}, or omit it for ${FRAMING_PAGE_SESSION_TIMEOUT_MS}.`);
508
+ return timeoutMs;
509
+ };
510
+ const askFramingPageForSession = (options) => {
511
+ const timeoutMs = timeoutFrom(options.timeoutMs);
512
+ const { clock, embed } = options;
513
+ return new Promise((resolve, reject) => {
514
+ if (Object.is(embed.parent, embed)) {
515
+ reject(new _mountaya_elements_errors.MountayaElementsError("askFramingPageForSession: the embed is not framed, so no page can hand it a session token."));
516
+ return;
517
+ }
518
+ let cancel = () => {};
519
+ const listener = (event) => {
520
+ if (event.source !== embed.parent) return;
521
+ const parsed = require_scope.setSessionTokenMessageSchema.safeParse(event.data);
522
+ if (!parsed.success) return;
523
+ cancel();
524
+ embed.removeEventListener("message", listener);
525
+ resolve({
526
+ expires_at: new Date(parsed.data.expiresAt),
527
+ token: parsed.data.token,
528
+ user_id: null
529
+ });
530
+ };
531
+ embed.addEventListener("message", listener);
532
+ cancel = clock.after(timeoutMs, () => {
533
+ embed.removeEventListener("message", listener);
534
+ reject(new _mountaya_elements_errors.MountayaElementsError(`askFramingPageForSession: the framing page answered no session token within ${timeoutMs} ms.`));
535
+ });
536
+ embed.parent.postMessage({ type: require_scope.REQUEST_SESSION_TOKEN_MESSAGE }, "*");
537
+ });
538
+ };
539
+ const fetchItineraryPace = async (client, itineraryId, { signal, speedKmh, surface }) => {
540
+ const params = {
541
+ itinerary_id: itineraryId,
542
+ query: {
543
+ speed: speedKmh,
544
+ ...surface === void 0 ? {} : { surface }
545
+ }
546
+ };
547
+ const { data } = await (signal === void 0 ? client.studio.itineraries.getItineraryPace(params) : client.studio.itineraries.getItineraryPace(params, { signal }));
548
+ return {
549
+ bySegmentId: new Map(data.segments.map((segment) => [segment.id, segment])),
550
+ durationSeconds: data.duration
551
+ };
552
+ };
553
+ const PACE_DEBOUNCE_MS = 250;
554
+ const isRateStep = (shown, next) => shown !== null && shown.client === next.client && shown.itineraryId === next.itineraryId && shown.revision === next.revision && shown.surface === next.surface;
555
+ const revisionKey = (revision) => `${typeof revision}\0${revision ?? ""}`;
556
+ const paceKey = (itineraryId, speedKmh, surface, revision) => [
557
+ itineraryId,
558
+ speedKmh,
559
+ surface ?? "",
560
+ revision
561
+ ].join("\0");
562
+ const debounceFrom$1 = (debounceMs) => {
563
+ if (debounceMs === void 0) return PACE_DEBOUNCE_MS;
564
+ if (!Number.isFinite(debounceMs) || debounceMs < 0 || debounceMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`ItineraryPaceEngine: debounceMs is ${String(debounceMs)}; pass a number of milliseconds from 0 to ${MAX_TIMER_MS}, or omit it for ${PACE_DEBOUNCE_MS}.`);
565
+ return debounceMs;
566
+ };
567
+ var ItineraryPaceEngine = class {
568
+ config;
569
+ debounceMs;
570
+ snapshot = null;
571
+ shown = null;
572
+ listeners = /* @__PURE__ */ new Set();
573
+ answers = /* @__PURE__ */ new Map();
574
+ inFlight = null;
575
+ timer = null;
576
+ parked = true;
577
+ disposed = false;
578
+ constructor(options) {
579
+ const { debounceMs, ...config } = options;
580
+ this.debounceMs = debounceFrom$1(debounceMs);
581
+ this.config = config;
582
+ }
583
+ getSnapshot() {
584
+ return this.snapshot;
585
+ }
586
+ subscribe(listener) {
587
+ if (this.disposed) return () => void 0;
588
+ this.listeners.add(listener);
589
+ if (this.parked) {
590
+ this.parked = false;
591
+ this.schedule();
592
+ }
593
+ return () => {
594
+ this.listeners.delete(listener);
595
+ if (this.listeners.size > 0 || this.parked) return;
596
+ this.parked = true;
597
+ this.cancelPending();
598
+ this.abandon(null);
599
+ };
600
+ }
601
+ configure(config) {
602
+ if (this.disposed) return;
603
+ const before = this.request()?.key ?? null;
604
+ const replacesClient = config.client !== this.config.client;
605
+ this.config = config;
606
+ if (replacesClient) {
607
+ this.answers.clear();
608
+ this.abandon(null);
609
+ }
610
+ const request = this.request();
611
+ if (request !== null) this.forgetOtherRevisions(request);
612
+ if (replacesClient || (request?.key ?? null) !== before) this.schedule();
613
+ }
614
+ dispose() {
615
+ if (this.disposed) return;
616
+ this.disposed = true;
617
+ this.parked = true;
618
+ this.cancelPending();
619
+ this.abandon(null);
620
+ this.listeners.clear();
621
+ }
622
+ request() {
623
+ const { client, itineraryId, speedKmh, surface } = this.config;
624
+ if (client === void 0 || !itineraryId || speedKmh === null) return null;
625
+ const revision = revisionKey(this.config.revision);
626
+ return {
627
+ client,
628
+ itineraryId,
629
+ key: paceKey(itineraryId, speedKmh, surface, revision),
630
+ revision,
631
+ speedKmh,
632
+ surface
633
+ };
634
+ }
635
+ readKept(key) {
636
+ const kept = this.answers.get(key);
637
+ if (kept !== void 0) {
638
+ this.answers.delete(key);
639
+ this.answers.set(key, kept);
640
+ }
641
+ return kept;
642
+ }
643
+ keep(key, kept) {
644
+ this.answers.delete(key);
645
+ this.answers.set(key, kept);
646
+ for (const oldest of this.answers.keys()) {
647
+ if (this.answers.size <= 32) break;
648
+ this.answers.delete(oldest);
649
+ }
650
+ }
651
+ forgetOtherRevisions(request) {
652
+ for (const [key, kept] of this.answers) if (kept.itineraryId === request.itineraryId && kept.revision !== request.revision) this.answers.delete(key);
653
+ }
654
+ schedule() {
655
+ this.cancelPending();
656
+ if (this.disposed) return;
657
+ const request = this.request();
658
+ this.abandon(request?.key ?? null);
659
+ if (request === null) {
660
+ this.commit(null, null);
661
+ return;
662
+ }
663
+ const kept = this.readKept(request.key);
664
+ if (kept !== void 0) {
665
+ this.commit(kept.answer, request);
666
+ return;
667
+ }
668
+ if (!isRateStep(this.shown, request)) this.commit(null, null);
669
+ if (this.parked) return;
670
+ if (this.debounceMs === 0) {
671
+ this.ask(request);
672
+ return;
673
+ }
674
+ this.timer = setTimeout(() => {
675
+ this.timer = null;
676
+ const current = this.request();
677
+ if (current !== null) this.ask(current);
678
+ }, this.debounceMs);
679
+ }
680
+ ask(request) {
681
+ const kept = this.readKept(request.key);
682
+ if (kept !== void 0) {
683
+ this.commit(kept.answer, request);
684
+ return;
685
+ }
686
+ if (this.inFlight?.key === request.key) return;
687
+ const inFlight = {
688
+ controller: new AbortController(),
689
+ key: request.key
690
+ };
691
+ this.inFlight = inFlight;
692
+ fetchItineraryPace(request.client, request.itineraryId, {
693
+ signal: inFlight.controller.signal,
694
+ speedKmh: request.speedKmh,
695
+ surface: request.surface
696
+ }).then((answer) => {
697
+ if (!this.settle(inFlight)) return;
698
+ this.keep(request.key, {
699
+ answer,
700
+ itineraryId: request.itineraryId,
701
+ revision: request.revision
702
+ });
703
+ if (this.isLive(request.key)) this.commit(answer, request);
704
+ }, () => {
705
+ if (this.settle(inFlight) && this.isLive(request.key)) this.commit(null, null);
706
+ });
707
+ }
708
+ settle(inFlight) {
709
+ if (this.inFlight === inFlight) this.inFlight = null;
710
+ return !inFlight.controller.signal.aborted;
711
+ }
712
+ abandon(keep) {
713
+ if (this.inFlight === null || this.inFlight.key === keep) return;
714
+ this.inFlight.controller.abort();
715
+ this.inFlight = null;
716
+ }
717
+ isLive(key) {
718
+ return !this.parked && !this.disposed && this.request()?.key === key;
719
+ }
720
+ cancelPending() {
721
+ if (this.timer !== null) {
722
+ clearTimeout(this.timer);
723
+ this.timer = null;
724
+ }
725
+ }
726
+ commit(snapshot, answers) {
727
+ if (this.disposed) return;
728
+ this.shown = snapshot === null ? null : answers;
729
+ if (snapshot === this.snapshot) return;
730
+ this.snapshot = snapshot;
731
+ require_listeners.notifyListeners(this.listeners);
732
+ }
733
+ };
734
+ const throttleFrom$1 = (throttleMs) => {
735
+ if (throttleMs === void 0) return 60;
736
+ if (!Number.isFinite(throttleMs) || throttleMs < 0 || throttleMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`ProfileMarkerEngine: throttleMs is ${String(throttleMs)}; pass a number of milliseconds from 0 to ${MAX_TIMER_MS}, or omit it for 60.`);
737
+ return throttleMs;
738
+ };
739
+ var ProfileMarkerEngine = class {
740
+ throttleMs;
741
+ listeners = /* @__PURE__ */ new Set();
742
+ resting = null;
743
+ held = null;
744
+ timer = null;
745
+ disposed = false;
746
+ constructor(options = {}) {
747
+ this.throttleMs = throttleFrom$1(options.throttleMs);
748
+ }
749
+ getSnapshot = () => this.resting;
750
+ subscribe = (listener) => {
751
+ if (this.disposed) return () => {};
752
+ this.listeners.add(listener);
753
+ return () => {
754
+ this.listeners.delete(listener);
755
+ if (this.listeners.size === 0) this.endWindow();
756
+ };
757
+ };
758
+ hover(point) {
759
+ if (this.disposed) return;
760
+ if (point === null) {
761
+ this.endWindow();
762
+ this.rest(null);
763
+ return;
764
+ }
765
+ if (this.timer !== null) {
766
+ this.held = point;
767
+ return;
768
+ }
769
+ this.rest(point);
770
+ if (this.resting === point) this.openWindow();
771
+ }
772
+ dispose() {
773
+ if (this.disposed) return;
774
+ this.disposed = true;
775
+ this.endWindow();
776
+ this.listeners.clear();
777
+ }
778
+ rest(point) {
779
+ if (this.resting === point) return;
780
+ this.resting = point;
781
+ require_listeners.notifyListeners(this.listeners);
782
+ }
783
+ openWindow() {
784
+ if (this.timer !== null || this.throttleMs === 0 || this.listeners.size === 0) return;
785
+ this.timer = setTimeout(() => {
786
+ this.timer = null;
787
+ const held = this.held;
788
+ if (held === null) return;
789
+ this.held = null;
790
+ this.rest(held);
791
+ if (this.resting === held) this.openWindow();
792
+ }, this.throttleMs);
793
+ }
794
+ endWindow() {
795
+ if (this.timer !== null) clearTimeout(this.timer);
796
+ this.timer = null;
797
+ this.held = null;
798
+ }
799
+ };
800
+ const promptKey = (hazards) => [...hazards].sort().join("|");
801
+ const createHazardPromptGate = (ask) => {
802
+ const pending = /* @__PURE__ */ new Map();
803
+ return (hazards) => {
804
+ const key = promptKey(hazards);
805
+ const asking = pending.get(key);
806
+ if (asking) return asking;
807
+ const answer = ask(hazards).finally(() => {
808
+ pending.delete(key);
809
+ });
810
+ pending.set(key, answer);
811
+ return answer;
812
+ };
813
+ };
814
+ const buildLiveSegmentForDraft = (base, segmentId, itineraryId, mode, route, draftName, draftColor) => require_scope.buildLiveSegment(base ?? require_scope.synthesizeDraftSegment({
815
+ draftColor,
816
+ draftName,
817
+ itineraryId,
818
+ mode,
819
+ segmentId
820
+ }), route);
821
+ const idleSnapshot = {
822
+ armed: false,
823
+ mode: null,
824
+ segmentId: null,
825
+ viaCount: 0
826
+ };
827
+ const sameArming = (a, b) => a.client === b.client && a.context === b.context && a.segmentId === b.segmentId && a.mode === b.mode && a.activitySlug === b.activitySlug && a.draftColor === b.draftColor && a.pinnedEnd === b.pinnedEnd && a.pinnedStart === b.pinnedStart && a.seedVias === b.seedVias;
828
+ const sameListenKey = (a, b) => a.client === b.client && a.context === b.context && a.itineraryId === b.itineraryId && a.mode === b.mode && a.segmentId === b.segmentId;
829
+ const throttleFrom = (throttleMs) => {
830
+ if (throttleMs === void 0) return _mountaya_elements_collab.LIVE_SEGMENT_THROTTLE_MS;
831
+ if (!Number.isFinite(throttleMs) || throttleMs < 0 || throttleMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`SegmentDraftEngine: throttleMs is ${String(throttleMs)}; pass a number of milliseconds from 0 to ${MAX_TIMER_MS}, or omit it for ${_mountaya_elements_collab.LIVE_SEGMENT_THROTTLE_MS}.`);
832
+ return throttleMs;
833
+ };
834
+ var SegmentDraftEngine = class {
835
+ config;
836
+ throttleMs;
837
+ snapshot = idleSnapshot;
838
+ subscriptions = /* @__PURE__ */ new Set();
839
+ watching = null;
840
+ arming = null;
841
+ refused = null;
842
+ listening = null;
843
+ viaCount = 0;
844
+ reconciling = false;
845
+ stale = false;
846
+ parked = true;
847
+ disposed = false;
848
+ hazardGate = createHazardPromptGate((hazards) => this.askAboutHazards(hazards));
849
+ hazardMemo = {
850
+ accept: (keys) => {
851
+ this.config.context.ui.getState().acknowledgeRouteHazards(keys);
852
+ },
853
+ accepted: () => this.config.context.ui.getState().segmentEditSession?.acknowledgedRouteHazards ?? []
854
+ };
855
+ constructor(options) {
856
+ const { throttleMs, ...config } = options;
857
+ this.throttleMs = throttleFrom(throttleMs);
858
+ this.config = config;
859
+ }
860
+ getSnapshot() {
861
+ return this.snapshot;
862
+ }
863
+ subscribe(listener) {
864
+ if (this.disposed) return () => {};
865
+ const subscription = { listener };
866
+ this.subscriptions.add(subscription);
867
+ if (this.parked) {
868
+ this.parked = false;
869
+ this.reconcile();
870
+ }
871
+ return () => {
872
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) return;
873
+ if (!this.parked) this.park();
874
+ };
875
+ }
876
+ configure(config) {
877
+ if (this.disposed) return;
878
+ this.config = config;
879
+ if (!this.parked) this.reconcile();
880
+ }
881
+ dispose() {
882
+ if (this.disposed) return;
883
+ this.disposed = true;
884
+ if (!this.parked) this.park();
885
+ this.subscriptions.clear();
886
+ }
887
+ reconcile() {
888
+ if (this.parked) return;
889
+ if (this.reconciling) {
890
+ this.stale = true;
891
+ return;
892
+ }
893
+ this.reconciling = true;
894
+ try {
895
+ do {
896
+ this.stale = false;
897
+ this.step();
898
+ } while (this.stale && !this.parked);
899
+ } finally {
900
+ this.reconciling = false;
901
+ }
902
+ this.publish();
903
+ }
904
+ step() {
905
+ const { client, context } = this.config;
906
+ this.watch(context.ui);
907
+ const state = context.ui.getState();
908
+ const session = state.segmentEditSession;
909
+ if (client === null || session === null || session.segmentId === "") {
910
+ this.unlisten();
911
+ this.arming = null;
912
+ this.refused = null;
913
+ return;
914
+ }
915
+ const key = {
916
+ client,
917
+ context,
918
+ itineraryId: state.activeItinerary?.id ?? null,
919
+ mode: session.mode,
920
+ segmentId: session.segmentId
921
+ };
922
+ if (this.listening !== null && !sameListenKey(this.listening, key)) this.unlisten();
923
+ const arming = {
924
+ activitySlug: session.activitySlug,
925
+ client,
926
+ context,
927
+ draftColor: session.draftColor,
928
+ mode: session.mode,
929
+ pinnedEnd: session.pinnedEnd,
930
+ pinnedStart: session.pinnedStart,
931
+ seedVias: session.seedVias,
932
+ segmentId: session.segmentId
933
+ };
934
+ if (this.refused !== null && sameArming(this.refused, arming)) return;
935
+ if (this.arming === null || !sameArming(this.arming, arming)) {
936
+ try {
937
+ client.beginSegmentEdit(require_segmentArming.buildSegmentEditOptions(session, {
938
+ client: context.api?.client,
939
+ confirmHazards: this.hazardGate,
940
+ hazardMemo: this.hazardMemo,
941
+ onViaCapRefused: () => this.refuseViaCap()
942
+ }));
943
+ } catch (refusal) {
944
+ this.unlisten();
945
+ this.arming = null;
946
+ this.refused = arming;
947
+ this.endRefused(context, require_scope.segmentEditSessionMark(session), refusal);
948
+ return;
949
+ }
950
+ this.arming = arming;
951
+ this.refused = null;
952
+ }
953
+ if (this.listening === null) this.listen(key);
954
+ }
955
+ endRefused(context, mark, refusal) {
956
+ require_listeners.surfaceFault(refusal);
957
+ const close = () => {
958
+ if (this.disposed) return;
959
+ const state = context.ui.getState();
960
+ const open = state.segmentEditSession;
961
+ if (open !== null && require_scope.segmentEditSessionMark(open) === mark) state.cancelSegmentEdit();
962
+ };
963
+ Promise.resolve(this.config.bus.dispatch(context, "studio.itinerary.segment.editCancel", {})).then((result) => {
964
+ if (result?.ok !== true) close();
965
+ }, close);
966
+ this.raiseAlert(context, {
967
+ level: "error",
968
+ message: this.config.strings.editing.segmentEditBeginFailed
969
+ });
970
+ }
971
+ raiseAlert(context, alert) {
972
+ Promise.resolve(this.config.bus.dispatch(context, "studio.alert.show", alert)).then(void 0, () => {});
973
+ }
974
+ watch(ui) {
975
+ if (this.watching?.ui === ui) return;
976
+ this.unwatch();
977
+ this.watching = {
978
+ release: ui.subscribe(() => this.reconcile()),
979
+ ui
980
+ };
981
+ }
982
+ unwatch() {
983
+ this.watching?.release();
984
+ this.watching = null;
985
+ }
986
+ listen(key) {
987
+ const listening = {
988
+ ...key,
989
+ projected: null,
990
+ release: () => {},
991
+ throttle: this.throttleMs === 0 ? null : new _mountaya_elements_collab.TrailingThrottle(this.throttleMs, (routed) => this.project(listening, routed), { leading: true })
992
+ };
993
+ this.listening = listening;
994
+ listening.release = key.client.onSegmentDraftChange((draft) => this.receive(listening, draft));
995
+ }
996
+ unlisten() {
997
+ const listening = this.listening;
998
+ if (listening === null) return;
999
+ this.listening = null;
1000
+ this.viaCount = 0;
1001
+ listening.release();
1002
+ listening.throttle?.cancel();
1003
+ listening.context.ui.getState().setSegmentEditLiveSegment(null);
1004
+ }
1005
+ receive(listening, draft) {
1006
+ if (this.listening !== listening) return;
1007
+ if (draft.vias.length !== this.viaCount) {
1008
+ this.viaCount = draft.vias.length;
1009
+ this.publish();
1010
+ if (this.listening !== listening) return;
1011
+ }
1012
+ const ui = listening.context.ui;
1013
+ const disposition = require_segmentArming.draftChangeDisposition({
1014
+ agentDriving: ui.getState().agentDriving,
1015
+ programmatic: draft.programmatic
1016
+ });
1017
+ if (disposition === "drop") return;
1018
+ if (disposition === "record") {
1019
+ const geometry = (0, _mountaya_elements_geo.buildSegmentGeometry)(listening.mode, draft.vias);
1020
+ if (draft.phase === "live") ui.getState().setSegmentEditLiveDraft(geometry);
1021
+ else ui.getState().pushSegmentDraft(geometry);
1022
+ if (this.listening !== listening) return;
1023
+ }
1024
+ if (draft.route) {
1025
+ const projected = listening.projected;
1026
+ if (projected?.route === draft.route && ui.getState().segmentEditSession?.liveSegment === projected.liveSegment) return;
1027
+ const routed = {
1028
+ route: draft.route,
1029
+ routedFor: draft.programmatic ? draft.vias : void 0
1030
+ };
1031
+ if (listening.throttle === null) this.project(listening, routed);
1032
+ else listening.throttle.push(routed);
1033
+ return;
1034
+ }
1035
+ if (draft.phase === "live") return;
1036
+ listening.throttle?.cancel();
1037
+ if (disposition === "record") this.fallBack(listening);
1038
+ }
1039
+ project(listening, { route, routedFor }) {
1040
+ if (this.listening !== listening) return;
1041
+ const state = listening.context.ui.getState();
1042
+ const itinerary = state.activeItinerary;
1043
+ const session = state.segmentEditSession;
1044
+ const liveSegment = buildLiveSegmentForDraft(itinerary?.segments.find((segment) => segment.id === listening.segmentId), listening.segmentId, itinerary?.id ?? "", session?.mode ?? "directions", route, session?.draftName ?? null, session?.draftColor ?? null);
1045
+ listening.projected = {
1046
+ liveSegment,
1047
+ route
1048
+ };
1049
+ state.setSegmentEditLiveSegment(liveSegment, routedFor);
1050
+ this.config.collab?.sendDraft({
1051
+ id: listening.segmentId,
1052
+ kind: "segment"
1053
+ }, liveSegment);
1054
+ }
1055
+ fallBack(listening) {
1056
+ const state = listening.context.ui.getState();
1057
+ const session = state.segmentEditSession;
1058
+ if (!state.activeItinerary?.segments?.find((segment) => segment.id === listening.segmentId) && session) {
1059
+ state.setSegmentEditLiveSegment(require_scope.synthesizeDraftSegment({
1060
+ draftColor: session.draftColor,
1061
+ draftName: session.draftName,
1062
+ itineraryId: state.activeItinerary?.id ?? "",
1063
+ mode: session.mode,
1064
+ segmentId: session.segmentId
1065
+ }));
1066
+ return;
1067
+ }
1068
+ state.setSegmentEditLiveSegment(null);
1069
+ }
1070
+ refuseViaCap() {
1071
+ const { context, strings } = this.config;
1072
+ this.raiseAlert(context, {
1073
+ level: "warning",
1074
+ message: strings.editing.segmentViaCapRefused(_mountaya_elements_geo.DIRECTIONS_VIA_MAX)
1075
+ });
1076
+ }
1077
+ askAboutHazards(hazards) {
1078
+ const { context, strings } = this.config;
1079
+ if (!context.confirm) return Promise.resolve(true);
1080
+ return context.confirm(require_segmentArming.routeHazardConfirmation(hazards, {
1081
+ closing: strings.editing.routeHazardClosing,
1082
+ hazards: strings.editing.routeHazards,
1083
+ severalTitle: strings.editing.routeHazardsTitle
1084
+ }));
1085
+ }
1086
+ park() {
1087
+ this.parked = true;
1088
+ this.unwatch();
1089
+ this.unlisten();
1090
+ this.arming = null;
1091
+ this.publish();
1092
+ }
1093
+ publish() {
1094
+ const listening = this.listening;
1095
+ const next = listening === null ? idleSnapshot : {
1096
+ armed: true,
1097
+ mode: listening.mode,
1098
+ segmentId: listening.segmentId,
1099
+ viaCount: this.viaCount
1100
+ };
1101
+ const current = this.snapshot;
1102
+ if (current.armed === next.armed && current.mode === next.mode && current.segmentId === next.segmentId && current.viaCount === next.viaCount) return;
1103
+ this.snapshot = next;
1104
+ if (this.disposed) return;
1105
+ require_listeners.notifyListeners(Array.from(this.subscriptions, ({ listener }) => listener));
1106
+ }
1107
+ };
1108
+ zod.object({ failedCollectionIds: zod.array(zod.string()).optional() });
1109
+ const mintedShareTokenSchema = zod.object({ shareToken: require_scope.issuedShareTokenSchema.shape.shareToken });
1110
+ const mintedShareToken = (result) => {
1111
+ if (!result.ok) return null;
1112
+ const parsed = mintedShareTokenSchema.safeParse(result.data);
1113
+ return parsed.success ? parsed.data.shareToken : null;
1114
+ };
1115
+ const skipped = { status: "skipped" };
1116
+ const withheld = { status: "withheld" };
1117
+ const unworded = {
1118
+ failure: null,
1119
+ retryable: true
1120
+ };
1121
+ const sameTarget = (a, b) => a.kind === b.kind && a.id === b.id;
1122
+ const sameActions = (a, b) => a.disable === b.disable && a.rotate === b.rotate;
1123
+ const heldBack = (actions) => ({
1124
+ disable: actions.disable === "ready" ? "waiting" : actions.disable,
1125
+ rotate: actions.rotate === "ready" ? "waiting" : actions.rotate
1126
+ });
1127
+ const answered = async (run, settle) => {
1128
+ let result;
1129
+ try {
1130
+ result = await run();
1131
+ } catch (error) {
1132
+ result = require_errors.failureFromThrown(error);
1133
+ }
1134
+ return settle(result);
1135
+ };
1136
+ const readToken = (result) => {
1137
+ if (!result.ok) return {
1138
+ failure: result,
1139
+ retryable: require_shareLink.isRetryableShareLinkFailure(result)
1140
+ };
1141
+ if (result.token === null) return { token: null };
1142
+ const issued = require_scope.issuedShareTokenSchema.safeParse({ shareToken: result.token });
1143
+ return issued.success ? { token: issued.data.shareToken } : unworded;
1144
+ };
1145
+ var ShareLinkEngine = class {
1146
+ config;
1147
+ target;
1148
+ token;
1149
+ known;
1150
+ readFailure = null;
1151
+ mintFailure = null;
1152
+ change = null;
1153
+ reading = false;
1154
+ minting = false;
1155
+ asked = false;
1156
+ acting = null;
1157
+ running = false;
1158
+ epoch = 0;
1159
+ sent = 0;
1160
+ outranked = 0;
1161
+ answeredAt = 0;
1162
+ unheard = 0;
1163
+ readFailedAt = 0;
1164
+ mintFailedAt = 0;
1165
+ latestRead = 0;
1166
+ latestMint = 0;
1167
+ snapshot;
1168
+ subscriptions = /* @__PURE__ */ new Set();
1169
+ parked = true;
1170
+ disposed = false;
1171
+ constructor(options) {
1172
+ const { token, ...config } = options;
1173
+ this.config = config;
1174
+ this.target = config.target;
1175
+ this.token = token ?? null;
1176
+ this.known = this.token !== null;
1177
+ this.snapshot = this.compose();
1178
+ }
1179
+ getSnapshot() {
1180
+ return this.snapshot;
1181
+ }
1182
+ subscribe(listener) {
1183
+ if (this.disposed) return () => void 0;
1184
+ const subscription = { listener };
1185
+ this.subscriptions.add(subscription);
1186
+ if (this.parked) {
1187
+ this.parked = false;
1188
+ this.ask();
1189
+ }
1190
+ return () => {
1191
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) return;
1192
+ this.parked = true;
1193
+ };
1194
+ }
1195
+ configure(config) {
1196
+ if (this.disposed) return;
1197
+ this.config = config;
1198
+ if (!sameTarget(this.target, config.target)) {
1199
+ this.target = config.target;
1200
+ this.epoch += 1;
1201
+ this.token = null;
1202
+ this.known = false;
1203
+ this.readFailure = null;
1204
+ this.readFailedAt = 0;
1205
+ this.mintFailure = null;
1206
+ this.mintFailedAt = 0;
1207
+ this.change = null;
1208
+ this.acting = null;
1209
+ this.running = false;
1210
+ this.reading = false;
1211
+ this.minting = false;
1212
+ this.asked = false;
1213
+ }
1214
+ this.publish();
1215
+ if (!this.parked) this.ask();
1216
+ }
1217
+ dispose() {
1218
+ if (this.disposed) return;
1219
+ this.disposed = true;
1220
+ this.parked = true;
1221
+ this.subscriptions.clear();
1222
+ }
1223
+ async read() {
1224
+ if (this.parked || this.disposed || this.reading || !this.mayAsk()) return;
1225
+ await this.runAsk("read");
1226
+ }
1227
+ async mint() {
1228
+ if (this.parked || this.disposed || this.minting || this.token !== null || this.acting !== null || !this.mayAsk()) return;
1229
+ await this.runAsk("mint");
1230
+ }
1231
+ rotate() {
1232
+ return this.act("rotate");
1233
+ }
1234
+ disable() {
1235
+ return this.act("disable");
1236
+ }
1237
+ ask() {
1238
+ if (this.asked || !this.mayAsk()) return;
1239
+ this.runAsk("read");
1240
+ }
1241
+ mayAsk() {
1242
+ return this.config.scope === "organization" && this.config.canManage;
1243
+ }
1244
+ async runAsk(kind) {
1245
+ const epoch = this.epoch;
1246
+ this.sent += 1;
1247
+ const place = this.sent;
1248
+ if (kind === "read") {
1249
+ this.latestRead = place;
1250
+ this.asked = true;
1251
+ this.reading = true;
1252
+ this.readFailure = null;
1253
+ this.readFailedAt = 0;
1254
+ } else {
1255
+ this.latestMint = place;
1256
+ this.minting = true;
1257
+ this.mintFailure = null;
1258
+ this.mintFailedAt = 0;
1259
+ }
1260
+ this.publish();
1261
+ const answer = kind === "read" ? await this.sendRead() : await this.sendMint();
1262
+ if (this.disposed || epoch !== this.epoch) return;
1263
+ if (kind === "read" && place === this.latestRead) this.reading = false;
1264
+ if (kind === "mint" && place === this.latestMint) this.minting = false;
1265
+ if (place <= this.outranked || place < this.answeredAt) {
1266
+ this.publish();
1267
+ return;
1268
+ }
1269
+ if (kind === "read" && this.parked) {
1270
+ this.asked = false;
1271
+ this.unheard = place;
1272
+ this.publish();
1273
+ return;
1274
+ }
1275
+ if ("failure" in answer) {
1276
+ if (kind === "read") {
1277
+ this.readFailure = answer;
1278
+ this.readFailedAt = place;
1279
+ } else {
1280
+ this.mintFailure = answer;
1281
+ this.mintFailedAt = place;
1282
+ }
1283
+ this.publish();
1284
+ return;
1285
+ }
1286
+ this.token = answer.token;
1287
+ this.known = true;
1288
+ this.change = kind === "read" ? "read" : "minted";
1289
+ this.answeredAt = place;
1290
+ if (this.readFailedAt < place) {
1291
+ this.readFailure = null;
1292
+ this.readFailedAt = 0;
1293
+ }
1294
+ if (this.mintFailedAt < place) {
1295
+ this.mintFailure = null;
1296
+ this.mintFailedAt = 0;
1297
+ }
1298
+ this.publish();
1299
+ }
1300
+ async sendRead() {
1301
+ try {
1302
+ return readToken(await this.config.read(this.config.context, this.target));
1303
+ } catch {
1304
+ return unworded;
1305
+ }
1306
+ }
1307
+ async sendMint() {
1308
+ try {
1309
+ const result = await this.config.dispatch(this.config.context, "studio.shareLink.mint", this.target);
1310
+ if (!result.ok) return {
1311
+ failure: result,
1312
+ retryable: require_shareLink.isRetryableShareLinkFailure(result)
1313
+ };
1314
+ const token = mintedShareToken(result);
1315
+ return token === null ? unworded : { token };
1316
+ } catch {
1317
+ return unworded;
1318
+ }
1319
+ }
1320
+ act(action) {
1321
+ if (this.parked || this.disposed || this.acting !== null || this.snapshot.actions[action] !== "ready") return Promise.resolve(skipped);
1322
+ const epoch = this.epoch;
1323
+ const { context, dispatch, scope } = this.config;
1324
+ this.sent += 1;
1325
+ let place = this.sent;
1326
+ const confirming = require_context.layerToolContext(context, { confirm: async (request) => {
1327
+ const approved = await context.confirm?.(request) ?? false;
1328
+ if (approved && !this.disposed && epoch === this.epoch) {
1329
+ this.sent += 1;
1330
+ place = this.sent;
1331
+ this.running = true;
1332
+ this.publish();
1333
+ }
1334
+ return approved;
1335
+ } });
1336
+ const target = this.target;
1337
+ this.acting = action;
1338
+ this.publish();
1339
+ if (action === "rotate") return answered(() => dispatch(confirming, "studio.shareLink.rotate", target), (result) => this.settleRotate(epoch, result));
1340
+ return answered(() => dispatch(confirming, "studio.shareLink.disable", target), (result) => this.settleDisable(epoch, scope, place, result));
1341
+ }
1342
+ settleRotate(epoch, result) {
1343
+ if (!result.ok) return this.refuse(epoch, result);
1344
+ const shareToken = mintedShareToken(result);
1345
+ if (shareToken === null) {
1346
+ this.finish(epoch, () => {
1347
+ this.outranked = this.sent;
1348
+ });
1349
+ this.readStandingLink(epoch);
1350
+ return {
1351
+ failure: require_shareLink.tokenlessAnswerRefusal("rotate"),
1352
+ status: "refused"
1353
+ };
1354
+ }
1355
+ this.finish(epoch, () => {
1356
+ this.outranked = this.sent;
1357
+ this.token = shareToken;
1358
+ this.known = true;
1359
+ this.change = "rotated";
1360
+ this.readFailure = null;
1361
+ this.readFailedAt = 0;
1362
+ this.mintFailure = null;
1363
+ this.mintFailedAt = 0;
1364
+ });
1365
+ return {
1366
+ linkWasActive: true,
1367
+ status: "settled"
1368
+ };
1369
+ }
1370
+ readStandingLink(epoch) {
1371
+ if (this.disposed || epoch !== this.epoch) return;
1372
+ if (this.parked || !this.mayAsk()) {
1373
+ this.asked = false;
1374
+ return;
1375
+ }
1376
+ this.runAsk("read");
1377
+ }
1378
+ settleDisable(epoch, scope, place, result) {
1379
+ if (!result.ok && !require_shareLink.isShareLinkDisableSettled(result, scope)) return this.refuse(epoch, result);
1380
+ this.finish(epoch, () => {
1381
+ if (place < this.answeredAt) return;
1382
+ this.outranked = place;
1383
+ this.token = null;
1384
+ this.known = true;
1385
+ this.change = "disabled";
1386
+ if (this.readFailedAt < place) {
1387
+ this.readFailure = null;
1388
+ this.readFailedAt = 0;
1389
+ }
1390
+ if (this.mintFailedAt < place) {
1391
+ this.mintFailure = null;
1392
+ this.mintFailedAt = 0;
1393
+ }
1394
+ if (place > this.unheard) this.asked = true;
1395
+ });
1396
+ return {
1397
+ linkWasActive: result.ok,
1398
+ status: "settled"
1399
+ };
1400
+ }
1401
+ refuse(epoch, failure) {
1402
+ this.finish(epoch);
1403
+ return require_routeHazardCopy.isConfirmationWithheld(failure) ? withheld : {
1404
+ failure,
1405
+ status: "refused"
1406
+ };
1407
+ }
1408
+ finish(epoch, apply) {
1409
+ if (this.disposed || epoch !== this.epoch) return;
1410
+ this.acting = null;
1411
+ this.running = false;
1412
+ apply?.();
1413
+ this.publish();
1414
+ }
1415
+ compose() {
1416
+ const { canManage, scope } = this.config;
1417
+ const offered = require_shareLink.shareLinkActions({
1418
+ canManage,
1419
+ scope,
1420
+ token: this.token
1421
+ });
1422
+ return {
1423
+ actions: this.acting === null ? offered : heldBack(offered),
1424
+ busy: this.running ? this.acting : null,
1425
+ change: this.change,
1426
+ known: this.known,
1427
+ mintFailure: this.mintFailure,
1428
+ minting: this.minting,
1429
+ readFailure: this.readFailure,
1430
+ reading: this.reading,
1431
+ target: this.target,
1432
+ token: this.token
1433
+ };
1434
+ }
1435
+ publish() {
1436
+ const current = this.snapshot;
1437
+ const next = this.compose();
1438
+ const actions = sameActions(current.actions, next.actions) ? current.actions : next.actions;
1439
+ if (actions === current.actions && next.busy === current.busy && next.change === current.change && next.known === current.known && next.mintFailure === current.mintFailure && next.minting === current.minting && next.readFailure === current.readFailure && next.reading === current.reading && next.target === current.target && next.token === current.token) return;
1440
+ this.snapshot = {
1441
+ ...next,
1442
+ actions
1443
+ };
1444
+ require_listeners.notifyListeners([...this.subscriptions].map((subscription) => subscription.listener));
1445
+ }
1446
+ };
1447
+ const queryKeyOf = (source) => source === null ? null : JSON.stringify(source);
1448
+ const noFacts = {
1449
+ createMethod: null,
1450
+ createSerial: 0,
1451
+ inherited: null,
1452
+ origin: null,
1453
+ session: null,
1454
+ zone: null
1455
+ };
1456
+ const factsOf = (state) => {
1457
+ const zone = state.activeZone;
1458
+ const itinerary = state.activeItinerary;
1459
+ return {
1460
+ createMethod: state.zoneCreateMethod,
1461
+ createSerial: state.zoneCreateSerial,
1462
+ inherited: zone === null && state.zoneCreateInheritsItinerary && itinerary !== null ? {
1463
+ activityId: itinerary.activity_id,
1464
+ itineraryId: itinerary.id,
1465
+ organizationId: itinerary.organization_id ?? null
1466
+ } : null,
1467
+ origin: state.zoneCreateOrigin,
1468
+ session: state.zoneEditSession,
1469
+ zone
1470
+ };
1471
+ };
1472
+ const sameIds = (a, b) => a.length === b.length && a.every((id, index) => id === b[index]);
1473
+ const sameMembers = (a, b) => {
1474
+ const keys = Object.keys(a);
1475
+ return keys.length === Object.keys(b).length && keys.every((key) => Object.is(a[key], b[key]));
1476
+ };
1477
+ const readsSame = (a, b) => a.activeZone === b.activeZone && a.activeItinerary === b.activeItinerary && a.zoneCreateInheritsItinerary === b.zoneCreateInheritsItinerary && a.zoneCreateMethod === b.zoneCreateMethod && a.zoneCreateOrigin === b.zoneCreateOrigin && a.zoneCreateSerial === b.zoneCreateSerial && a.zoneEditSession === b.zoneEditSession;
1478
+ const debounceFrom = (debounceMs) => {
1479
+ if (debounceMs === void 0) return 600;
1480
+ if (!Number.isFinite(debounceMs) || debounceMs < 0 || debounceMs > MAX_TIMER_MS) throw new _mountaya_elements_errors.MountayaElementsError(`ZoneFormEngine: debounceMs is ${String(debounceMs)}; pass a number of milliseconds from 0 to ${MAX_TIMER_MS}, or omit it for 600.`);
1481
+ return debounceMs;
1482
+ };
1483
+ var ZoneFormEngine = class {
1484
+ config;
1485
+ debounceMs;
1486
+ ids;
1487
+ ui;
1488
+ draft = {
1489
+ activityId: null,
1490
+ collectionIds: [],
1491
+ createLevel: require_shareLink.DEFAULT_ZONE_LEVEL,
1492
+ createMode: require_shareLink.DEFAULT_ZONE_MODE,
1493
+ description: "",
1494
+ endAt: null,
1495
+ name: "",
1496
+ organizationId: null,
1497
+ range: require_shareLink.ZONE_DEFAULT_DISTANCE_RANGE_METERS,
1498
+ rangeType: "distance",
1499
+ speedKmh: null,
1500
+ startAt: null,
1501
+ windowOpen: false
1502
+ };
1503
+ nameTouched = false;
1504
+ organizationChosen = false;
1505
+ saving = /* @__PURE__ */ new Set();
1506
+ drawing = false;
1507
+ drawFailure = null;
1508
+ pickFailure = null;
1509
+ pickSerial = 0;
1510
+ origin = void 0;
1511
+ saveFailure = null;
1512
+ sourceRefusal = null;
1513
+ previewFailure = null;
1514
+ unsavedWritten = false;
1515
+ touched = false;
1516
+ bound = void 0;
1517
+ subject = null;
1518
+ subjectEpoch = 0;
1519
+ create = void 0;
1520
+ createSerial = void 0;
1521
+ sourceSeed = null;
1522
+ settled = null;
1523
+ judged = null;
1524
+ snapshot;
1525
+ subscriptions = /* @__PURE__ */ new Set();
1526
+ unwatch = null;
1527
+ previewKey = void 0;
1528
+ previewInput = null;
1529
+ previewEpoch = 0;
1530
+ timer = null;
1531
+ reconciling = false;
1532
+ stale = false;
1533
+ parked = true;
1534
+ disposed = false;
1535
+ constructor(options) {
1536
+ const { debounceMs, ids, ui, ...config } = options;
1537
+ this.debounceMs = debounceFrom(debounceMs);
1538
+ this.ids = ids;
1539
+ this.ui = ui;
1540
+ this.config = config;
1541
+ this.snapshot = this.view(noFacts).snapshot;
1542
+ }
1543
+ getSnapshot() {
1544
+ this.settle();
1545
+ return this.snapshot;
1546
+ }
1547
+ subscribe(listener) {
1548
+ if (this.disposed) return () => {};
1549
+ const subscription = { listener };
1550
+ this.subscriptions.add(subscription);
1551
+ if (this.parked) {
1552
+ this.parked = false;
1553
+ this.unwatch = this.ui.subscribe((state) => this.watch(state));
1554
+ this.reconcile();
1555
+ }
1556
+ return () => {
1557
+ if (!this.subscriptions.delete(subscription) || this.subscriptions.size > 0) return;
1558
+ if (!this.parked) this.park();
1559
+ };
1560
+ }
1561
+ configure(config) {
1562
+ if (this.disposed || sameMembers(this.config, config)) return;
1563
+ this.config = config;
1564
+ if (!this.parked) this.reconcile();
1565
+ }
1566
+ dispose() {
1567
+ if (this.disposed) return;
1568
+ this.disposed = true;
1569
+ if (!this.parked) this.park();
1570
+ this.subscriptions.clear();
1571
+ }
1572
+ edit(fields) {
1573
+ if (this.parked || this.disposed) return;
1574
+ this.touched = true;
1575
+ const { draft } = this;
1576
+ if (fields.rangeType !== void 0) {
1577
+ draft.rangeType = fields.rangeType;
1578
+ draft.range = fields.rangeType === "time" ? require_shareLink.ZONE_DEFAULT_TIME_RANGE_SECONDS : require_shareLink.ZONE_DEFAULT_DISTANCE_RANGE_METERS;
1579
+ if (fields.rangeType === "distance") draft.speedKmh = null;
1580
+ }
1581
+ if (fields.windowOpen !== void 0) {
1582
+ draft.windowOpen = fields.windowOpen;
1583
+ if (!fields.windowOpen) {
1584
+ draft.startAt = null;
1585
+ draft.endAt = null;
1586
+ }
1587
+ }
1588
+ if (fields.name !== void 0) {
1589
+ draft.name = fields.name;
1590
+ this.nameTouched = true;
1591
+ const session = this.ui.getState().zoneEditSession;
1592
+ if (this.bound === null && session?.intent === "create" && session.name !== null) this.ui.getState().setZoneEditName(null);
1593
+ }
1594
+ if (fields.description !== void 0) draft.description = fields.description;
1595
+ if (fields.startAt !== void 0) draft.startAt = fields.startAt;
1596
+ if (fields.endAt !== void 0) draft.endAt = fields.endAt;
1597
+ if (fields.name !== void 0 || fields.description !== void 0 || fields.startAt !== void 0 || fields.endAt !== void 0) this.saveFailure = null;
1598
+ if (fields.activityId !== void 0) draft.activityId = fields.activityId;
1599
+ if (fields.collectionIds !== void 0 && !sameIds(draft.collectionIds, fields.collectionIds)) draft.collectionIds = [...fields.collectionIds];
1600
+ if (fields.mode !== void 0) draft.createMode = fields.mode;
1601
+ if (fields.organizationId !== void 0) {
1602
+ draft.organizationId = fields.organizationId;
1603
+ this.organizationChosen = true;
1604
+ const session = this.ui.getState().zoneEditSession;
1605
+ if (this.bound === null && session?.intent === "create" && session.organizationId !== fields.organizationId) this.ui.getState().setZoneEditOrganization(fields.organizationId);
1606
+ }
1607
+ if (fields.range !== void 0) draft.range = fields.range;
1608
+ if (fields.speedKmh !== void 0) draft.speedKmh = draft.rangeType === "time" ? fields.speedKmh : null;
1609
+ const held = {
1610
+ level: draft.createLevel,
1611
+ pick: this.ui.getState().zoneCreatePickedLevel
1612
+ };
1613
+ if (fields.level !== void 0) {
1614
+ draft.createLevel = fields.level;
1615
+ if (this.bound === null && held.pick !== fields.level) this.ui.getState().setZoneCreatePickedLevel(fields.level);
1616
+ }
1617
+ this.reconcile();
1618
+ if (fields.level !== void 0 && this.snapshot.armed) this.recolour(fields.level, held);
1619
+ }
1620
+ async ask(name, input) {
1621
+ try {
1622
+ return await this.config.dispatch(name, input);
1623
+ } catch {
1624
+ return null;
1625
+ }
1626
+ }
1627
+ async recolour(level, held) {
1628
+ const epoch = this.subjectEpoch;
1629
+ if ((await this.ask("studio.zone.setLevel", { level }))?.ok !== true && !this.disposed && epoch === this.subjectEpoch && this.draft.createLevel === level) {
1630
+ this.draft.createLevel = held.level;
1631
+ if (this.bound === null && this.ui.getState().zoneCreatePickedLevel === level) this.ui.getState().setZoneCreatePickedLevel(held.pick);
1632
+ this.reconcile();
1633
+ }
1634
+ }
1635
+ setMethod(method) {
1636
+ if (this.parked || this.disposed) return;
1637
+ this.touched = true;
1638
+ this.switchMethod(method);
1639
+ }
1640
+ async switchMethod(method) {
1641
+ const epoch = this.subjectEpoch;
1642
+ const held = {
1643
+ preview: this.previewFailure,
1644
+ save: this.saveFailure,
1645
+ source: this.sourceRefusal
1646
+ };
1647
+ const answer = this.ask("studio.zone.setCreateMethod", { method });
1648
+ this.saveFailure = null;
1649
+ this.sourceRefusal = null;
1650
+ this.previewFailure = null;
1651
+ this.reconcile();
1652
+ if ((await answer)?.ok === true || this.disposed || epoch !== this.subjectEpoch) return;
1653
+ this.saveFailure ??= held.save;
1654
+ this.sourceRefusal ??= held.source;
1655
+ this.previewFailure ??= held.preview;
1656
+ this.reconcile();
1657
+ }
1658
+ beginOriginPick() {
1659
+ if (this.parked || this.disposed) return;
1660
+ this.touched = true;
1661
+ this.pickFailure = null;
1662
+ this.reconcile();
1663
+ this.pick();
1664
+ }
1665
+ async pick() {
1666
+ const epoch = this.subjectEpoch;
1667
+ this.pickSerial += 1;
1668
+ const asked = this.pickSerial;
1669
+ const result = await this.ask("studio.zone.beginOriginPick", {});
1670
+ if (result === null || result.ok || this.disposed || epoch !== this.subjectEpoch || asked !== this.pickSerial) return;
1671
+ this.pickFailure = result;
1672
+ this.reconcile();
1673
+ }
1674
+ beginDraw() {
1675
+ if (this.parked || this.disposed || this.drawing) return;
1676
+ const facts = factsOf(this.ui.getState());
1677
+ const { createLevel, createMode, organizationId } = this.draft;
1678
+ if (facts.zone !== null || facts.session !== null || createMode === null) return;
1679
+ this.drawing = true;
1680
+ this.drawFailure = null;
1681
+ this.reconcile();
1682
+ this.draw({
1683
+ intent: "create",
1684
+ level: createLevel,
1685
+ mode: createMode,
1686
+ organizationId: organizationId ?? void 0,
1687
+ zoneId: this.ids.next()
1688
+ });
1689
+ }
1690
+ async draw(input) {
1691
+ const epoch = this.subjectEpoch;
1692
+ const result = await this.ask("studio.zone.editBegin", input);
1693
+ if (result !== null && !result.ok && !this.disposed && epoch === this.subjectEpoch) this.drawFailure = result;
1694
+ this.drawing = false;
1695
+ this.reconcile();
1696
+ }
1697
+ async save() {
1698
+ const { subject } = this;
1699
+ if (this.parked || this.disposed || subject === null || this.saving.has(subject)) return;
1700
+ this.saveFailure = null;
1701
+ this.sourceRefusal = null;
1702
+ const request = this.saveRequest();
1703
+ if (request === null) {
1704
+ this.reconcile();
1705
+ return;
1706
+ }
1707
+ const query = queryKeyOf(this.statedSource());
1708
+ this.saving.add(subject);
1709
+ this.reconcile();
1710
+ try {
1711
+ const result = await this.run(request);
1712
+ if (this.disposed) return;
1713
+ if (!result.ok) {
1714
+ if (subject !== this.subject) return;
1715
+ if (query !== null && require_zoneSourceRefusal.zoneSourceRefused(result)) this.sourceRefusal = {
1716
+ failure: result,
1717
+ query
1718
+ };
1719
+ else this.saveFailure = result;
1720
+ return;
1721
+ }
1722
+ const failed = result.data !== void 0 && "failedCollectionIds" in result.data ? result.data.failedCollectionIds : [];
1723
+ if (failed.length > 0) this.ask("studio.alert.show", {
1724
+ level: "warning",
1725
+ message: this.config.strings.zoneForm.collectionAttachWarning(failed.length)
1726
+ });
1727
+ } finally {
1728
+ this.saving.delete(subject);
1729
+ this.reconcile();
1730
+ }
1731
+ }
1732
+ run(request) {
1733
+ switch (request.name) {
1734
+ case "studio.zone.create": return this.config.dispatch(request.name, request.input);
1735
+ case "studio.zone.editCommit": return this.config.dispatch(request.name, request.input);
1736
+ case "studio.zone.update": return this.config.dispatch(request.name, request.input);
1737
+ }
1738
+ }
1739
+ saveRequest() {
1740
+ const facts = factsOf(this.ui.getState());
1741
+ const { fields, method } = this.snapshot;
1742
+ const { zone } = facts;
1743
+ return require_shareLink.zoneSaveRequest({
1744
+ canEdit: zone === null || require_shareLink.canEditOwnedResource({
1745
+ createdById: zone.created_by.id,
1746
+ organizationId: zone.organization_id
1747
+ }, this.config.userId, this.config.writableOrganizationIds),
1748
+ fields,
1749
+ method,
1750
+ session: facts.session,
1751
+ source: this.sourceFor(facts, method),
1752
+ zone
1753
+ });
1754
+ }
1755
+ statedSource() {
1756
+ return this.sourceFor(factsOf(this.ui.getState()), this.snapshot.method);
1757
+ }
1758
+ publishUnsaved(unsaved) {
1759
+ if (this.parked || this.disposed || unsaved === this.unsavedWritten) return;
1760
+ this.unsavedWritten = unsaved;
1761
+ this.ui.getState().setZoneFormUnsaved(unsaved);
1762
+ }
1763
+ park() {
1764
+ if (this.unsavedWritten) {
1765
+ this.unsavedWritten = false;
1766
+ this.ui.getState().setZoneFormUnsaved(false);
1767
+ }
1768
+ this.parked = true;
1769
+ this.unwatch?.();
1770
+ this.unwatch = null;
1771
+ this.cancelPending();
1772
+ this.previewKey = void 0;
1773
+ this.previewInput = null;
1774
+ this.previewEpoch += 1;
1775
+ }
1776
+ settle() {
1777
+ if (this.disposed || !this.parked) return;
1778
+ const { settled } = this;
1779
+ if (settled !== null && settled.config === this.config && readsSame(settled.state, this.ui.getState())) return;
1780
+ this.reconcile();
1781
+ }
1782
+ watch(state) {
1783
+ const { settled } = this;
1784
+ if (settled !== null && settled.config === this.config && readsSame(settled.state, state)) {
1785
+ this.settled = {
1786
+ config: settled.config,
1787
+ state
1788
+ };
1789
+ return;
1790
+ }
1791
+ this.reconcile();
1792
+ }
1793
+ reconcile() {
1794
+ if (this.disposed) return;
1795
+ if (this.reconciling) {
1796
+ this.stale = true;
1797
+ return;
1798
+ }
1799
+ this.reconciling = true;
1800
+ try {
1801
+ do {
1802
+ this.stale = false;
1803
+ const state = this.ui.getState();
1804
+ this.settled = {
1805
+ config: this.config,
1806
+ state
1807
+ };
1808
+ const facts = factsOf(state);
1809
+ this.seed(facts);
1810
+ const view = this.view(facts);
1811
+ this.commit(view.snapshot);
1812
+ this.publishUnsaved(view.changed);
1813
+ this.followPreview(view);
1814
+ } while (this.stale && !this.disposed);
1815
+ } finally {
1816
+ this.reconciling = false;
1817
+ }
1818
+ }
1819
+ seed(facts) {
1820
+ const { draft } = this;
1821
+ const { activities, defaultOrganizationId, inheritedCollectionIds } = this.config;
1822
+ const { inherited, zone } = facts;
1823
+ const previous = this.bound;
1824
+ if (zone !== previous) {
1825
+ this.bound = zone;
1826
+ if (zone !== null && previous != null && previous.id === zone.id) this.follow(previous, zone, facts.session);
1827
+ else this.seedMetadata(zone);
1828
+ } else if (zone === null && facts.createSerial !== this.createSerial) this.seedMetadata(null);
1829
+ this.createSerial = zone === null ? facts.createSerial : void 0;
1830
+ const create = zone === null ? `${facts.createSerial}:${inherited?.itineraryId ?? ""}` : void 0;
1831
+ const subject = zone === null ? `create:${facts.createMethod ?? "draw"}:${create ?? ""}` : `zone:${zone.id}`;
1832
+ if (subject !== this.subject) {
1833
+ this.subject = subject;
1834
+ this.touched = false;
1835
+ this.drawFailure = null;
1836
+ this.pickFailure = null;
1837
+ this.saveFailure = null;
1838
+ this.sourceRefusal = null;
1839
+ this.previewFailure = null;
1840
+ this.subjectEpoch += 1;
1841
+ this.previewEpoch += 1;
1842
+ }
1843
+ if (facts.origin !== this.origin) {
1844
+ this.origin = facts.origin;
1845
+ this.pickFailure = null;
1846
+ }
1847
+ if (facts.session !== null) this.drawFailure = null;
1848
+ if (create !== this.create) {
1849
+ this.create = create;
1850
+ if (create !== void 0) this.resetCreate();
1851
+ }
1852
+ this.seedParameters(zone);
1853
+ if (zone !== null) return;
1854
+ if (inherited) {
1855
+ draft.organizationId = inherited.organizationId;
1856
+ if (!sameIds(draft.collectionIds, inheritedCollectionIds)) draft.collectionIds = [...inheritedCollectionIds];
1857
+ if (activities.length > 0) draft.activityId = inherited.activityId;
1858
+ } else {
1859
+ if (draft.organizationId === null && !this.organizationChosen) draft.organizationId = defaultOrganizationId;
1860
+ if (draft.activityId === null && activities.length > 0) draft.activityId = require_shareLink.firstRoutableActivityId(activities);
1861
+ }
1862
+ if (!this.nameTouched) {
1863
+ const name = require_shareLink.zoneAutoName({
1864
+ activityName: this.activityName(),
1865
+ language: this.config.language,
1866
+ method: facts.createMethod ?? "draw",
1867
+ proposedName: facts.session?.name ?? null,
1868
+ range: draft.range,
1869
+ rangeType: draft.rangeType,
1870
+ strings: this.config.strings.zoneForm
1871
+ });
1872
+ if (name !== null) draft.name = name;
1873
+ }
1874
+ }
1875
+ seedParameters(zone) {
1876
+ const { draft } = this;
1877
+ const { activities } = this.config;
1878
+ const seeded = this.sourceSeed;
1879
+ if (seeded?.zone !== zone || seeded.activities !== activities) {
1880
+ this.sourceSeed = {
1881
+ activities,
1882
+ zone
1883
+ };
1884
+ const source = zone?.source;
1885
+ if (source) {
1886
+ const says = require_shareLink.parametersOf(activities, source);
1887
+ const earlier = seeded?.zone?.id === zone?.id ? seeded?.zone?.source : void 0;
1888
+ if (seeded && earlier && draft.activityId === require_shareLink.activityIdForSlug(seeded.activities, earlier.activity)) draft.activityId = require_shareLink.activityIdForSlug(activities, earlier.activity);
1889
+ const said = earlier ? require_shareLink.parametersOf(activities, earlier) : null;
1890
+ const held = {
1891
+ activityId: draft.activityId,
1892
+ range: draft.range,
1893
+ rangeType: draft.rangeType,
1894
+ speedKmh: draft.speedKmh
1895
+ };
1896
+ if (said === null || sameMembers(held, said) || sameMembers(held, says)) {
1897
+ draft.activityId = says.activityId;
1898
+ draft.rangeType = says.rangeType;
1899
+ draft.range = says.range;
1900
+ draft.speedKmh = says.speedKmh;
1901
+ }
1902
+ }
1903
+ }
1904
+ if (draft.activityId !== null && activities.length > 0 && require_shareLink.activityForId(activities, draft.activityId) === null) {
1905
+ const stored = zone?.source?.activity;
1906
+ draft.activityId = stored === void 0 ? null : require_shareLink.activityIdForSlug(activities, stored);
1907
+ }
1908
+ }
1909
+ seedMetadata(zone) {
1910
+ const { draft } = this;
1911
+ draft.name = zone?.name ?? "";
1912
+ draft.description = zone?.description ?? "";
1913
+ draft.startAt = zone?.start_at ?? null;
1914
+ draft.endAt = zone?.end_at ?? null;
1915
+ draft.windowOpen = draft.startAt !== null || draft.endAt !== null;
1916
+ draft.createLevel = zone?.level ?? "info";
1917
+ this.nameTouched = zone !== null;
1918
+ }
1919
+ follow(previous, next, session) {
1920
+ const { draft } = this;
1921
+ if (session !== null && session.zoneId === next.id && session.level === previous.level && next.level !== previous.level) this.ask("studio.zone.setLevel", { level: next.level });
1922
+ if (!require_shareLink.typedOver("name", draft.name, previous, next)) draft.name = next.name;
1923
+ if (!require_shareLink.typedOver("description", draft.description, previous, next)) draft.description = next.description ?? "";
1924
+ if (!require_shareLink.typedOver("level", draft.createLevel, previous, next)) draft.createLevel = next.level;
1925
+ if (!(require_shareLink.typedOver("startAt", draft.startAt, previous, next) || require_shareLink.typedOver("endAt", draft.endAt, previous, next) || draft.windowOpen !== require_shareLink.windowOpens(previous) && draft.windowOpen !== require_shareLink.windowOpens(next))) {
1926
+ draft.startAt = next.start_at;
1927
+ draft.endAt = next.end_at;
1928
+ draft.windowOpen = require_shareLink.windowOpens(next);
1929
+ }
1930
+ }
1931
+ resetCreate() {
1932
+ const { draft } = this;
1933
+ this.organizationChosen = false;
1934
+ draft.activityId = null;
1935
+ if (draft.collectionIds.length > 0) draft.collectionIds = [];
1936
+ draft.createMode = require_shareLink.DEFAULT_ZONE_MODE;
1937
+ draft.organizationId = null;
1938
+ draft.range = require_shareLink.ZONE_DEFAULT_DISTANCE_RANGE_METERS;
1939
+ draft.rangeType = "distance";
1940
+ draft.speedKmh = null;
1941
+ }
1942
+ activityName() {
1943
+ const { activityId } = this.draft;
1944
+ const activity = activityId === null ? null : require_shareLink.activityForId(this.config.activities, activityId);
1945
+ return activity ? (0, _mountaya_elements_i18n.localizedName)(activity, this.config.language) : null;
1946
+ }
1947
+ sourceFor(facts, method) {
1948
+ const { activityId, range, rangeType, speedKmh } = this.draft;
1949
+ const activity = activityId === null ? null : require_shareLink.activityForId(this.config.activities, activityId);
1950
+ return require_shareLink.zoneSourceQuery({
1951
+ activitySlug: activity?.slug ?? null,
1952
+ method,
1953
+ origin: facts.origin,
1954
+ range,
1955
+ rangeType,
1956
+ speedKmh
1957
+ });
1958
+ }
1959
+ view(facts) {
1960
+ const { draft } = this;
1961
+ const { session, zone } = facts;
1962
+ const method = zone === null ? facts.createMethod ?? "draw" : zone.source ? "reachability" : "draw";
1963
+ const fields = {
1964
+ activityId: draft.activityId,
1965
+ collectionIds: draft.collectionIds,
1966
+ description: draft.description,
1967
+ endAt: draft.endAt,
1968
+ level: session?.level ?? draft.createLevel,
1969
+ mode: zone === null ? session?.mode ?? draft.createMode : zone.mode,
1970
+ name: zone === null ? session?.name ?? draft.name : draft.name,
1971
+ organizationId: zone === null ? session?.organizationId ?? draft.organizationId : draft.organizationId,
1972
+ range: draft.range,
1973
+ rangeType: draft.rangeType,
1974
+ speedKmh: draft.speedKmh,
1975
+ startAt: draft.startAt,
1976
+ windowOpen: draft.windowOpen
1977
+ };
1978
+ const source = this.sourceFor(facts, method);
1979
+ const armed = session !== null;
1980
+ const metadataDirty = zone !== null && require_shareLink.isZoneMetadataDirty(fields, zone);
1981
+ const sourceDirty = zone !== null && require_shareLink.isZoneSourceDirty(source, zone.source);
1982
+ const { descriptionValid, nameValid } = this.judge(fields.name, fields.description);
1983
+ const saving = this.subject !== null && this.saving.has(this.subject);
1984
+ const windowValid = !require_shareLink.isZoneWindowInvalid(fields.startAt, fields.endAt);
1985
+ const reachabilityCreate = zone === null && method === "reachability";
1986
+ const previewFailure = source === null ? null : this.previewFailure;
1987
+ const refused = this.sourceRefusal;
1988
+ const sourceFailure = refused !== null && refused.query === queryKeyOf(source) ? refused.failure : null;
1989
+ const unsaved = zone === null ? reachabilityCreate ? source !== null && previewFailure === null : require_shareLink.isZoneGeometryDirty(session) : require_shareLink.isZoneGeometryDirty(session) || metadataDirty || sourceDirty;
1990
+ const changed = reachabilityCreate ? unsaved && this.touched : unsaved;
1991
+ const preview = source === null ? null : {
1992
+ activity: source.activity,
1993
+ level: fields.level,
1994
+ location: source.location,
1995
+ ranges: [source.range],
1996
+ rangeType: source.range_type,
1997
+ speed: source.speed
1998
+ };
1999
+ return {
2000
+ preview,
2001
+ previewKey: preview === null ? null : JSON.stringify(preview),
2002
+ snapshot: {
2003
+ armed,
2004
+ descriptionValid,
2005
+ drawFailure: this.drawFailure,
2006
+ fields,
2007
+ inherits: facts.inherited !== null,
2008
+ method,
2009
+ nameValid,
2010
+ pickFailure: this.pickFailure,
2011
+ previewFailure,
2012
+ saveFailure: this.saveFailure,
2013
+ saveOffered: reachabilityCreate || armed || metadataDirty || sourceDirty,
2014
+ saveReady: !saving && nameValid && descriptionValid && windowValid && unsaved,
2015
+ saving,
2016
+ sourceFailure,
2017
+ windowValid,
2018
+ zoneId: zone?.id ?? null
2019
+ },
2020
+ changed
2021
+ };
2022
+ }
2023
+ judge(name, description) {
2024
+ const last = this.judged;
2025
+ if (last !== null && last.name === name && last.description === description) return last;
2026
+ const judged = {
2027
+ description,
2028
+ descriptionValid: require_scope.zoneDescriptionSchema.safeParse(description).success,
2029
+ name,
2030
+ nameValid: require_scope.zoneNameSchema.safeParse(name).success
2031
+ };
2032
+ this.judged = judged;
2033
+ return judged;
2034
+ }
2035
+ commit(next) {
2036
+ const fields = sameMembers(this.snapshot.fields, next.fields) ? this.snapshot.fields : next.fields;
2037
+ const snapshot = {
2038
+ ...next,
2039
+ fields
2040
+ };
2041
+ if (sameMembers(this.snapshot, snapshot)) return;
2042
+ this.snapshot = snapshot;
2043
+ require_listeners.notifyListeners(Array.from(this.subscriptions, (subscription) => subscription.listener));
2044
+ }
2045
+ followPreview(view) {
2046
+ if (this.parked || view.previewKey === this.previewKey) return;
2047
+ this.cancelPending();
2048
+ this.previewKey = view.previewKey;
2049
+ this.previewInput = view.preview;
2050
+ this.previewEpoch += 1;
2051
+ if (view.preview === null) {
2052
+ this.previewFailure = null;
2053
+ return;
2054
+ }
2055
+ if (this.debounceMs === 0) {
2056
+ this.askPreview();
2057
+ return;
2058
+ }
2059
+ this.timer = setTimeout(() => {
2060
+ this.timer = null;
2061
+ this.askPreview();
2062
+ }, this.debounceMs);
2063
+ }
2064
+ askPreview() {
2065
+ const input = this.previewInput;
2066
+ if (input === null) return;
2067
+ const epoch = this.previewEpoch;
2068
+ this.ask("studio.zone.reachabilityPreview", input).then((result) => {
2069
+ if (result === null || epoch !== this.previewEpoch || this.parked) return;
2070
+ this.previewFailure = result.ok ? null : result;
2071
+ this.reconcile();
2072
+ });
2073
+ }
2074
+ cancelPending() {
2075
+ if (this.timer !== null) {
2076
+ clearTimeout(this.timer);
2077
+ this.timer = null;
2078
+ }
2079
+ }
2080
+ };
2081
+ exports.EmbedFramingEngine = EmbedFramingEngine;
2082
+ exports.EmbedReadyEngine = EmbedReadyEngine;
2083
+ exports.FRAMING_PAGE_SESSION_TIMEOUT_MS = FRAMING_PAGE_SESSION_TIMEOUT_MS;
2084
+ exports.ItineraryPaceEngine = ItineraryPaceEngine;
2085
+ exports.ProfileMarkerEngine = ProfileMarkerEngine;
2086
+ exports.SegmentDraftEngine = SegmentDraftEngine;
2087
+ exports.ShareLinkEngine = ShareLinkEngine;
2088
+ exports.ZoneFormEngine = ZoneFormEngine;
2089
+ exports.askFramingPageForSession = askFramingPageForSession;
2090
+
2091
+ //# sourceMappingURL=index.cjs.map