@mountaya/studio 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (524) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +917 -2
  5. package/dist/agent/index.cjs +2854 -0
  6. package/dist/agent/index.cjs.map +1 -0
  7. package/dist/agent/index.d.cts +1257 -0
  8. package/dist/agent/index.d.ts +1257 -0
  9. package/dist/agent/index.js +2818 -0
  10. package/dist/agent/index.js.map +1 -0
  11. package/dist/bus-BwiNiXdH.d.ts +514 -0
  12. package/dist/bus-DzmhPwdK.d.cts +514 -0
  13. package/dist/chainModel-B23pEP_1.d.cts +127 -0
  14. package/dist/chainModel-B23pEP_1.d.ts +127 -0
  15. package/dist/chunk-2HFY7ETU.js +5721 -0
  16. package/dist/chunk-2HFY7ETU.js.map +1 -0
  17. package/dist/chunk-355TOXSB.js +72 -0
  18. package/dist/chunk-355TOXSB.js.map +1 -0
  19. package/dist/chunk-4ZCUZVSV.js +10275 -0
  20. package/dist/chunk-4ZCUZVSV.js.map +1 -0
  21. package/dist/chunk-6HEKY3NF.js +95 -0
  22. package/dist/chunk-6HEKY3NF.js.map +1 -0
  23. package/dist/chunk-7GFLGGBX.cjs +8 -0
  24. package/dist/chunk-7GFLGGBX.cjs.map +1 -0
  25. package/dist/chunk-7NBRCENN.cjs +19 -0
  26. package/dist/chunk-7NBRCENN.cjs.map +1 -0
  27. package/dist/chunk-AF5GCXE3.js +8 -0
  28. package/dist/chunk-AF5GCXE3.js.map +1 -0
  29. package/dist/chunk-CJDIFRGZ.cjs +2005 -0
  30. package/dist/chunk-CJDIFRGZ.cjs.map +1 -0
  31. package/dist/chunk-CNPZY7N3.js +349 -0
  32. package/dist/chunk-CNPZY7N3.js.map +1 -0
  33. package/dist/chunk-DZJHTWSF.cjs +45 -0
  34. package/dist/chunk-DZJHTWSF.cjs.map +1 -0
  35. package/dist/chunk-EABIHHWA.js +42 -0
  36. package/dist/chunk-EABIHHWA.js.map +1 -0
  37. package/dist/chunk-EKZWV6RS.cjs +415 -0
  38. package/dist/chunk-EKZWV6RS.cjs.map +1 -0
  39. package/dist/chunk-EOKRXXAC.cjs +24 -0
  40. package/dist/chunk-EOKRXXAC.cjs.map +1 -0
  41. package/dist/chunk-F73W2ZTJ.js +1126 -0
  42. package/dist/chunk-F73W2ZTJ.js.map +1 -0
  43. package/dist/chunk-H4DVOZ5O.js +1897 -0
  44. package/dist/chunk-H4DVOZ5O.js.map +1 -0
  45. package/dist/chunk-HI52PBFT.cjs +10314 -0
  46. package/dist/chunk-HI52PBFT.cjs.map +1 -0
  47. package/dist/chunk-IDBXFBLG.cjs +1225 -0
  48. package/dist/chunk-IDBXFBLG.cjs.map +1 -0
  49. package/dist/chunk-LBWTJZUJ.js +297 -0
  50. package/dist/chunk-LBWTJZUJ.js.map +1 -0
  51. package/dist/chunk-NCLA6DKD.cjs +310 -0
  52. package/dist/chunk-NCLA6DKD.cjs.map +1 -0
  53. package/dist/chunk-O4MC5DPD.js +19 -0
  54. package/dist/chunk-O4MC5DPD.js.map +1 -0
  55. package/dist/chunk-OP37FKW6.cjs +98 -0
  56. package/dist/chunk-OP37FKW6.cjs.map +1 -0
  57. package/dist/chunk-OQSYFH3Z.cjs +5945 -0
  58. package/dist/chunk-OQSYFH3Z.cjs.map +1 -0
  59. package/dist/chunk-PACIO4NS.cjs +26 -0
  60. package/dist/chunk-PACIO4NS.cjs.map +1 -0
  61. package/dist/chunk-PSZ2R3TC.cjs +75 -0
  62. package/dist/chunk-PSZ2R3TC.cjs.map +1 -0
  63. package/dist/chunk-QFO5CZG2.cjs +136 -0
  64. package/dist/chunk-QFO5CZG2.cjs.map +1 -0
  65. package/dist/chunk-QL63MUEW.cjs +140 -0
  66. package/dist/chunk-QL63MUEW.cjs.map +1 -0
  67. package/dist/chunk-RFUPPVZO.js +17 -0
  68. package/dist/chunk-RFUPPVZO.js.map +1 -0
  69. package/dist/chunk-RPG2LWMP.js +23 -0
  70. package/dist/chunk-RPG2LWMP.js.map +1 -0
  71. package/dist/chunk-TIBXK6B7.cjs +12 -0
  72. package/dist/chunk-TIBXK6B7.cjs.map +1 -0
  73. package/dist/chunk-UU65VNEV.js +381 -0
  74. package/dist/chunk-UU65VNEV.js.map +1 -0
  75. package/dist/chunk-VGX6TR2I.js +209 -0
  76. package/dist/chunk-VGX6TR2I.js.map +1 -0
  77. package/dist/chunk-WUTDDBVP.js +130 -0
  78. package/dist/chunk-WUTDDBVP.js.map +1 -0
  79. package/dist/chunk-WVQQLKCI.cjs +224 -0
  80. package/dist/chunk-WVQQLKCI.cjs.map +1 -0
  81. package/dist/chunk-WZYXG3SE.js +111 -0
  82. package/dist/chunk-WZYXG3SE.js.map +1 -0
  83. package/dist/chunk-XDI2X3KE.js +6 -0
  84. package/dist/chunk-XDI2X3KE.js.map +1 -0
  85. package/dist/chunk-XKHLRIC7.cjs +381 -0
  86. package/dist/chunk-XKHLRIC7.cjs.map +1 -0
  87. package/dist/context-DNtd2WUv.d.cts +11666 -0
  88. package/dist/context-DgB72Bur.d.ts +11666 -0
  89. package/dist/directorThreads-CqmvsV8b.d.cts +80 -0
  90. package/dist/directorThreads-CqmvsV8b.d.ts +80 -0
  91. package/dist/en-Bu4Ti9Ev.d.cts +2315 -0
  92. package/dist/en-Bu4Ti9Ev.d.ts +2315 -0
  93. package/dist/engines/index.cjs +3446 -0
  94. package/dist/engines/index.cjs.map +1 -0
  95. package/dist/engines/index.d.cts +2216 -0
  96. package/dist/engines/index.d.ts +2216 -0
  97. package/dist/engines/index.js +3416 -0
  98. package/dist/engines/index.js.map +1 -0
  99. package/dist/handlers/index.cjs +99 -0
  100. package/dist/handlers/index.cjs.map +1 -0
  101. package/dist/handlers/index.d.cts +445 -0
  102. package/dist/handlers/index.d.ts +445 -0
  103. package/dist/handlers/index.js +42 -0
  104. package/dist/handlers/index.js.map +1 -0
  105. package/dist/index.cjs +4562 -0
  106. package/dist/index.cjs.map +1 -0
  107. package/dist/index.d.cts +7297 -0
  108. package/dist/index.d.ts +7297 -0
  109. package/dist/index.js +3223 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/plugins/index.cjs +977 -0
  112. package/dist/plugins/index.cjs.map +1 -0
  113. package/dist/plugins/index.d.cts +313 -0
  114. package/dist/plugins/index.d.ts +313 -0
  115. package/dist/plugins/index.js +933 -0
  116. package/dist/plugins/index.js.map +1 -0
  117. package/dist/saveFile-j-1kkApx.d.cts +123 -0
  118. package/dist/saveFile-j-1kkApx.d.ts +123 -0
  119. package/dist/seams/index.cjs +152 -0
  120. package/dist/seams/index.cjs.map +1 -0
  121. package/dist/seams/index.d.cts +485 -0
  122. package/dist/seams/index.d.ts +485 -0
  123. package/dist/seams/index.js +79 -0
  124. package/dist/seams/index.js.map +1 -0
  125. package/dist/shareLink-B6hlt942.d.ts +144 -0
  126. package/dist/shareLink-C7rIMb7x.d.ts +527 -0
  127. package/dist/shareLink-CnTxxXjp.d.cts +144 -0
  128. package/dist/shareLink-DyZVYH2V.d.cts +527 -0
  129. package/dist/strings/fr/index.cjs +2121 -0
  130. package/dist/strings/fr/index.cjs.map +1 -0
  131. package/dist/strings/fr/index.d.cts +19 -0
  132. package/dist/strings/fr/index.d.ts +19 -0
  133. package/dist/strings/fr/index.js +2119 -0
  134. package/dist/strings/fr/index.js.map +1 -0
  135. package/dist/strings/index.cjs +2678 -0
  136. package/dist/strings/index.cjs.map +1 -0
  137. package/dist/strings/index.d.cts +731 -0
  138. package/dist/strings/index.d.ts +731 -0
  139. package/dist/strings/index.js +2644 -0
  140. package/dist/strings/index.js.map +1 -0
  141. package/dist/studioPlugin-C3C7VjMy.d.ts +847 -0
  142. package/dist/studioPlugin-Cf3OBNUv.d.cts +847 -0
  143. package/dist/tabs-B2nRO4p_.d.cts +15 -0
  144. package/dist/tabs-B2nRO4p_.d.ts +15 -0
  145. package/dist/testing/index.cjs +292 -0
  146. package/dist/testing/index.cjs.map +1 -0
  147. package/dist/testing/index.d.cts +306 -0
  148. package/dist/testing/index.d.ts +306 -0
  149. package/dist/testing/index.js +284 -0
  150. package/dist/testing/index.js.map +1 -0
  151. package/dist/time/index.cjs +28 -0
  152. package/dist/time/index.cjs.map +1 -0
  153. package/dist/time/index.d.cts +43 -0
  154. package/dist/time/index.d.ts +43 -0
  155. package/dist/time/index.js +26 -0
  156. package/dist/time/index.js.map +1 -0
  157. package/dist/types-BzJRV6UI.d.cts +845 -0
  158. package/dist/types-BzJRV6UI.d.ts +845 -0
  159. package/dist/zoneForm-CdYNtnnA.d.cts +320 -0
  160. package/dist/zoneForm-mG85yt5e.d.ts +320 -0
  161. package/package.json +225 -4
  162. package/src/agent/engines/agentThreads.ts +1601 -0
  163. package/src/agent/engines/directorChat.ts +500 -0
  164. package/src/agent/index.ts +67 -0
  165. package/src/agent/rules/agentEditLock.ts +115 -0
  166. package/src/agent/rules/agentErrorCopy.ts +44 -0
  167. package/src/agent/rules/copilotOrganization.ts +36 -0
  168. package/src/agent/rules/playbook.gen.ts +444 -0
  169. package/src/agent/rules/router.ts +518 -0
  170. package/src/agent/rules/stateDelta.ts +28 -0
  171. package/src/agent/rules/studioRouter.ts +123 -0
  172. package/src/agent/rules/surfaces.gen.ts +633 -0
  173. package/src/agent/rules/threadsUrl.ts +48 -0
  174. package/src/agent/rules/transcriptObserver.ts +90 -0
  175. package/src/agent/stores/agentThreads.ts +454 -0
  176. package/src/bus/contracts/noData.ts +18 -0
  177. package/src/bus/contracts/shared.ts +172 -0
  178. package/src/bus/contracts/studioTools.ts +224 -0
  179. package/src/bus/rules/bus.ts +858 -0
  180. package/src/bus/rules/confirmation.ts +22 -0
  181. package/src/bus/rules/defineRegistry.ts +26 -0
  182. package/src/bus/rules/errors.ts +401 -0
  183. package/src/bus/rules/handlerErrors.ts +103 -0
  184. package/src/bus/rules/handlerRegistry.ts +627 -0
  185. package/src/bus/rules/inputSchema.ts +232 -0
  186. package/src/bus/rules/invalidInput.ts +441 -0
  187. package/src/bus/rules/lateBoundTools.ts +100 -0
  188. package/src/bus/rules/studioRegistry.ts +324 -0
  189. package/src/bus/rules/studioToolBus.ts +73 -0
  190. package/src/bus/rules/types.ts +805 -0
  191. package/src/chrome/contracts/alert.ts +42 -0
  192. package/src/chrome/contracts/itinerary.ts +26 -0
  193. package/src/chrome/contracts/map.ts +23 -0
  194. package/src/chrome/contracts/overlay.ts +46 -0
  195. package/src/chrome/contracts/panel.ts +29 -0
  196. package/src/chrome/contracts/question.ts +52 -0
  197. package/src/chrome/contracts/selection.ts +26 -0
  198. package/src/chrome/contracts/sidenav.ts +23 -0
  199. package/src/chrome/contracts/snapshot.ts +319 -0
  200. package/src/chrome/contracts/state.ts +22 -0
  201. package/src/chrome/contracts/tabs.ts +56 -0
  202. package/src/chrome/handlers/alert.ts +91 -0
  203. package/src/chrome/handlers/introspection.ts +180 -0
  204. package/src/chrome/handlers/panels.ts +42 -0
  205. package/src/chrome/handlers/question.ts +24 -0
  206. package/src/chrome/handlers/sidenav.ts +116 -0
  207. package/src/chrome/handlers/snapshot.ts +451 -0
  208. package/src/chrome/handlers/stateDelta.ts +125 -0
  209. package/src/chrome/handlers/tabs.ts +143 -0
  210. package/src/chrome/handlers/timestamp.ts +19 -0
  211. package/src/chrome/rules/agentSelectors.ts +210 -0
  212. package/src/chrome/rules/mapAlert.ts +13 -0
  213. package/src/chrome/rules/question.ts +25 -0
  214. package/src/chrome/rules/tabs.ts +13 -0
  215. package/src/chrome/stores/activeDraftSession.ts +134 -0
  216. package/src/chrome/stores/chrome.ts +527 -0
  217. package/src/chrome/stores/uiStore.ts +573 -0
  218. package/src/collab/contracts/collab.ts +261 -0
  219. package/src/collab/handlers/collab.ts +468 -0
  220. package/src/collab/rules/toolNames.ts +33 -0
  221. package/src/collab/stores/collab.ts +899 -0
  222. package/src/collections/contracts/collection.ts +182 -0
  223. package/src/collections/handlers/collectionAttach.ts +141 -0
  224. package/src/collections/handlers/collections.ts +499 -0
  225. package/src/collections/handlers/heldCollection.ts +42 -0
  226. package/src/collections/handlers/restCollections.ts +386 -0
  227. package/src/collections/rules/collections.ts +138 -0
  228. package/src/collections/rules/entityCollections.ts +53 -0
  229. package/src/collections/stores/collections.ts +133 -0
  230. package/src/data/contracts/data.ts +233 -0
  231. package/src/data/contracts/itinerary.ts +71 -0
  232. package/src/data/handlers/activityResolve.ts +76 -0
  233. package/src/data/handlers/data.ts +200 -0
  234. package/src/data/handlers/graphql.ts +26 -0
  235. package/src/data/handlers/mutationSink.ts +1577 -0
  236. package/src/data/handlers/profile.ts +83 -0
  237. package/src/data/handlers/writeThrough.ts +417 -0
  238. package/src/data/rules/cache.ts +181 -0
  239. package/src/data/rules/dataTypes.ts +40 -0
  240. package/src/data/rules/keys.ts +106 -0
  241. package/src/data/rules/persistence.ts +1058 -0
  242. package/src/data/rules/requestBody.ts +43 -0
  243. package/src/data/rules/restErrors.ts +354 -0
  244. package/src/data/rules/sessionSurface.ts +156 -0
  245. package/src/data/rules/toolResultData.ts +73 -0
  246. package/src/data/rules/uuid.ts +24 -0
  247. package/src/edit/contracts/edit.ts +37 -0
  248. package/src/edit/contracts/itinerary.ts +57 -0
  249. package/src/edit/handlers/draftCommit.ts +257 -0
  250. package/src/edit/handlers/editDiscard.ts +34 -0
  251. package/src/edit/handlers/editLock.ts +949 -0
  252. package/src/edit/handlers/editor.ts +203 -0
  253. package/src/edit/handlers/formUnsaved.ts +24 -0
  254. package/src/edit/rules/draftMetadata.ts +117 -0
  255. package/src/edit/rules/editKeyboard.ts +222 -0
  256. package/src/edit/rules/editShortcuts.ts +102 -0
  257. package/src/edit/rules/editTooltip.ts +174 -0
  258. package/src/edit/rules/editorTaken.ts +49 -0
  259. package/src/edit/rules/history.ts +26 -0
  260. package/src/edit/rules/unsavedWork.ts +60 -0
  261. package/src/edit/stores/editorReservation.ts +70 -0
  262. package/src/edit/stores/formsUnsaved.ts +54 -0
  263. package/src/embed/contracts/embed.ts +48 -0
  264. package/src/embed/engines/embedFraming.ts +1329 -0
  265. package/src/embed/engines/embedReady.ts +353 -0
  266. package/src/embed/engines/framingPageSession.ts +169 -0
  267. package/src/embed/handlers/embed.ts +130 -0
  268. package/src/embed/rules/allowedDomains.ts +71 -0
  269. package/src/embed/rules/bridgeMessages.ts +224 -0
  270. package/src/embed/rules/defaults.ts +173 -0
  271. package/src/embed/rules/displaySeed.ts +115 -0
  272. package/src/embed/rules/embedAllowlist.ts +146 -0
  273. package/src/embed/rules/embedConstraints.ts +215 -0
  274. package/src/embed/rules/embedElements.ts +277 -0
  275. package/src/embed/rules/embedSectionFields.ts +126 -0
  276. package/src/embed/rules/embedSecurity.ts +116 -0
  277. package/src/embed/rules/fieldDependencies.ts +87 -0
  278. package/src/embed/rules/fieldOptions.ts +138 -0
  279. package/src/embed/rules/layerOptions.ts +161 -0
  280. package/src/embed/rules/readyProtocol.ts +66 -0
  281. package/src/embed/rules/safetyRules.ts +213 -0
  282. package/src/embed/rules/snippet.ts +531 -0
  283. package/src/embed/rules/tableCode.ts +269 -0
  284. package/src/embed/stores/embed.ts +60 -0
  285. package/src/embed/stores/embedContent.ts +77 -0
  286. package/src/engines/index.ts +81 -0
  287. package/src/handlers/index.ts +66 -0
  288. package/src/index.ts +1086 -0
  289. package/src/itinerary/contracts/itinerary.ts +705 -0
  290. package/src/itinerary/engines/itineraryPace.ts +612 -0
  291. package/src/itinerary/engines/profileMarker.ts +238 -0
  292. package/src/itinerary/handlers/importStaging.ts +352 -0
  293. package/src/itinerary/handlers/itinerary.ts +572 -0
  294. package/src/itinerary/handlers/itineraryDuplicate.ts +177 -0
  295. package/src/itinerary/handlers/itineraryExport.ts +117 -0
  296. package/src/itinerary/handlers/itineraryImport.ts +783 -0
  297. package/src/itinerary/handlers/itineraryPublish.ts +118 -0
  298. package/src/itinerary/handlers/itinerarySelection.ts +354 -0
  299. package/src/itinerary/handlers/itinerarySuggest.ts +1186 -0
  300. package/src/itinerary/handlers/itineraryUnpublish.ts +101 -0
  301. package/src/itinerary/handlers/publicationScope.ts +118 -0
  302. package/src/itinerary/handlers/restItineraries.ts +752 -0
  303. package/src/itinerary/handlers/restItineraryExport.ts +70 -0
  304. package/src/itinerary/handlers/restItineraryImport.ts +311 -0
  305. package/src/itinerary/handlers/restItineraryPace.ts +87 -0
  306. package/src/itinerary/handlers/restItineraryRecord.ts +36 -0
  307. package/src/itinerary/handlers/suggestParams.ts +379 -0
  308. package/src/itinerary/handlers/suggestStaging.ts +363 -0
  309. package/src/itinerary/handlers/surfaceOpen.ts +389 -0
  310. package/src/itinerary/rules/activity.ts +139 -0
  311. package/src/itinerary/rules/analysis.ts +42 -0
  312. package/src/itinerary/rules/ceiling.ts +49 -0
  313. package/src/itinerary/rules/createFlow.ts +107 -0
  314. package/src/itinerary/rules/densify.ts +440 -0
  315. package/src/itinerary/rules/draftSurface.ts +219 -0
  316. package/src/itinerary/rules/editorView.ts +83 -0
  317. package/src/itinerary/rules/export.ts +159 -0
  318. package/src/itinerary/rules/friendlyName.ts +77 -0
  319. package/src/itinerary/rules/import.ts +1052 -0
  320. package/src/itinerary/rules/importFiles.ts +140 -0
  321. package/src/itinerary/rules/importTotals.ts +77 -0
  322. package/src/itinerary/rules/liveSegment.ts +712 -0
  323. package/src/itinerary/rules/lngLat.ts +17 -0
  324. package/src/itinerary/rules/mapSync.ts +100 -0
  325. package/src/itinerary/rules/previewRender.ts +416 -0
  326. package/src/itinerary/rules/profileReadout.ts +216 -0
  327. package/src/itinerary/rules/routing.ts +707 -0
  328. package/src/itinerary/rules/suggest.ts +522 -0
  329. package/src/itinerary/rules/suggestionPreview.ts +119 -0
  330. package/src/itinerary/rules/view.ts +61 -0
  331. package/src/itinerary/stores/importSession.ts +319 -0
  332. package/src/itinerary/stores/itinerary.ts +331 -0
  333. package/src/itinerary/stores/itineraryDuplicate.ts +76 -0
  334. package/src/itinerary/stores/sessionIdentity.ts +43 -0
  335. package/src/itinerary/stores/suggestSession.ts +418 -0
  336. package/src/layers/contracts/itinerary.ts +46 -0
  337. package/src/layers/contracts/overlay.ts +132 -0
  338. package/src/layers/handlers/enrichment.ts +36 -0
  339. package/src/layers/handlers/overlay.ts +406 -0
  340. package/src/layers/handlers/restLayers.ts +94 -0
  341. package/src/layers/handlers/tiles.ts +25 -0
  342. package/src/layers/rules/layers.ts +212 -0
  343. package/src/layers/rules/overlayInstant.ts +12 -0
  344. package/src/layers/rules/reachabilityIcon.ts +18 -0
  345. package/src/layers/rules/readout.ts +102 -0
  346. package/src/layers/stores/layers.ts +262 -0
  347. package/src/map/contracts/contextmenu.ts +33 -0
  348. package/src/map/contracts/geolocate.ts +37 -0
  349. package/src/map/contracts/map.ts +146 -0
  350. package/src/map/contracts/streetview.ts +53 -0
  351. package/src/map/contracts/terrain.ts +152 -0
  352. package/src/map/handlers/contextMenu.ts +135 -0
  353. package/src/map/handlers/geolocate.ts +52 -0
  354. package/src/map/handlers/map.ts +391 -0
  355. package/src/map/handlers/streetview.ts +94 -0
  356. package/src/map/handlers/terrain.ts +663 -0
  357. package/src/map/rules/baseTerrain.ts +75 -0
  358. package/src/map/rules/clickTargets.ts +464 -0
  359. package/src/map/rules/constraints.ts +32 -0
  360. package/src/map/rules/contextMenuReadout.ts +67 -0
  361. package/src/map/rules/coordinates.ts +71 -0
  362. package/src/map/rules/itineraryFit.ts +8 -0
  363. package/src/map/rules/mapEvents.ts +64 -0
  364. package/src/map/rules/mapProjection.ts +476 -0
  365. package/src/map/rules/terrainReading.ts +62 -0
  366. package/src/plugins/contracts/ids.ts +66 -0
  367. package/src/plugins/contracts/plugin.ts +200 -0
  368. package/src/plugins/contracts/slots.ts +137 -0
  369. package/src/plugins/engines/studioPlugin.ts +1365 -0
  370. package/src/plugins/index.ts +111 -0
  371. package/src/plugins/rules/contributions.ts +152 -0
  372. package/src/plugins/rules/errors.ts +60 -0
  373. package/src/plugins/rules/ids.ts +42 -0
  374. package/src/plugins/rules/validation.ts +249 -0
  375. package/src/rules/listeners.ts +57 -0
  376. package/src/rules/origin.ts +13 -0
  377. package/src/rules/storeWrite.ts +37 -0
  378. package/src/rules/types.ts +136 -0
  379. package/src/seams/index.ts +79 -0
  380. package/src/seams/rules/clock.ts +28 -0
  381. package/src/seams/rules/formatters.ts +209 -0
  382. package/src/seams/rules/ids.ts +102 -0
  383. package/src/seams/rules/links.ts +66 -0
  384. package/src/seams/rules/navigation.ts +222 -0
  385. package/src/seams/rules/notify.ts +49 -0
  386. package/src/seams/rules/persistenceDrawer.ts +220 -0
  387. package/src/seams/rules/saveFile.ts +101 -0
  388. package/src/seams/rules/seams.ts +156 -0
  389. package/src/seams/rules/storage.ts +116 -0
  390. package/src/search/contracts/overlay.ts +74 -0
  391. package/src/search/contracts/search.ts +197 -0
  392. package/src/search/handlers/pois.ts +57 -0
  393. package/src/search/handlers/search.ts +280 -0
  394. package/src/search/rules/params.ts +925 -0
  395. package/src/search/rules/poiGroups.ts +138 -0
  396. package/src/search/rules/searchFetch.ts +139 -0
  397. package/src/search/rules/timeWindow.ts +30 -0
  398. package/src/search/stores/search.ts +51 -0
  399. package/src/segments/contracts/itinerary.ts +433 -0
  400. package/src/segments/contracts/segment.ts +35 -0
  401. package/src/segments/engines/segmentDraft.ts +926 -0
  402. package/src/segments/handlers/chainGuards.ts +67 -0
  403. package/src/segments/handlers/directions.ts +44 -0
  404. package/src/segments/handlers/itineraryEcho.ts +45 -0
  405. package/src/segments/handlers/roadAccessDialog.ts +34 -0
  406. package/src/segments/handlers/segment.ts +111 -0
  407. package/src/segments/handlers/segmentEdit.ts +1341 -0
  408. package/src/segments/handlers/segmentGroups.ts +347 -0
  409. package/src/segments/handlers/segmentStructure.ts +1144 -0
  410. package/src/segments/rules/chain.ts +196 -0
  411. package/src/segments/rules/chainModel.ts +217 -0
  412. package/src/segments/rules/colors.ts +11 -0
  413. package/src/segments/rules/commit.ts +76 -0
  414. package/src/segments/rules/draft.ts +90 -0
  415. package/src/segments/rules/draftDisposition.ts +43 -0
  416. package/src/segments/rules/draftSegmentEdit.ts +129 -0
  417. package/src/segments/rules/engine.ts +222 -0
  418. package/src/segments/rules/groupSave.ts +234 -0
  419. package/src/segments/rules/hazardPrompt.ts +60 -0
  420. package/src/segments/rules/itineraryEcho.ts +40 -0
  421. package/src/segments/rules/liveSegmentProjection.ts +55 -0
  422. package/src/segments/rules/merge.ts +51 -0
  423. package/src/segments/rules/metrics.ts +456 -0
  424. package/src/segments/rules/naming.ts +168 -0
  425. package/src/segments/rules/segmentArming.ts +144 -0
  426. package/src/segments/rules/splitPick.ts +84 -0
  427. package/src/segments/rules/viaSimplify.ts +230 -0
  428. package/src/segments/stores/directions.ts +77 -0
  429. package/src/segments/stores/roadAccessDialog.ts +58 -0
  430. package/src/segments/stores/segmentEdit.ts +922 -0
  431. package/src/segments/stores/segmentGroupEdit.ts +84 -0
  432. package/src/segments/stores/segmentSplit.ts +77 -0
  433. package/src/share/contracts/share.ts +39 -0
  434. package/src/share/contracts/shareLink.ts +63 -0
  435. package/src/share/engines/shareLink.ts +1053 -0
  436. package/src/share/handlers/share.ts +47 -0
  437. package/src/share/handlers/shareLink.ts +231 -0
  438. package/src/share/handlers/shareScope.ts +54 -0
  439. package/src/share/rules/link.ts +89 -0
  440. package/src/share/rules/shareLink.ts +218 -0
  441. package/src/share/rules/targets.ts +92 -0
  442. package/src/share/rules/viewConfig.ts +95 -0
  443. package/src/share/stores/share.ts +58 -0
  444. package/src/strings/fr/index.ts +18 -0
  445. package/src/strings/fr/rules/fr.ts +2368 -0
  446. package/src/strings/index.ts +98 -0
  447. package/src/strings/rules/confirmCopy.ts +156 -0
  448. package/src/strings/rules/draftToolNames.ts +94 -0
  449. package/src/strings/rules/en.ts +2519 -0
  450. package/src/strings/rules/failureAlert.ts +115 -0
  451. package/src/strings/rules/formError.ts +400 -0
  452. package/src/strings/rules/maneuvers.ts +107 -0
  453. package/src/strings/rules/outputOptions.ts +126 -0
  454. package/src/strings/rules/publicationState.ts +100 -0
  455. package/src/strings/rules/routeHazardCopy.ts +62 -0
  456. package/src/strings/rules/searchLabels.ts +50 -0
  457. package/src/strings/rules/segmentChainVerbs.ts +62 -0
  458. package/src/strings/rules/studioCopy.ts +130 -0
  459. package/src/strings/rules/unitOptions.ts +119 -0
  460. package/src/testing/checkedBus.ts +226 -0
  461. package/src/testing/index.ts +34 -0
  462. package/src/testing/plugins.ts +106 -0
  463. package/src/testing/studio.ts +267 -0
  464. package/src/testing/urlSeam.ts +153 -0
  465. package/src/time/index.ts +12 -0
  466. package/src/time/rules/sun.ts +78 -0
  467. package/src/video/contracts/cameraSchemas.ts +266 -0
  468. package/src/video/contracts/profileSchemas.ts +37 -0
  469. package/src/video/contracts/video.ts +601 -0
  470. package/src/video/handlers/video.ts +1638 -0
  471. package/src/video/handlers/videoDirector.ts +114 -0
  472. package/src/video/rules/previewRefresh.ts +76 -0
  473. package/src/video/rules/profileSource.ts +51 -0
  474. package/src/video/rules/routeSpans.ts +79 -0
  475. package/src/video/rules/shotDefaults.ts +28 -0
  476. package/src/video/rules/stepOrder.ts +17 -0
  477. package/src/video/rules/videoSnapshot.ts +136 -0
  478. package/src/video/stores/directorThreads.ts +167 -0
  479. package/src/video/stores/videoExport.ts +290 -0
  480. package/src/viewer/contracts/preferences.ts +40 -0
  481. package/src/viewer/handlers/preferences.ts +91 -0
  482. package/src/viewer/rules/capabilities.ts +42 -0
  483. package/src/viewer/rules/config.ts +266 -0
  484. package/src/viewer/rules/context.ts +375 -0
  485. package/src/viewer/rules/ownership.ts +134 -0
  486. package/src/viewer/rules/platformViewer.ts +198 -0
  487. package/src/viewer/rules/scope.ts +197 -0
  488. package/src/viewer/rules/url.ts +145 -0
  489. package/src/viewer/rules/viewer.ts +307 -0
  490. package/src/viewer/rules/viewerSeam.ts +49 -0
  491. package/src/viewer/rules/viewerUnits.ts +34 -0
  492. package/src/waypoints/contracts/itinerary.ts +417 -0
  493. package/src/waypoints/handlers/poiWaypointStyle.ts +32 -0
  494. package/src/waypoints/handlers/waypointDetailsDialog.ts +38 -0
  495. package/src/waypoints/handlers/waypointEdit.ts +1073 -0
  496. package/src/waypoints/rules/amenities.ts +30 -0
  497. package/src/waypoints/rules/defaults.ts +31 -0
  498. package/src/waypoints/rules/details.ts +213 -0
  499. package/src/waypoints/rules/detailsDraft.ts +312 -0
  500. package/src/waypoints/rules/detailsPreview.ts +76 -0
  501. package/src/waypoints/rules/detailsSave.ts +356 -0
  502. package/src/waypoints/rules/draftDirty.ts +45 -0
  503. package/src/waypoints/rules/icons.ts +32 -0
  504. package/src/waypoints/rules/liveWaypoint.ts +63 -0
  505. package/src/waypoints/rules/naming.ts +185 -0
  506. package/src/waypoints/rules/sections.ts +77 -0
  507. package/src/waypoints/rules/waypointDraft.ts +62 -0
  508. package/src/waypoints/stores/waypointDetails.ts +62 -0
  509. package/src/waypoints/stores/waypointEdit.ts +566 -0
  510. package/src/zones/contracts/collection.ts +37 -0
  511. package/src/zones/contracts/zone.ts +528 -0
  512. package/src/zones/engines/zoneForm.ts +1773 -0
  513. package/src/zones/handlers/restZones.ts +287 -0
  514. package/src/zones/handlers/zonePublish.ts +206 -0
  515. package/src/zones/handlers/zoneUnpublish.ts +56 -0
  516. package/src/zones/handlers/zones.ts +2254 -0
  517. package/src/zones/rules/geometry.ts +946 -0
  518. package/src/zones/rules/zoneDefaults.ts +34 -0
  519. package/src/zones/rules/zoneDraft.ts +54 -0
  520. package/src/zones/rules/zoneForm.ts +563 -0
  521. package/src/zones/rules/zoneMetadata.ts +29 -0
  522. package/src/zones/rules/zoneSource.ts +87 -0
  523. package/src/zones/rules/zoneSourceRefusal.ts +104 -0
  524. package/src/zones/stores/zoneEdit.ts +998 -0
package/dist/index.js ADDED
@@ -0,0 +1,3223 @@
1
+ export { buildVideoSnapshot, createVideoDirectorStore, selectDirecting, videoSnapshotSchema } from './chunk-WZYXG3SE.js';
2
+ import { draftChangeDisposition } from './chunk-CNPZY7N3.js';
3
+ export { EMBED_COVER_MAX_MS, buildReadyPayload, buildSegmentEditOptions, draftChangeDisposition, embedConstraintsFor, profileCursorReadout, profileMarkerIcon, resolveFramedError, routeHazardConfirmation } from './chunk-CNPZY7N3.js';
4
+ export { layerToolContext } from './chunk-RFUPPVZO.js';
5
+ import { fetchItineraryRecord, allowlistUnrestricted, allowlistMode, clampConfigToSafetyRules, showingDraftSurface, hasUuidShape, POIS_OVERLAY_SLUG, exceedsMergeViaCeiling, declaredBody, withItineraryAnalysis, rethrowSegmentWriteError, withSegmentAnalysis, reconcileMadeWrite, ALLOWLIST_WILDCARD, lngLatOf, createdIdOf, SegmentDeleteNotEdgeError } from './chunk-H4DVOZ5O.js';
6
+ export { HILLSHADE_OVERLAY_SLUG, POIS_OVERLAY_SLUG, ToolBus, allowlistForMode, allowlistMode, allowlistUnrestricted, clampConfigToSafetyRules, classicOverlays, collectAttributions, confirmationToneSchema, contiguousRunBounds, createUiStore, describeInvalidInput, directionsTargetSchema, embedUiBaseline, enrichmentOverlays, exceedsMergeViaCeiling, filterEnrichmentOverlays, filterOverlayCategories, filterTerrains, findHillshadeOverlay, isContiguousRun, isFieldRestricted, isZoneWorkUnsaved, makeWaypointId, registerStudioTools, resolveViewerUnits, selectActiveDraft, selectActiveDraftSession, selectAgentHandoffArmed, selectBaseMapLocked, selectDirections, selectEditDirtyTick, selectEditorTakenBy, selectEmbed, selectEmbedContent, selectImportSession, selectProfilePaceKmh, selectProfileSheetSnap, selectSegmentViaPrompt, selectSelectedSuggestionCandidate, selectShare, selectUnsavedWork, selectVideoExport, selectVideoExportPlan, selectVideoExportRoute, selectVideoExportStatus, selectWaypointDetails, selectZoneCreateSetup, selectZoneEditDirty, splitPickVerdict, studioRegistry, toggleableSegmentIds, toolCapabilitySchema, toolConfirmationSchema, toolErrorCodeSchema, withItineraryAnalysis } from './chunk-H4DVOZ5O.js';
7
+ import { embedSearchSchema, POI_GROUPS, terrainVariantSchema, DEFAULT_TERRAIN, resolveEmbedConfig, languageSchema, themeSchema, unitLengthSchema, unitPaceSchema, unitSlopeSchema, unitTemperatureSchema, defaultSegmentName, draftToView, suggestionCandidateToView, collabResourceKey, collabLockKey, collabPeerColor, hexColorSchema, createStaticViewer, userWaypointIconSchema, itineraryWaypointsToolContracts, synthesizeDraftWaypoint, wrapZoneGeometryPastRange, chosenCandidate, waypointPropertyValueMatchesFormat, isWaypointPhone, isWaypointEmail, isWaypointWebUrl, isWaypointPropertyKey, segmentLengthMeters } from './chunk-2HFY7ETU.js';
8
+ export { AGENT_PANEL_SEARCH_KEYS, COLLAB_PEER_COLORS, DEFAULT_ENABLED_POI_GROUP_IDS, DEFAULT_TERRAIN, DUPLICATE_SEGMENT_IDS_MAX, DUPLICATE_WAYPOINT_IDS_MAX, EXPORT_FORMATS, EXPORT_VARIANTS, MAP_STATE_SEARCH_KEYS, POI_GROUPS, POI_GROUP_COUNT, POI_GROUP_IDS, SPLIT_MIN_END_DISTANCE_METERS, SPLIT_PICK_TOLERANCE_PX, SUGGESTION_MAX_KEPT, SUGGESTION_TARGET_COUNT, TIME_OFFSET_MAX_MINUTES, TIME_OFFSET_MIN_MINUTES, TIME_WINDOW_FUTURE_HOURS, TIME_WINDOW_PAST_HOURS, agentHandoffTarget, buildExportFilename, cameraBearingModeSchema, cameraFpsSchema, cameraModeSchema, cameraOutputBaseSchema, cameraOutputFormatSchema, cameraOutputSchema, cameraPlanSchema, cameraResolutionSchema, cameraShotBaseSchema, cameraShotSchema, climbCategorySchema, collabLockEntrySchema, collabLockKey, collabLockKindSchema, collabPeerColor, collabPeerColorIndex, collabPresencePeerSchema, collabResourceKey, collabResourceKindSchema, collabResourceSchema, collectionsTargetSchema, contextMenuSchema, contextMenuZoneSchema, createMemoryViewer, createStaticViewer, defaultSegmentGroupName, defaultSegmentName, defaultVideoExportProfile, destinationPoint, editingCollectionSchema, embedAuthSearchSchema, embedConfigSchema, embedConfigSearchSchema, embedSearchSchema, embedThemeSchema, exportExtension, exportFileStem, exportFormatVariants, exportTargetSchema, featureHitSchema, hexColorSchema, importReasonSentence, importWarningSentence, isDefaultSegmentName, isWaypointEmail, isWaypointPhone, isWaypointPropertyKey, isWaypointWebUrl, languageSchema, mapAlertSchema, mapStateShape, overlayFeatureSchema, overlaySampleResultSchema, peerSegmentDraftsOf, poiGroupIdSchema, poiGroupSchema, poiInfoSchema, pointAtFraction, profileDesignSchema, profileSheetSnapSchema, profileSourceSchema, projectOnSegment, qualitySchema, renumberDefaultSegments, resolveEmbedConfig, routeGeometrySchema, routeProfilePointSchema, segmentGroupEditTargetSchema, segmentLengthMeters, segmentSpanSchema, segmentSplitPickSchema, segmentsColorSchema, selectActiveEditEngine, selectAgentEntityLocked, selectCollabLockHolder, selectCollabLockHolderIds, selectCollabPeerDrafts, selectCollabPeers, selectSegmentGroupEdit, selectSegmentSplitPick, selectSuggestionSession, selectedCandidate, shareSearchSchema, splitSegmentNames, streetviewPositionSchema, studioAlertCodeSchema, studioContentSchema, studioEntitlementSchema, studioMapStateSearchSchema, studioModalSchema, studioPanelSchema, studioToolContracts, suggestRouteTypeSchema, synthesizeDraftWaypoint, terrainVariantSchema, themeSchema, timeSliderWindow, unitLengthSchema, unitPaceSchema, unitSlopeSchema, unitTemperatureSchema, urlBoolean, userWaypointIconSchema, videoExportProfileSchema, videoExportSchema, videoExportStatusSchema, videoPresetSchema, waypointAmenitySchema, waypointDetailLimits, waypointDraftSchema, waypointEditIntentSchema, waypointEditModeSchema, waypointIconSchema, waypointPoiSeedSchema, waypointPropertyFormatSchema, waypointPropertyValueMatchesFormat, wrapZoneGeometryPastRange, zoneCircleGeometry, zoneCircleParamsSchema, zoneCreateMethodSchema, zoneEditBeginSchema, zoneEditLevelSchema, zoneEditModeSchema, zonePreviewQueryKey, zoneReachPole, zoneSectorGeometry, zoneSectorParamsSchema, zoneSensorGeometry, zoneSensorParamsSchema } from './chunk-2HFY7ETU.js';
9
+ import { defaultEngineForActivity, canEditOwnedResource, clampSeedPoint, simplifyToVias, seedFromCoordinates } from './chunk-UU65VNEV.js';
10
+ export { ITINERARY_FIT_MAX_ZOOM, ZONE_PREVIEW_DEBOUNCE_MS, activityForId, availableEnginesForActivity, canEditItinerary, canEditOwnedResource, clampSeedPoint, defaultEngineForActivity, defaultSpeedForActivity, firstActivityId, isRetryableShareLinkFailure, isShareLinkDisableSettled, isZoneMetadataDirty, seedFromCoordinates, seedFromPersistedSegment, shareLinkActions, shareLinkScope, simplifyToVias, zoneAutoName, zoneSaveRequest } from './chunk-UU65VNEV.js';
11
+ import { displayNameSchema, descriptionSchema, originBase, defaultStudioScope, REQUEST_SESSION_TOKEN_MESSAGE, SET_SESSION_TOKEN_MESSAGE } from './chunk-F73W2ZTJ.js';
12
+ export { CAMERA_MESSAGE, DEFAULT_ZONE_CREATE_METHOD, DEFAULT_ZONE_LEVEL, DEFAULT_ZONE_MODE, DESCRIPTION_MAX_LENGTH, DISPLAY_NAME_MAX_LENGTH, DISPLAY_NAME_MIN_LENGTH, READY_MESSAGE, REQUEST_CAMERA_MESSAGE, REQUEST_SESSION_TOKEN_MESSAGE, SET_ITINERARY_MESSAGE, SET_SESSION_TOKEN_MESSAGE, activeStudioScope, buildShareSearch, buildShareSrc, cameraMessageSchema, defaultStudioScope, descriptionSchema, displayNameSchema, draftActivityInput, draftCollectionsInput, draftNameInput, draftOrganizationInput, draftPositionCount, draftPrivateInput, fitDisplayName, inboundBridgeMessageSchema, isPublishableScope, mapBoundsSchema, readyErrorSchema, readyMessageSchema, renumber, requestCameraMessageSchema, requestSessionTokenMessageSchema, requireWritableScope, resolveActivity, segmentEditModeSchema, segmentInsertAnchorSchema, setSessionTokenMessageSchema, shareLinkTargetSchema, substituteLiveSegment, switchOverridesSchema, synthesizeDraftSegment, toolNoDataSchema, zoneDescriptionSchema, zoneNameSchema } from './chunk-F73W2ZTJ.js';
13
+ import { localPersistenceDrawer, memoryPersistenceDrawer } from './chunk-355TOXSB.js';
14
+ import { studioSeamAbsences } from './chunk-VGX6TR2I.js';
15
+ export { isConfirmationWithheld } from './chunk-O4MC5DPD.js';
16
+ export { codeForThrown, failureFromThrown, restStatusCodes } from './chunk-WUTDDBVP.js';
17
+ import * as z4 from 'zod';
18
+ import { MountayaElementsError, MountayaElementsNotFoundError } from '@mountaya/elements/errors';
19
+ import { DIRECTIONS_VIA_MAX, DIRECTIONS_VIA_COUNTER_THRESHOLD, SEGMENT_MIN_VIAS, extractLines, pointTuple, boundsTuple, extractPoint, extractVias, segmentLineCoordinates, buildGeometryCollection } from '@mountaya/elements/geo';
20
+ import { DEFAULT_WAYPOINT_TABLE_COLUMNS, DEFAULT_SEGMENT_TABLE_COLUMNS, formatDistance, formatTemperature, formatSnowfall, formatSnowDepth, formatHumidity, formatSpeed, buildInfoBands, buildElevationPoints, resolveSpeedKmh, durationForSpeed } from '@mountaya/elements/profile';
21
+ import { MAP_LANGUAGES, languageEndonym } from '@mountaya/elements/i18n';
22
+ import { pickLivelyColor, DEFAULT_SEGMENT_COLOR } from '@mountaya/elements/style';
23
+ import { convertDataSize, convertDuration, convertSpeed, SECONDS_PER_MINUTE } from '@mountaya/elements/units';
24
+ import { ITINERARY_ENDPOINT_ICONS, ITINERARY_LINE_SOURCE_LAYER, ITINERARY_POINT_SOURCE_LAYER, roadAccessIconLayerIdOf, ITINERARY_RESTRICTION_SOURCE_LAYER, findOverlay, zoneLevelColors } from '@mountaya/elements/layers';
25
+ export { overlayInstant, timestampedSources } from '@mountaya/elements/layers';
26
+ import { DEFAULT_WAYPOINT_COLOR, DEFAULT_WAYPOINT_ICON } from '@mountaya/elements/icons';
27
+ import { SEGMENT_GROUP_MIN_MEMBERS, segmentsForSelection, ROAD_ACCESS_KINDS } from '@mountaya/elements/data';
28
+ import { peerDraftInitials } from '@mountaya/elements/collab';
29
+ import { representativeStillFraction } from '@mountaya/elements/camera';
30
+
31
+ // src/bus/rules/defineRegistry.ts
32
+ var defineRegistry = (registry) => registry;
33
+
34
+ // src/bus/rules/lateBoundTools.ts
35
+ var lateBoundTool = (read) => ({
36
+ get agentHidden() {
37
+ return read().agentHidden;
38
+ },
39
+ get capability() {
40
+ return read().capability;
41
+ },
42
+ get confirmation() {
43
+ return read().confirmation;
44
+ },
45
+ get confirmationValues() {
46
+ return read().confirmationValues;
47
+ },
48
+ get description() {
49
+ return read().description;
50
+ },
51
+ get handler() {
52
+ return read().handler;
53
+ },
54
+ get input() {
55
+ return read().input;
56
+ },
57
+ get name() {
58
+ return read().name;
59
+ },
60
+ get output() {
61
+ return read().output;
62
+ },
63
+ get precondition() {
64
+ return read().precondition;
65
+ },
66
+ get requiresConfirmation() {
67
+ return read().requiresConfirmation;
68
+ }
69
+ });
70
+ var lateBoundTools = (names, tools) => {
71
+ const bound = {};
72
+ for (const name of names) {
73
+ const record = tools();
74
+ const initial = Object.hasOwn(record, name) ? record[name] : void 0;
75
+ if (initial === void 0) {
76
+ continue;
77
+ }
78
+ let held = initial;
79
+ bound[name] = lateBoundTool(() => {
80
+ const current = tools();
81
+ held = (Object.hasOwn(current, name) ? current[name] : void 0) ?? held;
82
+ return held;
83
+ });
84
+ }
85
+ return bound;
86
+ };
87
+
88
+ // src/collab/rules/toolNames.ts
89
+ var studioCollabTools = {
90
+ changeApply: "studio.collab.change.apply",
91
+ listApply: "studio.collab.list.apply",
92
+ lockClear: "studio.collab.lock.clear",
93
+ lockSet: "studio.collab.lock.set",
94
+ lockSnapshot: "studio.collab.lock.snapshot",
95
+ peerDraftClear: "studio.collab.peerDraft.clear",
96
+ peerDraftSet: "studio.collab.peerDraft.set",
97
+ peerSelectionSet: "studio.collab.peerSelection.set",
98
+ presenceClear: "studio.collab.presence.clear",
99
+ presenceSet: "studio.collab.presence.set",
100
+ presenceSnapshot: "studio.collab.presence.snapshot"
101
+ };
102
+ var collectionContentRoles = /* @__PURE__ */ new Set(["owner", "admin", "contributor"]);
103
+ var collectionMetadataRoles = /* @__PURE__ */ new Set(["owner", "admin"]);
104
+ var canEditCollection = (role) => collectionContentRoles.has(role);
105
+ var canEditCollectionMetadata = (role, isAuthor) => collectionMetadataRoles.has(role) || isAuthor && collectionContentRoles.has(role);
106
+ var canDeleteCollection = canEditCollectionMetadata;
107
+ var collectionFormSchema = z4.object({
108
+ description: descriptionSchema,
109
+ isPrivate: z4.boolean(),
110
+ name: displayNameSchema
111
+ });
112
+ var collectionCreateScope = (organizationId, isPersonalScope) => isPersonalScope(organizationId) ? void 0 : organizationId ?? void 0;
113
+
114
+ // src/collections/rules/entityCollections.ts
115
+ var projectEntityCollections = (collections, holding) => {
116
+ const held = new Set(holding.map(({ id }) => id));
117
+ const rows = /* @__PURE__ */ new Map();
118
+ for (const collection of [...collections, ...holding]) {
119
+ if (!rows.has(collection.id)) {
120
+ rows.set(collection.id, {
121
+ has: held.has(collection.id),
122
+ id: collection.id,
123
+ name: collection.name,
124
+ role: collection.role
125
+ });
126
+ }
127
+ }
128
+ return [...rows.values()];
129
+ };
130
+
131
+ // src/data/rules/keys.ts
132
+ var KEY_PREFIX_LENGTH = 7;
133
+ var KEY_SUFFIX_LENGTH = 4;
134
+ var truncateKey = (key) => key.length <= KEY_PREFIX_LENGTH + KEY_SUFFIX_LENGTH + 1 ? key : `${key.slice(0, KEY_PREFIX_LENGTH)}\u2026${key.slice(-KEY_SUFFIX_LENGTH)}`;
135
+ var itineraryUpdateFields = {
136
+ description: true,
137
+ is_private: true,
138
+ name: true
139
+ };
140
+ var itineraryCreateFields = {
141
+ activity_id: true,
142
+ description: true,
143
+ is_private: true,
144
+ name: true,
145
+ organization_id: true
146
+ };
147
+ var segmentCreateFields = {
148
+ before_segment_id: true,
149
+ color: true,
150
+ description: true,
151
+ geojson: true,
152
+ mode: true,
153
+ name: true,
154
+ speed: true,
155
+ start_at: true
156
+ };
157
+ var segmentUpdateFields = {
158
+ color: true,
159
+ description: true,
160
+ geojson: true,
161
+ name: true,
162
+ speed: true,
163
+ start_at: true
164
+ };
165
+ var segmentSplitFields = {
166
+ first_name: true,
167
+ fraction: true,
168
+ second_name: true
169
+ };
170
+ var segmentConvertFields = { mode: true };
171
+ var segmentGroupCreateFields = {
172
+ color: true,
173
+ name: true,
174
+ segment_ids: true,
175
+ speed: true
176
+ };
177
+ var segmentGroupUpdateFields = {
178
+ color: true,
179
+ name: true,
180
+ segment_ids: true,
181
+ speed: true
182
+ };
183
+ var itineraryDuplicateFields = {
184
+ name: true,
185
+ organization_id: true,
186
+ segment_ids: true,
187
+ waypoint_ids: true
188
+ };
189
+ var waypointCreateFields = {
190
+ amenities: true,
191
+ color: true,
192
+ contact: true,
193
+ description: true,
194
+ geojson: true,
195
+ icon: true,
196
+ media: true,
197
+ mode: true,
198
+ name: true,
199
+ position: true,
200
+ properties: true,
201
+ timing: true
202
+ };
203
+ var waypointUpdateFields = {
204
+ amenities: true,
205
+ color: true,
206
+ contact: true,
207
+ description: true,
208
+ geojson: true,
209
+ icon: true,
210
+ media: true,
211
+ name: true,
212
+ position: true,
213
+ properties: true,
214
+ timing: true
215
+ };
216
+ var partOf = (parts, id, operation) => {
217
+ const part = parts.find((candidate) => candidate.id === id);
218
+ if (part === void 0) {
219
+ throw new MountayaElementsError(
220
+ `${operation}: the write landed, and the itinerary it answered holds no part ${String(id)}. Read the itinerary again to see it.`
221
+ );
222
+ }
223
+ return part;
224
+ };
225
+ var updateItinerary = async (client, itineraryId, params) => {
226
+ const body = await client.studio.itineraries.patchItinerary({
227
+ body: declaredBody(params, itineraryUpdateFields),
228
+ itinerary_id: itineraryId
229
+ });
230
+ return withItineraryAnalysis(body.data);
231
+ };
232
+ var updateSegment = async (client, itineraryId, segmentId, params) => {
233
+ try {
234
+ const body = await client.studio.itineraries.patchItinerarySegment({
235
+ body: declaredBody(params, segmentUpdateFields),
236
+ itinerary_id: itineraryId,
237
+ segment_id: segmentId
238
+ });
239
+ return withSegmentAnalysis(partOf(body.data.segments, segmentId, "update segment"));
240
+ } catch (error) {
241
+ return rethrowSegmentWriteError(error);
242
+ }
243
+ };
244
+ var deleteItinerary = async (client, itineraryId) => {
245
+ await client.studio.itineraries.deleteItinerary({
246
+ itinerary_id: itineraryId
247
+ });
248
+ };
249
+ var readMadeItinerary = async (client, location) => {
250
+ const itineraryId = createdIdOf({ location });
251
+ if (itineraryId === void 0) {
252
+ return null;
253
+ }
254
+ try {
255
+ return await fetchItineraryRecord(client, itineraryId);
256
+ } catch {
257
+ return null;
258
+ }
259
+ };
260
+ var createItinerary = async (client, params) => reconcileMadeWrite(
261
+ async () => {
262
+ const body = await client.studio.itineraries.postItinerary({
263
+ body: declaredBody(params, itineraryCreateFields)
264
+ });
265
+ return withItineraryAnalysis(body.data);
266
+ },
267
+ (answer) => readMadeItinerary(client, answer.location)
268
+ );
269
+ var createSegment = async (client, itineraryId, params) => {
270
+ try {
271
+ const body = await client.studio.itineraries.postItinerarySegment({
272
+ body: declaredBody(params, segmentCreateFields),
273
+ itinerary_id: itineraryId
274
+ });
275
+ return withSegmentAnalysis(
276
+ partOf(body.data.segments, body.extensions.metadata.created.id, "create segment")
277
+ );
278
+ } catch (error) {
279
+ return rethrowSegmentWriteError(error);
280
+ }
281
+ };
282
+ var deleteSegment = async (client, itineraryId, segmentId) => {
283
+ try {
284
+ await client.studio.itineraries.deleteItinerarySegment({
285
+ itinerary_id: itineraryId,
286
+ segment_id: segmentId
287
+ });
288
+ } catch (error) {
289
+ return rethrowSegmentWriteError(error, "delete");
290
+ }
291
+ };
292
+ var mergeSegment = async (client, itineraryId, segmentId) => {
293
+ try {
294
+ const body = await client.studio.itineraries.postItinerarySegmentMerge({
295
+ itinerary_id: itineraryId,
296
+ segment_id: segmentId
297
+ });
298
+ return withItineraryAnalysis(body.data);
299
+ } catch (error) {
300
+ return rethrowSegmentWriteError(error);
301
+ }
302
+ };
303
+ var splitSegment = async (client, itineraryId, segmentId, params) => {
304
+ try {
305
+ const body = await client.studio.itineraries.postItinerarySegmentSplit({
306
+ body: declaredBody(params, segmentSplitFields),
307
+ itinerary_id: itineraryId,
308
+ segment_id: segmentId
309
+ });
310
+ return withItineraryAnalysis(body.data);
311
+ } catch (error) {
312
+ return rethrowSegmentWriteError(error);
313
+ }
314
+ };
315
+ var convertSegment = async (client, itineraryId, segmentId, params) => {
316
+ try {
317
+ const body = await client.studio.itineraries.postItinerarySegmentConvert({
318
+ body: declaredBody(params, segmentConvertFields),
319
+ itinerary_id: itineraryId,
320
+ segment_id: segmentId
321
+ });
322
+ return withItineraryAnalysis(body.data);
323
+ } catch (error) {
324
+ return rethrowSegmentWriteError(error);
325
+ }
326
+ };
327
+ var createSegmentGroup = async (client, itineraryId, params) => {
328
+ try {
329
+ const body = await client.studio.itineraries.postItinerarySegmentGroup({
330
+ body: declaredBody(params, segmentGroupCreateFields),
331
+ itinerary_id: itineraryId
332
+ });
333
+ return withItineraryAnalysis(body.data);
334
+ } catch (error) {
335
+ return rethrowSegmentWriteError(error);
336
+ }
337
+ };
338
+ var updateSegmentGroup = async (client, itineraryId, groupId, params) => {
339
+ try {
340
+ const body = await client.studio.itineraries.patchItinerarySegmentGroup({
341
+ body: declaredBody(params, segmentGroupUpdateFields),
342
+ group_id: groupId,
343
+ itinerary_id: itineraryId
344
+ });
345
+ return withItineraryAnalysis(body.data);
346
+ } catch (error) {
347
+ return rethrowSegmentWriteError(error);
348
+ }
349
+ };
350
+ var deleteSegmentGroup = async (client, itineraryId, groupId) => {
351
+ try {
352
+ const body = await client.studio.itineraries.deleteItinerarySegmentGroup({
353
+ group_id: groupId,
354
+ itinerary_id: itineraryId
355
+ });
356
+ return withItineraryAnalysis(body.data);
357
+ } catch (error) {
358
+ return rethrowSegmentWriteError(error);
359
+ }
360
+ };
361
+ var duplicateItinerary = async (client, itineraryId, params) => reconcileMadeWrite(
362
+ async () => {
363
+ const body = await client.studio.itineraries.postItineraryDuplicate({
364
+ body: declaredBody(params, itineraryDuplicateFields),
365
+ itinerary_id: itineraryId
366
+ });
367
+ return withItineraryAnalysis(body.data);
368
+ },
369
+ (answer) => readMadeItinerary(client, answer.location)
370
+ );
371
+ var publishItinerary = async (client, itineraryId) => reconcileMadeWrite(
372
+ async () => {
373
+ try {
374
+ const body = await client.studio.itineraries.postItineraryPublication({
375
+ itinerary_id: itineraryId
376
+ });
377
+ return withItineraryAnalysis(body.data);
378
+ } catch (error) {
379
+ return rethrowSegmentWriteError(error);
380
+ }
381
+ },
382
+ () => fetchItineraryRecord(client, itineraryId)
383
+ );
384
+ var unpublishItinerary = async (client, itineraryId) => reconcileMadeWrite(
385
+ async () => {
386
+ const body = await client.studio.itineraries.deleteItineraryPublication({
387
+ itinerary_id: itineraryId
388
+ });
389
+ return withItineraryAnalysis(body.data);
390
+ },
391
+ () => fetchItineraryRecord(client, itineraryId)
392
+ );
393
+ var createWaypoint = async (client, itineraryId, params) => {
394
+ const body = await client.studio.itineraries.postItineraryWaypoint({
395
+ body: declaredBody(params, waypointCreateFields),
396
+ itinerary_id: itineraryId
397
+ });
398
+ return partOf(body.data.waypoints, body.extensions.metadata.created.id, "create waypoint");
399
+ };
400
+ var updateWaypoint = async (client, itineraryId, waypointId, params) => {
401
+ const body = await client.studio.itineraries.patchItineraryWaypoint({
402
+ body: declaredBody(params, waypointUpdateFields),
403
+ itinerary_id: itineraryId,
404
+ waypoint_id: waypointId
405
+ });
406
+ return partOf(body.data.waypoints, waypointId, "update waypoint");
407
+ };
408
+ var deleteWaypoint = async (client, itineraryId, waypointId) => {
409
+ await client.studio.itineraries.deleteItineraryWaypoint({
410
+ itinerary_id: itineraryId,
411
+ waypoint_id: waypointId
412
+ });
413
+ };
414
+ var shareLinkSchema = z4.object({
415
+ created_at: z4.date(),
416
+ share_token: z4.string().min(1)
417
+ });
418
+ var shareLinkResponseSchema = z4.object({ data: shareLinkSchema });
419
+ var shareLinkReadSchema = z4.object({ data: shareLinkSchema.nullable() });
420
+ var mintItineraryShareLink = async (client, itineraryId) => {
421
+ const envelope = await client.studio.itineraries.postItineraryShareLink({
422
+ itinerary_id: itineraryId
423
+ });
424
+ return shareLinkResponseSchema.parse(envelope).data;
425
+ };
426
+ var rotateItineraryShareLink = async (client, itineraryId) => {
427
+ const envelope = await client.studio.itineraries.postItineraryShareLinkRotate({
428
+ itinerary_id: itineraryId
429
+ });
430
+ return shareLinkResponseSchema.parse(envelope).data;
431
+ };
432
+ var disableItineraryShareLink = async (client, itineraryId) => {
433
+ await client.studio.itineraries.deleteItineraryShareLink({ itinerary_id: itineraryId });
434
+ };
435
+ var fetchItineraryShareLink = async (client, itineraryId) => {
436
+ const envelope = await client.studio.itineraries.getItineraryShareLink({
437
+ itinerary_id: itineraryId
438
+ });
439
+ return shareLinkReadSchema.parse(envelope).data;
440
+ };
441
+
442
+ // src/data/rules/persistence.ts
443
+ var restStudioPersistence = (client) => ({
444
+ tiled: true,
445
+ convertSegment: (itineraryId, segmentId, params) => convertSegment(client, itineraryId, segmentId, params),
446
+ createItinerary: (params) => createItinerary(client, params),
447
+ createSegment: (itineraryId, params) => createSegment(client, itineraryId, params),
448
+ createSegmentGroup: (itineraryId, params) => createSegmentGroup(client, itineraryId, params),
449
+ createWaypoint: (itineraryId, params) => createWaypoint(client, itineraryId, params),
450
+ deleteItinerary: (itineraryId) => deleteItinerary(client, itineraryId),
451
+ deleteSegment: (itineraryId, segmentId) => deleteSegment(client, itineraryId, segmentId),
452
+ deleteSegmentGroup: (itineraryId, groupId) => deleteSegmentGroup(client, itineraryId, groupId),
453
+ deleteWaypoint: (itineraryId, waypointId) => deleteWaypoint(client, itineraryId, waypointId),
454
+ disableItineraryShareLink: (itineraryId) => disableItineraryShareLink(client, itineraryId),
455
+ duplicateItinerary: (itineraryId, params) => duplicateItinerary(client, itineraryId, params),
456
+ fetchItineraryRecord: (itineraryId, surface) => fetchItineraryRecord(client, itineraryId, surface),
457
+ fetchItineraryShareLink: (itineraryId) => fetchItineraryShareLink(client, itineraryId),
458
+ mergeSegment: (itineraryId, segmentId) => mergeSegment(client, itineraryId, segmentId),
459
+ mintItineraryShareLink: (itineraryId) => mintItineraryShareLink(client, itineraryId),
460
+ publishItinerary: (itineraryId) => publishItinerary(client, itineraryId),
461
+ rotateItineraryShareLink: (itineraryId) => rotateItineraryShareLink(client, itineraryId),
462
+ splitSegment: (itineraryId, segmentId, params) => splitSegment(client, itineraryId, segmentId, params),
463
+ unpublishItinerary: (itineraryId) => unpublishItinerary(client, itineraryId),
464
+ updateItinerary: (itineraryId, params) => updateItinerary(client, itineraryId, params),
465
+ updateSegment: (itineraryId, segmentId, params) => updateSegment(client, itineraryId, segmentId, params),
466
+ updateSegmentGroup: (itineraryId, groupId, params) => updateSegmentGroup(client, itineraryId, groupId, params),
467
+ updateWaypoint: (itineraryId, waypointId, params) => updateWaypoint(client, itineraryId, waypointId, params)
468
+ });
469
+ var PERSISTENCE_REFUSED_NAME = "StudioPersistenceRefusedError";
470
+ var StudioPersistenceRefusedError = class extends MountayaElementsError {
471
+ name = PERSISTENCE_REFUSED_NAME;
472
+ };
473
+ var refusedError = (verb) => new StudioPersistenceRefusedError(`${verb} is not available in a local studio session`);
474
+ var DEFAULT_NAMESPACE = "studio";
475
+ var instantOf = (clock) => {
476
+ const reading = clock.now();
477
+ const instant = new Date(reading);
478
+ if (Number.isNaN(instant.getTime())) {
479
+ throw new MountayaElementsError(
480
+ `local studio session: the clock seam reads no instant (${String(reading)}), so the write has no time to carry. Hand the session a clock whose now() answers epoch milliseconds.`
481
+ );
482
+ }
483
+ return instant;
484
+ };
485
+ var withLocalMetrics = (segment) => {
486
+ let ascent = 0;
487
+ let descent = 0;
488
+ let lowest = Number.POSITIVE_INFINITY;
489
+ let highest = Number.NEGATIVE_INFINITY;
490
+ let readings = 0;
491
+ let distance = null;
492
+ for (const line of extractLines(segment.geojson)) {
493
+ if (line.coordinates.length > 1) {
494
+ distance = (distance ?? 0) + segmentLengthMeters(line);
495
+ }
496
+ let previous = null;
497
+ for (const position of line.coordinates) {
498
+ const elevation = position[2];
499
+ if (typeof elevation !== "number") continue;
500
+ if (previous !== null) {
501
+ const step = elevation - previous;
502
+ if (step > 0) ascent += step;
503
+ else descent -= step;
504
+ }
505
+ lowest = Math.min(lowest, elevation);
506
+ highest = Math.max(highest, elevation);
507
+ previous = elevation;
508
+ readings += 1;
509
+ }
510
+ }
511
+ const has3d = readings > 1;
512
+ return withSegmentAnalysis({
513
+ ...segment,
514
+ altitude_max: has3d ? highest : null,
515
+ altitude_min: has3d ? lowest : null,
516
+ ascent: has3d ? ascent : null,
517
+ descent: has3d ? descent : null,
518
+ distance
519
+ });
520
+ };
521
+ var routedGeometry = async (geojson, mode, activityId, route) => {
522
+ if (!route || mode !== "directions" || !geojson) return geojson;
523
+ if (extractLines(geojson).length > 0) return geojson;
524
+ const vias = extractVias(geojson);
525
+ if (vias.length < 2) return geojson;
526
+ try {
527
+ const line = await route({ activityId, vias: vias.map((via) => [...via]) });
528
+ return line ? buildGeometryCollection([line, { coordinates: vias, type: "MultiPoint" }]) : geojson;
529
+ } catch {
530
+ return geojson;
531
+ }
532
+ };
533
+ var sum = (values) => {
534
+ const present = values.filter((value) => value !== null);
535
+ return present.length ? present.reduce((total, value) => total + value, 0) : null;
536
+ };
537
+ var withRollUp = (itinerary) => {
538
+ const segments = itinerary.segments.map((segment, index) => ({ ...segment, position: index }));
539
+ return withItineraryAnalysis({
540
+ ...itinerary,
541
+ ascent: sum(segments.map((segment) => segment.ascent)),
542
+ count: {
543
+ ...itinerary.count,
544
+ groups: itinerary.groups.length,
545
+ segments: segments.length,
546
+ waypoints: itinerary.waypoints.length
547
+ },
548
+ distance: sum(segments.map((segment) => segment.distance)),
549
+ segments
550
+ });
551
+ };
552
+ var clearedText = (sent, held) => {
553
+ if (sent === void 0) return held;
554
+ return sent === null || sent.trim() === "" ? null : sent;
555
+ };
556
+ var segmentOf = (record, segmentId) => {
557
+ const segment = record.segments.find((candidate) => candidate.id === segmentId);
558
+ if (!segment) {
559
+ throw new MountayaElementsNotFoundError(`local studio session holds no segment ${segmentId}`);
560
+ }
561
+ return segment;
562
+ };
563
+ var waypointOf = (record, waypointId) => {
564
+ const waypoint = record.waypoints.find((candidate) => candidate.id === waypointId);
565
+ if (!waypoint) {
566
+ throw new MountayaElementsNotFoundError(`local studio session holds no waypoint ${waypointId}`);
567
+ }
568
+ return waypoint;
569
+ };
570
+ var activityDefaultSpeed = (read, activityId) => {
571
+ if (!read) return null;
572
+ try {
573
+ const speed = read(activityId);
574
+ return typeof speed === "number" && Number.isFinite(speed) && speed > 0 ? speed : null;
575
+ } catch {
576
+ return null;
577
+ }
578
+ };
579
+ var rescaledDuration = (segment, speed, activityDefault) => {
580
+ const held = resolveSpeedKmh(segment.speed, activityDefault);
581
+ const next = resolveSpeedKmh(speed, activityDefault);
582
+ if (held === null || next === null) {
583
+ return segment.duration;
584
+ }
585
+ return durationForSpeed({
586
+ baseDurationSeconds: segment.duration,
587
+ baseSpeedKmh: held,
588
+ distanceMeters: segment.distance,
589
+ targetSpeedKmh: next
590
+ }) ?? segment.duration;
591
+ };
592
+ var updatedSegment = (segment, params, geojson, activityDefault) => {
593
+ const next = {
594
+ ...segment,
595
+ color: params.color === void 0 ? segment.color : params.color,
596
+ description: clearedText(params.description, segment.description),
597
+ duration: params.speed === void 0 ? segment.duration : rescaledDuration(segment, params.speed, activityDefault),
598
+ geojson: geojson ?? segment.geojson,
599
+ name: params.name ?? segment.name,
600
+ revision: segment.revision + 1,
601
+ speed: params.speed === void 0 ? segment.speed : params.speed,
602
+ start_at: params.start_at === void 0 ? segment.start_at : params.start_at
603
+ };
604
+ return geojson ? withLocalMetrics(next) : next;
605
+ };
606
+ var updatedWaypoint = (waypoint, params) => ({
607
+ ...waypoint,
608
+ amenities: params.amenities === void 0 ? waypoint.amenities : params.amenities ?? [],
609
+ color: params.color === void 0 ? waypoint.color : params.color,
610
+ contact: params.contact === void 0 ? waypoint.contact : params.contact,
611
+ description: clearedText(params.description, waypoint.description),
612
+ geojson: params.geojson ?? waypoint.geojson,
613
+ icon: params.icon ?? waypoint.icon,
614
+ media: params.media === void 0 ? waypoint.media : params.media,
615
+ name: params.name === void 0 ? waypoint.name : params.name,
616
+ position: params.position ?? waypoint.position,
617
+ properties: params.properties === void 0 ? waypoint.properties : params.properties,
618
+ revision: waypoint.revision + 1,
619
+ timing: params.timing === void 0 ? waypoint.timing : params.timing
620
+ });
621
+ var sameRecord = (kept, written) => kept === written || kept !== void 0 && JSON.stringify(kept) === JSON.stringify(written);
622
+ var createLocalRecords = (drawer, clock, seed) => {
623
+ let seeded = null;
624
+ let unkept = null;
625
+ const seedRecords = () => {
626
+ seeded ??= Object.fromEntries(
627
+ seed.map((itinerary) => [itinerary.id, withRollUp(itinerary)])
628
+ );
629
+ return seeded;
630
+ };
631
+ const written = () => unkept ?? drawer.read() ?? {};
632
+ const recordIn = (document, itineraryId) => {
633
+ const record = document[itineraryId] ?? seedRecords()[itineraryId];
634
+ if (!record) {
635
+ throw new MountayaElementsNotFoundError(
636
+ `local studio session holds no itinerary ${itineraryId}`
637
+ );
638
+ }
639
+ return record;
640
+ };
641
+ return {
642
+ commit: (itineraryId, change) => {
643
+ const held = written();
644
+ const current = recordIn(held, itineraryId);
645
+ const stamp = instantOf(clock);
646
+ const next = withRollUp({ ...change(current, stamp), updated_at: stamp });
647
+ const document = { ...held, [next.id]: next };
648
+ drawer.write(document);
649
+ unkept = sameRecord(drawer.read()?.[next.id], next) ? null : document;
650
+ return next;
651
+ },
652
+ recordOf: (itineraryId) => recordIn(written(), itineraryId)
653
+ };
654
+ };
655
+ var createLocalPersistence = (drawer, options) => {
656
+ const { clock = studioSeamAbsences.clock, ids = studioSeamAbsences.ids } = options;
657
+ const { defaultSpeed, route, seed = [] } = options;
658
+ const records = createLocalRecords(drawer, clock, seed);
659
+ const refuse = (verb) => Promise.reject(refusedError(verb));
660
+ return {
661
+ tiled: false,
662
+ convertSegment: () => refuse("Changing a segment's authoring mode"),
663
+ createItinerary: () => refuse("Creating an itinerary"),
664
+ createSegment: async (itineraryId, params) => {
665
+ const { activity_id: activityId } = records.recordOf(itineraryId);
666
+ const geojson = await routedGeometry(params.geojson, params.mode, activityId, route);
667
+ const id = localId(ids);
668
+ const saved = records.commit(itineraryId, (current, stamp) => {
669
+ const segment = withLocalMetrics({
670
+ ...blankSegment(current, stamp, id),
671
+ color: params.color ?? null,
672
+ description: params.description ?? null,
673
+ geojson: geojson ?? null,
674
+ mode: params.mode,
675
+ name: params.name,
676
+ speed: params.speed ?? null,
677
+ start_at: params.start_at ?? null
678
+ });
679
+ const before = params.before_segment_id;
680
+ const at = before === void 0 ? current.segments.length : current.segments.indexOf(segmentOf(current, before));
681
+ return {
682
+ ...current,
683
+ segments: [...current.segments.slice(0, at), segment, ...current.segments.slice(at)]
684
+ };
685
+ });
686
+ return segmentOf(saved, id);
687
+ },
688
+ createSegmentGroup: () => refuse("Creating a segment group"),
689
+ createWaypoint: async (itineraryId, params) => {
690
+ const id = localId(ids);
691
+ const saved = records.commit(itineraryId, (current, stamp) => ({
692
+ ...current,
693
+ waypoints: [
694
+ ...current.waypoints,
695
+ {
696
+ ...blankWaypoint(current, stamp, id),
697
+ amenities: params.amenities ?? [],
698
+ color: params.color ?? null,
699
+ contact: params.contact ?? null,
700
+ description: params.description ?? null,
701
+ geojson: params.geojson ?? null,
702
+ icon: params.icon ?? null,
703
+ media: params.media ?? null,
704
+ mode: params.mode,
705
+ name: params.name ?? null,
706
+ position: params.position,
707
+ properties: params.properties ?? null,
708
+ timing: params.timing ?? null
709
+ }
710
+ ]
711
+ }));
712
+ return waypointOf(saved, id);
713
+ },
714
+ deleteItinerary: () => refuse("Deleting an itinerary"),
715
+ deleteSegment: async (itineraryId, segmentId) => {
716
+ records.commit(itineraryId, (current) => {
717
+ const index = current.segments.indexOf(segmentOf(current, segmentId));
718
+ if (index > 0 && index < current.segments.length - 1) {
719
+ throw new SegmentDeleteNotEdgeError(
720
+ `local studio session: segment ${segmentId} is neither the first nor the last of the chain, and a chain shrinks from its ends only`
721
+ );
722
+ }
723
+ return {
724
+ ...current,
725
+ segments: current.segments.filter((segment) => segment.id !== segmentId)
726
+ };
727
+ });
728
+ },
729
+ deleteSegmentGroup: () => refuse("Deleting a segment group"),
730
+ deleteWaypoint: async (itineraryId, waypointId) => {
731
+ records.commit(itineraryId, (current) => {
732
+ const removed = waypointOf(current, waypointId);
733
+ return {
734
+ ...current,
735
+ waypoints: current.waypoints.filter((waypoint) => waypoint !== removed)
736
+ };
737
+ });
738
+ },
739
+ disableItineraryShareLink: () => refuse("Disabling a share link"),
740
+ duplicateItinerary: () => refuse("Duplicating an itinerary"),
741
+ fetchItineraryRecord: async (itineraryId) => records.recordOf(itineraryId),
742
+ fetchItineraryShareLink: () => refuse("Reading a share link"),
743
+ mergeSegment: () => refuse("Merging two segments"),
744
+ mintItineraryShareLink: () => refuse("Minting a share link"),
745
+ publishItinerary: () => refuse("Publishing an itinerary"),
746
+ rotateItineraryShareLink: () => refuse("Rotating a share link"),
747
+ splitSegment: () => refuse("Splitting a segment"),
748
+ unpublishItinerary: () => refuse("Unpublishing an itinerary"),
749
+ updateItinerary: async (itineraryId, params) => records.commit(itineraryId, (current) => ({
750
+ ...current,
751
+ description: clearedText(params.description, current.description),
752
+ is_private: params.is_private ?? current.is_private,
753
+ name: params.name ?? current.name,
754
+ revision: current.revision + 1
755
+ })),
756
+ updateSegment: async (itineraryId, segmentId, params) => {
757
+ const record = records.recordOf(itineraryId);
758
+ const { mode } = segmentOf(record, segmentId);
759
+ const geojson = await routedGeometry(params.geojson, mode, record.activity_id, route);
760
+ const activityDefault = params.speed === void 0 ? null : activityDefaultSpeed(defaultSpeed, record.activity_id);
761
+ const saved = records.commit(itineraryId, (current) => {
762
+ const held = segmentOf(current, segmentId);
763
+ return {
764
+ ...current,
765
+ segments: current.segments.map(
766
+ (segment) => segment === held ? updatedSegment(segment, params, geojson, activityDefault) : segment
767
+ )
768
+ };
769
+ });
770
+ return segmentOf(saved, segmentId);
771
+ },
772
+ updateSegmentGroup: () => refuse("Updating a segment group"),
773
+ updateWaypoint: async (itineraryId, waypointId, params) => {
774
+ const saved = records.commit(itineraryId, (current) => {
775
+ const held = waypointOf(current, waypointId);
776
+ return {
777
+ ...current,
778
+ waypoints: current.waypoints.map(
779
+ (waypoint) => waypoint === held ? updatedWaypoint(waypoint, params) : waypoint
780
+ )
781
+ };
782
+ });
783
+ return waypointOf(saved, waypointId);
784
+ }
785
+ };
786
+ };
787
+ var localStudioPersistence = (options = {}) => createLocalPersistence(localPersistenceDrawer(options.namespace ?? DEFAULT_NAMESPACE), options);
788
+ var memoryStudioPersistence = (options = {}) => createLocalPersistence(memoryPersistenceDrawer(), options);
789
+ var blankSegment = (record, stamp, id) => ({
790
+ altitude_max: null,
791
+ altitude_min: null,
792
+ ascent: null,
793
+ color: null,
794
+ created_at: stamp,
795
+ created_by: record.created_by,
796
+ descent: null,
797
+ description: null,
798
+ distance: null,
799
+ duration: null,
800
+ geojson: null,
801
+ gradient_max: null,
802
+ gradient_min: null,
803
+ group_id: null,
804
+ id,
805
+ itinerary_id: record.id,
806
+ mode: "linestring",
807
+ name: "",
808
+ position: 0,
809
+ revision: 1,
810
+ road_access_info: null,
811
+ slope_info: [],
812
+ speed: null,
813
+ speed_info: null,
814
+ start_at: null,
815
+ steps: [],
816
+ surface_info: [],
817
+ trail_difficulty_info: [],
818
+ way_type_info: []
819
+ });
820
+ var blankWaypoint = (record, stamp, id) => ({
821
+ amenities: [],
822
+ color: null,
823
+ contact: null,
824
+ created_at: stamp,
825
+ created_by: record.created_by,
826
+ description: null,
827
+ geojson: null,
828
+ icon: null,
829
+ id,
830
+ itinerary_id: record.id,
831
+ media: null,
832
+ mode: "point",
833
+ name: null,
834
+ position: 0,
835
+ properties: null,
836
+ revision: 1,
837
+ timing: null
838
+ });
839
+ var localId = (ids) => `local-${ids.next()}`;
840
+
841
+ // src/data/rules/sessionSurface.ts
842
+ var SESSION_TOKEN_PREFIX = "sess_";
843
+ var DEFAULT_SURFACE = "api";
844
+ var STUDIO_SURFACE = "studio-embedded";
845
+ var BASE64URL_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
846
+ var base64UrlBytes = (text2) => {
847
+ if (text2.length % 4 === 1) {
848
+ return void 0;
849
+ }
850
+ const bytes = [];
851
+ let buffer = 0;
852
+ let bits = 0;
853
+ for (const character of text2) {
854
+ const value = BASE64URL_ALPHABET.indexOf(character);
855
+ if (value === -1) {
856
+ return void 0;
857
+ }
858
+ buffer = buffer << 6 | value;
859
+ bits += 6;
860
+ if (bits >= 8) {
861
+ bits -= 8;
862
+ bytes.push(buffer >> bits & 255);
863
+ buffer &= (1 << bits) - 1;
864
+ }
865
+ }
866
+ return Uint8Array.from(bytes);
867
+ };
868
+ var payloadOf = (token) => {
869
+ if (!token.startsWith(SESSION_TOKEN_PREFIX)) {
870
+ return void 0;
871
+ }
872
+ const body = token.slice(SESSION_TOKEN_PREFIX.length);
873
+ const dot = body.indexOf(".");
874
+ if (dot <= 0 || dot === body.length - 1) {
875
+ return void 0;
876
+ }
877
+ const bytes = base64UrlBytes(body.slice(0, dot));
878
+ if (bytes === void 0) {
879
+ return void 0;
880
+ }
881
+ let parsed;
882
+ try {
883
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
884
+ } catch {
885
+ return void 0;
886
+ }
887
+ return typeof parsed === "object" && parsed !== null && !Array.isArray(parsed) ? parsed : void 0;
888
+ };
889
+ var sessionTokenSurface = (token) => {
890
+ const payload = payloadOf(token);
891
+ if (payload === void 0) {
892
+ return void 0;
893
+ }
894
+ if (!("surface" in payload) || payload.surface === void 0) {
895
+ return DEFAULT_SURFACE;
896
+ }
897
+ return typeof payload.surface === "string" ? payload.surface : void 0;
898
+ };
899
+ var isStudioSessionToken = (token) => sessionTokenSurface(token) === STUDIO_SURFACE;
900
+
901
+ // src/edit/rules/editKeyboard.ts
902
+ var latinLetter = /^[a-z]$/i;
903
+ var LAST_ASCII_CODE_POINT = 127;
904
+ var isCharacterOutsideAscii = (key) => {
905
+ const [first, ...rest] = key;
906
+ return first !== void 0 && rest.length === 0 && (first.codePointAt(0) ?? 0) > LAST_ASCII_CODE_POINT;
907
+ };
908
+ var physicalLetter = /^Key([A-Z])$/;
909
+ var chordLetter = (stroke) => {
910
+ if (latinLetter.test(stroke.key)) {
911
+ return stroke.key.toLowerCase();
912
+ }
913
+ if (stroke.code === void 0 || !isCharacterOutsideAscii(stroke.key)) {
914
+ return null;
915
+ }
916
+ return physicalLetter.exec(stroke.code)?.[1]?.toLowerCase() ?? null;
917
+ };
918
+ var editToolPrefixes = {
919
+ segment: "studio.itinerary.segment.",
920
+ waypoint: "studio.itinerary.waypoint.",
921
+ zone: "studio.zone."
922
+ };
923
+ var editToolVerbs = {
924
+ cancel: "editCancel",
925
+ commit: "editCommit",
926
+ redo: "editRedo",
927
+ undo: "editUndo"
928
+ };
929
+ var editToolName = (family, intent) => `${editToolPrefixes[family]}${editToolVerbs[intent]}`;
930
+ var editHijacksNativeShortcut = (stroke) => {
931
+ if (stroke.key === "Enter") {
932
+ return true;
933
+ }
934
+ const letter = chordLetter(stroke);
935
+ return stroke.meta && (letter === "z" || letter === "y" || letter === "s");
936
+ };
937
+ var editKeyIntent = (stroke, options = {}) => {
938
+ const { escapeCancels = true } = options;
939
+ const letter = chordLetter(stroke);
940
+ if (stroke.key === "Enter" || stroke.meta && letter === "s") {
941
+ return "commit";
942
+ }
943
+ if (escapeCancels && stroke.key === "Escape") {
944
+ return "cancel";
945
+ }
946
+ if (stroke.meta && letter === "z") {
947
+ return stroke.shift ? "redo" : "undo";
948
+ }
949
+ if (stroke.meta && letter === "y") {
950
+ return "redo";
951
+ }
952
+ return null;
953
+ };
954
+
955
+ // src/edit/rules/editShortcuts.ts
956
+ var editShortcuts = (input) => {
957
+ const modifier = input.apple ? "command" : "control";
958
+ const shortcuts = [];
959
+ if (input.canUndo) {
960
+ shortcuts.push({ action: "undo", keys: [modifier, "z"] });
961
+ }
962
+ if (input.canRedo) {
963
+ shortcuts.push({
964
+ action: "redo",
965
+ keys: input.apple ? ["shift", "command", "z"] : ["control", "y"]
966
+ });
967
+ }
968
+ if (input.escape !== null) {
969
+ shortcuts.push({ action: input.escape, keys: ["escape"] });
970
+ }
971
+ if (input.canCommit) {
972
+ shortcuts.push({ action: "commit", keys: ["enter"] });
973
+ }
974
+ return shortcuts;
975
+ };
976
+ var zoneEditTooltipText = (texts, hasShape) => {
977
+ if (hasShape) {
978
+ return texts.reshape;
979
+ }
980
+ return texts.draw;
981
+ };
982
+ var segmentEditTooltipContent = (texts, viaCount, mode) => {
983
+ if (mode === "directions" && viaCount >= DIRECTIONS_VIA_MAX) {
984
+ return { hint: null, primary: texts.viaCapReached, tone: "limit" };
985
+ }
986
+ if (mode === "directions" && viaCount >= DIRECTIONS_VIA_COUNTER_THRESHOLD) {
987
+ return { hint: null, primary: texts.viaCapCounter(viaCount), tone: "warning" };
988
+ }
989
+ return {
990
+ hint: texts.finishHint,
991
+ primary: viaCount >= SEGMENT_MIN_VIAS ? texts.reshape : texts.addPoint,
992
+ tone: "info"
993
+ };
994
+ };
995
+ var waypointEditTooltipText = (texts, mode, hasDraft, poiUnderCursor) => {
996
+ if (mode === "point") {
997
+ return hasDraft ? texts.clickToMove : texts.clickToDrop;
998
+ }
999
+ return poiUnderCursor ? texts.clickToCapture : texts.clickAPoi;
1000
+ };
1001
+
1002
+ // src/embed/rules/allowedDomains.ts
1003
+ var leadingWww = /^www\./;
1004
+ var loopbackIpv4 = /^127(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}$/;
1005
+ var ipv6Text = /^[0-9a-f:.]+$/;
1006
+ var loopbackIpv6 = /^\[(?:::1|::ffff:7f[0-9a-f]{2}:[0-9a-f]{1,4})\]$/;
1007
+ var isLoopbackHost = (host) => {
1008
+ if (host === "localhost" || host.endsWith(".localhost") || loopbackIpv4.test(host)) {
1009
+ return true;
1010
+ }
1011
+ if (!host.includes(":") || !ipv6Text.test(host)) {
1012
+ return false;
1013
+ }
1014
+ try {
1015
+ return loopbackIpv6.test(new URL(`http://[${host}]`).hostname);
1016
+ } catch {
1017
+ return false;
1018
+ }
1019
+ };
1020
+ var isLoopbackDomain = (entry) => {
1021
+ const text2 = entry.toLowerCase().replace(leadingWww, "");
1022
+ if (text2.startsWith("[")) {
1023
+ const close = text2.indexOf("]");
1024
+ const rest = close === -1 ? "" : text2.slice(close + 1);
1025
+ return close !== -1 && (rest === "" || rest.startsWith(":")) && isLoopbackHost(text2.slice(1, close));
1026
+ }
1027
+ const colons = text2.split(":").length - 1;
1028
+ return isLoopbackHost(colons === 1 ? text2.slice(0, text2.indexOf(":")) : text2);
1029
+ };
1030
+
1031
+ // src/embed/rules/snippet.ts
1032
+ var EMBED_CONFIG_FIELDS = [
1033
+ // Appearance.
1034
+ { key: "preferredLanguage", kind: "enum", param: "preferred_language" },
1035
+ { key: "preferredTheme", kind: "enum", param: "preferred_theme" },
1036
+ { key: "preferredUnitLength", kind: "enum", param: "preferred_unit_length" },
1037
+ { key: "preferredUnitPace", kind: "enum", param: "preferred_unit_pace" },
1038
+ { key: "preferredUnitSlope", kind: "enum", param: "preferred_unit_slope" },
1039
+ { key: "preferredUnitTemperature", kind: "enum", param: "preferred_unit_temperature" },
1040
+ { key: "terrain", kind: "string", param: "terrain" },
1041
+ { key: "terrainVariant", kind: "enum", param: "terrain_variant" },
1042
+ { key: "segmentsColor", kind: "string", param: "segments_color" },
1043
+ // Map controls, in the top-right stack's render order: zoom, preferences, download,
1044
+ // directions, Street View (the overlay time slider is in the Layers section below).
1045
+ { key: "withNavigationControl", kind: "boolean", param: "with_navigation_control" },
1046
+ { key: "withPreferencesControl", kind: "boolean", param: "with_preferences_control" },
1047
+ { key: "withDownloadControl", kind: "boolean", param: "with_download_control" },
1048
+ { key: "withDirectionsControl", kind: "boolean", param: "with_directions_control" },
1049
+ { key: "withStreetviewControl", kind: "boolean", param: "with_streetview_control" },
1050
+ // Profile panel, in the elevation panel's render order: characteristics, elevation,
1051
+ // analysis.
1052
+ { key: "withProfileCharacteristics", kind: "boolean", param: "with_profile_characteristics" },
1053
+ { key: "withProfileElevation", kind: "boolean", param: "with_profile_elevation" },
1054
+ { key: "withProfilePaceControl", kind: "boolean", param: "with_profile_pace_control" },
1055
+ { key: "withProfileAnalysis", kind: "boolean", param: "with_profile_analysis" },
1056
+ // Layers: the layers-button toggle that governs the panel, then the terrain and
1057
+ // overlay allowlists it offers, then the restricted stretches the routes are drawn with.
1058
+ { key: "withOverlaysControl", kind: "boolean", param: "with_overlays_control" },
1059
+ { key: "withTerrains", kind: "stringArray", param: "with_terrains" },
1060
+ { key: "withOverlays", kind: "stringArray", param: "with_overlays" },
1061
+ { key: "withAccessRestrictions", kind: "boolean", param: "with_access_restrictions" }
1062
+ ];
1063
+ var emptyEmbedSearch = embedSearchSchema.parse({});
1064
+ var resolveEmbedDefaults = (defaultProps) => resolveEmbedConfig(emptyEmbedSearch, defaultProps);
1065
+ var arraysDifferByContents = (a, b) => {
1066
+ if (a.length !== b.length) {
1067
+ return true;
1068
+ }
1069
+ const sortedA = [...a].sort();
1070
+ const sortedB = [...b].sort();
1071
+ return sortedA.some((value, index) => value !== sortedB[index]);
1072
+ };
1073
+ var allowlistEntries = (param, value, fallback) => {
1074
+ if (allowlistUnrestricted(value)) {
1075
+ return allowlistUnrestricted(fallback) ? [] : [[param, ALLOWLIST_WILDCARD]];
1076
+ }
1077
+ return arraysDifferByContents(value, fallback) ? value.map((slug) => [param, slug]) : [];
1078
+ };
1079
+ var fieldEntries = (field, config, defaults) => {
1080
+ const value = config[field.key];
1081
+ const fallback = defaults[field.key];
1082
+ if (Array.isArray(value)) {
1083
+ return allowlistEntries(field.param, value, Array.isArray(fallback) ? fallback : []);
1084
+ }
1085
+ if (value === fallback) {
1086
+ return [];
1087
+ }
1088
+ return [[field.param, typeof value === "boolean" ? value ? "true" : "false" : value]];
1089
+ };
1090
+ var buildEmbedSearch = (input) => {
1091
+ const entries = [["publishable_key", input.publishableKey]];
1092
+ if (input.itineraryId) {
1093
+ entries.push(["itinerary_id", input.itineraryId]);
1094
+ }
1095
+ if (input.collectionId) {
1096
+ entries.push(["collection_id", input.collectionId]);
1097
+ }
1098
+ if (input.sessionToken) {
1099
+ entries.push(["session_token", input.sessionToken]);
1100
+ }
1101
+ for (const field of EMBED_CONFIG_FIELDS) {
1102
+ entries.push(...fieldEntries(field, input.config, input.defaults));
1103
+ }
1104
+ return entries;
1105
+ };
1106
+ var buildEmbedSrc = (origin, search, hash = "") => {
1107
+ const params = new URLSearchParams(search);
1108
+ return `${originBase(origin)}/studio/embed?${params.toString()}${hash}`;
1109
+ };
1110
+ var buildEmbedViewHash = (view) => {
1111
+ if (view.center === null || view.zoom === null) {
1112
+ return "";
1113
+ }
1114
+ const [lng, lat] = view.center;
1115
+ const bearing = Math.round(view.bearing ?? 0);
1116
+ const pitch = Math.round(view.pitch ?? 0);
1117
+ return `#view=${view.zoom.toFixed(2)}/${lat.toFixed(6)}/${lng.toFixed(6)}/${bearing}/${pitch}`;
1118
+ };
1119
+ var EMBED_IFRAME_RADIUS_PX = 8;
1120
+ var escapeHtmlAttribute = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
1121
+ var buildEmbedIframe = (input) => [
1122
+ "<iframe",
1123
+ ` src="${escapeHtmlAttribute(input.src)}"`,
1124
+ ` width="${escapeHtmlAttribute(input.width)}"`,
1125
+ ` height="${escapeHtmlAttribute(input.height)}"`,
1126
+ ` title="${escapeHtmlAttribute(input.title)}"`,
1127
+ ` style="border:0;border-radius:${EMBED_IFRAME_RADIUS_PX}px"`,
1128
+ ' loading="lazy"',
1129
+ ' referrerpolicy="strict-origin-when-cross-origin"',
1130
+ "></iframe>"
1131
+ ].join("\n");
1132
+ var EMBED_SESSION_ENDPOINT = "/api/mountaya-embed-session";
1133
+ var scriptString = (value) => JSON.stringify(value).replace(/</g, "\\u003c");
1134
+ var buildEmbedSessionScript = (input) => [
1135
+ "<script>",
1136
+ " // Answers each Mountaya embed's request for a session token from your endpoint, which",
1137
+ " // calls POST /v1/sessions with your secret key and answers its body, or the session in it.",
1138
+ " (function () {",
1139
+ ` var origin = ${scriptString(originBase(input.appOrigin))};`,
1140
+ ` var endpoint = ${scriptString(input.endpoint ?? EMBED_SESSION_ENDPOINT)};`,
1141
+ " if (window.mountayaEmbedSession) return;",
1142
+ " window.mountayaEmbedSession = true;",
1143
+ ' window.addEventListener("message", function (event) {',
1144
+ " if (event.origin !== origin || !event.data) return;",
1145
+ ` if (event.data.type !== ${scriptString(REQUEST_SESSION_TOKEN_MESSAGE)}) return;`,
1146
+ " var frame = event.source;",
1147
+ ' fetch(endpoint, { credentials: "same-origin" })',
1148
+ " .then(function (response) {",
1149
+ ' if (!response.ok) throw new Error("Session endpoint answered " + response.status);',
1150
+ " return response.json();",
1151
+ " })",
1152
+ " .then(function (body) {",
1153
+ " var session = body && body.data ? body.data : body;",
1154
+ ' if (!session || typeof session.token !== "string") {',
1155
+ ' throw new Error("Session endpoint answered no token");',
1156
+ " }",
1157
+ ' if (typeof session.user_id === "string") {',
1158
+ ' throw new Error("Session endpoint answered a token naming a user: mint without user_id");',
1159
+ " }",
1160
+ " frame.postMessage(",
1161
+ ` { type: ${scriptString(SET_SESSION_TOKEN_MESSAGE)}, token: session.token, expiresAt: session.expires_at },`,
1162
+ " origin",
1163
+ " );",
1164
+ " })",
1165
+ " .catch(function (error) {",
1166
+ " console.error(error);",
1167
+ " });",
1168
+ " });",
1169
+ " })();",
1170
+ "</script>"
1171
+ ].join("\n");
1172
+
1173
+ // src/embed/rules/defaults.ts
1174
+ var embedFallbackProps = {
1175
+ preferred_language: "en",
1176
+ preferred_theme: "light",
1177
+ preferred_unit_length: "metric",
1178
+ preferred_unit_pace: "per-time",
1179
+ preferred_unit_slope: "degrees",
1180
+ preferred_unit_temperature: "celsius",
1181
+ segments_color: "",
1182
+ terrain: DEFAULT_TERRAIN,
1183
+ terrain_variant: "light",
1184
+ with_access_restrictions: true,
1185
+ with_collection_itineraries: true,
1186
+ with_collection_zones: true,
1187
+ with_directions_control: false,
1188
+ with_download_control: false,
1189
+ with_navigation_control: true,
1190
+ with_overlays: [],
1191
+ with_overlays_control: false,
1192
+ with_preferences_control: true,
1193
+ with_profile_analysis: false,
1194
+ with_profile_characteristics: true,
1195
+ with_profile_elevation: true,
1196
+ with_profile_pace_control: true,
1197
+ with_streetview_control: false,
1198
+ with_terrains: []
1199
+ };
1200
+ var normalizeDefaultProps = (props) => {
1201
+ if (!props) {
1202
+ return embedFallbackProps;
1203
+ }
1204
+ const language = languageSchema.safeParse(props.preferred_language);
1205
+ const theme = themeSchema.safeParse(props.preferred_theme);
1206
+ const unitLength = unitLengthSchema.safeParse(props.preferred_unit_length);
1207
+ const unitPace = unitPaceSchema.safeParse(props.preferred_unit_pace);
1208
+ const unitSlope = unitSlopeSchema.safeParse(props.preferred_unit_slope);
1209
+ const unitTemperature = unitTemperatureSchema.safeParse(props.preferred_unit_temperature);
1210
+ const terrainVariant = terrainVariantSchema.safeParse(props.terrain_variant);
1211
+ return {
1212
+ preferred_language: language.success ? language.data : embedFallbackProps.preferred_language,
1213
+ preferred_theme: theme.success ? theme.data : embedFallbackProps.preferred_theme,
1214
+ preferred_unit_length: unitLength.success ? unitLength.data : embedFallbackProps.preferred_unit_length,
1215
+ preferred_unit_pace: unitPace.success ? unitPace.data : embedFallbackProps.preferred_unit_pace,
1216
+ preferred_unit_slope: unitSlope.success ? unitSlope.data : embedFallbackProps.preferred_unit_slope,
1217
+ preferred_unit_temperature: unitTemperature.success ? unitTemperature.data : embedFallbackProps.preferred_unit_temperature,
1218
+ segments_color: props.segments_color ?? embedFallbackProps.segments_color,
1219
+ terrain: props.terrain || embedFallbackProps.terrain,
1220
+ terrain_variant: terrainVariant.success ? terrainVariant.data : embedFallbackProps.terrain_variant,
1221
+ with_access_restrictions: props.with_access_restrictions,
1222
+ with_collection_itineraries: props.with_collection_itineraries,
1223
+ with_collection_zones: props.with_collection_zones,
1224
+ with_directions_control: props.with_directions_control,
1225
+ with_download_control: props.with_download_control,
1226
+ with_navigation_control: props.with_navigation_control,
1227
+ with_overlays: props.with_overlays,
1228
+ with_overlays_control: props.with_overlays_control,
1229
+ with_preferences_control: props.with_preferences_control,
1230
+ with_profile_analysis: props.with_profile_analysis,
1231
+ with_profile_characteristics: props.with_profile_characteristics,
1232
+ with_profile_elevation: props.with_profile_elevation,
1233
+ with_profile_pace_control: props.with_profile_pace_control,
1234
+ with_streetview_control: props.with_streetview_control,
1235
+ with_terrains: props.with_terrains
1236
+ };
1237
+ };
1238
+ var resolveOrgEmbedDefaults = (props) => resolveEmbedDefaults(normalizeDefaultProps(props));
1239
+
1240
+ // src/embed/rules/displaySeed.ts
1241
+ var displaySeedDispatches = (previous, next) => {
1242
+ const dispatches = [];
1243
+ if (previous === null || previous.terrain !== next.terrain || previous.terrainVariant !== next.terrainVariant) {
1244
+ dispatches.push({
1245
+ input: { terrain: next.terrain, variant: next.terrainVariant },
1246
+ name: "studio.terrain.set"
1247
+ });
1248
+ }
1249
+ if (previous === null || previous.overlay !== next.overlay) {
1250
+ dispatches.push({ input: { overlay: next.overlay }, name: "studio.overlay.set" });
1251
+ }
1252
+ const previousEnrichments = previous?.enrichments ?? [];
1253
+ for (const slug of next.enrichments) {
1254
+ if (!previousEnrichments.includes(slug)) {
1255
+ dispatches.push({
1256
+ input: { enabled: true, overlay: slug },
1257
+ name: "studio.overlay.enrichment.set"
1258
+ });
1259
+ }
1260
+ }
1261
+ for (const slug of previousEnrichments) {
1262
+ if (!next.enrichments.includes(slug)) {
1263
+ dispatches.push({
1264
+ input: { enabled: false, overlay: slug },
1265
+ name: "studio.overlay.enrichment.set"
1266
+ });
1267
+ }
1268
+ }
1269
+ return dispatches;
1270
+ };
1271
+
1272
+ // src/embed/rules/embedAllowlist.ts
1273
+ var capPermits = (cap, slug) => {
1274
+ if (cap === void 0) {
1275
+ return true;
1276
+ }
1277
+ const mode = allowlistMode(cap, "cap");
1278
+ return mode === "all" || mode === "specific" && cap.includes(slug);
1279
+ };
1280
+ var clampConfigToAllowlists = (config, cap) => {
1281
+ const displayUnrestricted = allowlistUnrestricted(config.withOverlays);
1282
+ const permits = (slug) => capPermits(cap, slug) && (displayUnrestricted || config.withOverlays.includes(slug));
1283
+ let next = config;
1284
+ if (next.overlay !== null && !permits(next.overlay)) {
1285
+ next = { ...next, overlay: null };
1286
+ }
1287
+ if (next.enrichments.length > 0) {
1288
+ const allowedEnrichments = next.enrichments.filter(permits);
1289
+ if (allowedEnrichments.length !== next.enrichments.length) {
1290
+ next = { ...next, enrichments: allowedEnrichments };
1291
+ }
1292
+ }
1293
+ const capMode = cap === void 0 ? "all" : allowlistMode(cap, "cap");
1294
+ if (capMode !== "all") {
1295
+ const offered = displayUnrestricted ? cap ?? [] : config.withOverlays.filter((slug) => capPermits(cap, slug));
1296
+ if (offered.length > 0 && (displayUnrestricted || offered.length !== config.withOverlays.length)) {
1297
+ next = { ...next, withOverlays: [...offered] };
1298
+ }
1299
+ }
1300
+ if (!allowlistUnrestricted(next.withTerrains) && !next.withTerrains.includes(next.terrain)) {
1301
+ const fallbackTerrain = next.withTerrains[0];
1302
+ if (fallbackTerrain !== void 0) {
1303
+ next = { ...next, terrain: fallbackTerrain };
1304
+ }
1305
+ }
1306
+ return next;
1307
+ };
1308
+ var overlaysOffered = (withOverlays, cap) => {
1309
+ const capMode = cap === void 0 ? "all" : allowlistMode(cap, "cap");
1310
+ if (capMode !== "specific") {
1311
+ return capMode === "all";
1312
+ }
1313
+ return allowlistUnrestricted(withOverlays) || withOverlays.some((slug) => capPermits(cap, slug));
1314
+ };
1315
+ var layersControlOffered = (config, cap) => overlaysOffered(config.withOverlays, cap) || !allowlistUnrestricted(config.withTerrains);
1316
+
1317
+ // src/embed/rules/embedSectionFields.ts
1318
+ var EMBED_SECTION_ORDER = [
1319
+ "appearance",
1320
+ "controls",
1321
+ "profile",
1322
+ "layers"
1323
+ ];
1324
+ var embedSectionFieldKeys = {
1325
+ appearance: /* @__PURE__ */ new Set([
1326
+ "preferredLanguage",
1327
+ "preferredTheme",
1328
+ "preferredUnitLength",
1329
+ "preferredUnitPace",
1330
+ "preferredUnitSlope",
1331
+ "preferredUnitTemperature",
1332
+ "terrain",
1333
+ "terrainVariant",
1334
+ "segmentsColor"
1335
+ ]),
1336
+ // Empty: the collection section's toggles are organization clamps with no
1337
+ // per-embed spelling, so they carry no EMBED_CONFIG_FIELDS descriptor. They reach
1338
+ // an organization settings form through orgOnlySectionProps below.
1339
+ collection: /* @__PURE__ */ new Set(),
1340
+ controls: /* @__PURE__ */ new Set([
1341
+ "withNavigationControl",
1342
+ "withPreferencesControl",
1343
+ "withDownloadControl",
1344
+ "withDirectionsControl",
1345
+ "withStreetviewControl"
1346
+ ]),
1347
+ layers: /* @__PURE__ */ new Set([
1348
+ "withOverlaysControl",
1349
+ "withTerrains",
1350
+ "withOverlays",
1351
+ "withAccessRestrictions"
1352
+ ]),
1353
+ profile: /* @__PURE__ */ new Set([
1354
+ "withProfileCharacteristics",
1355
+ "withProfileElevation",
1356
+ "withProfilePaceControl",
1357
+ "withProfileAnalysis"
1358
+ ])
1359
+ };
1360
+ var sectionFields = (section) => EMBED_CONFIG_FIELDS.filter((field) => embedSectionFieldKeys[section].has(field.key));
1361
+ var orgOnlySectionProps = {
1362
+ collection: ["with_collection_itineraries", "with_collection_zones"]
1363
+ };
1364
+ var sectionDefaultPropsFields = (section) => [
1365
+ ...sectionFields(section).map((field) => field.param),
1366
+ ...orgOnlySectionProps[section] ?? []
1367
+ ];
1368
+
1369
+ // src/embed/rules/embedElements.ts
1370
+ var EMBED_ELEMENTS = ["map", "segment-table", "waypoint-table"];
1371
+ var isEmbedTableElement = (element) => element !== "map";
1372
+ var isPerEmbedSection = (section) => section !== "collection";
1373
+ var embedElementSections = (element, withGeneral) => {
1374
+ const own = isEmbedTableElement(element) ? ["columns", "appearance"] : ["defaultView", ...EMBED_SECTION_ORDER.filter(isPerEmbedSection)];
1375
+ return [...withGeneral ? ["general"] : [], ...own, "code"];
1376
+ };
1377
+ var tableFieldKeys = /* @__PURE__ */ new Set([
1378
+ "preferredLanguage",
1379
+ "preferredUnitLength"
1380
+ ]);
1381
+ var embedElementSupportsField = (element, key) => !isEmbedTableElement(element) || tableFieldKeys.has(key);
1382
+ var embedElementSectionFields = (element, section) => sectionFields(section).filter((field) => embedElementSupportsField(element, field.key));
1383
+ var embedSectionChanges = (element, section, config, defaults) => embedElementSectionFields(element, section).filter((field) => {
1384
+ const value = config[field.key];
1385
+ const fallback = defaults[field.key];
1386
+ return Array.isArray(value) && Array.isArray(fallback) ? arraysDifferByContents(value, fallback) : value !== fallback;
1387
+ }).length;
1388
+ var EMBED_SEGMENT_TABLE_COLUMNS = [
1389
+ "segment",
1390
+ "profile",
1391
+ "distance",
1392
+ "elevation",
1393
+ "altitude",
1394
+ "duration",
1395
+ "difficulty"
1396
+ ];
1397
+ var EMBED_WAYPOINT_TABLE_COLUMNS = [
1398
+ "waypoint",
1399
+ "profile",
1400
+ "distance",
1401
+ "elevation",
1402
+ "altitude",
1403
+ "amenities",
1404
+ "cutoff",
1405
+ "properties"
1406
+ ];
1407
+ var defaultEmbedTableOptions = {
1408
+ segmentColumns: DEFAULT_SEGMENT_TABLE_COLUMNS,
1409
+ serviceFilter: false,
1410
+ waypointColumns: DEFAULT_WAYPOINT_TABLE_COLUMNS
1411
+ };
1412
+ var toggleEmbedTableColumn = (all, columns, column, shown) => all.filter(
1413
+ (candidate, index) => candidate === column ? shown || index === 0 : columns.includes(candidate)
1414
+ );
1415
+ var embedTableColumns = (element, options) => element === "segment-table" ? options.segmentColumns : options.waypointColumns;
1416
+ var embedTableChanges = (element, options) => {
1417
+ const columns = embedTableColumns(element, options);
1418
+ const defaults = element === "segment-table" ? DEFAULT_SEGMENT_TABLE_COLUMNS : DEFAULT_WAYPOINT_TABLE_COLUMNS;
1419
+ const moved = columns.filter((column) => !defaults.includes(column)).length + defaults.filter((column) => !columns.includes(column)).length;
1420
+ return moved + (element === "waypoint-table" && options.serviceFilter ? 1 : 0);
1421
+ };
1422
+
1423
+ // src/embed/rules/fieldDependencies.ts
1424
+ var embedFieldDependencies = {
1425
+ withProfileAnalysis: ["withProfileElevation"],
1426
+ withProfilePaceControl: ["withProfileElevation", "withProfileCharacteristics"]
1427
+ };
1428
+ var isDependentFieldKey = (key) => Object.hasOwn(embedFieldDependencies, key);
1429
+ var fieldDependenciesUnmet = (key, config) => {
1430
+ if (!isDependentFieldKey(key)) {
1431
+ return [];
1432
+ }
1433
+ const required = embedFieldDependencies[key];
1434
+ return required.filter((field) => config[field] === false);
1435
+ };
1436
+ var clampConfigToFieldDependencies = (config) => {
1437
+ let next = config;
1438
+ for (const key of Object.keys(embedFieldDependencies).filter(isDependentFieldKey)) {
1439
+ if (next[key] && fieldDependenciesUnmet(key, next).length > 0) {
1440
+ next = { ...next, [key]: false };
1441
+ }
1442
+ }
1443
+ return next;
1444
+ };
1445
+
1446
+ // src/embed/rules/embedSecurity.ts
1447
+ var clampEmbedConfigToSecurity = (config, safetyRules) => clampConfigToFieldDependencies(
1448
+ clampConfigToAllowlists(
1449
+ clampConfigToSafetyRules(config, safetyRules),
1450
+ safetyRules?.with_overlays
1451
+ )
1452
+ );
1453
+ var applyEmbedOverrides = (config, content) => {
1454
+ const { itineraryId, overrides } = content;
1455
+ const next = { ...config, itineraryId };
1456
+ if (overrides.terrain !== void 0) {
1457
+ next.terrain = overrides.terrain;
1458
+ }
1459
+ if (Array.isArray(overrides.withOverlays)) {
1460
+ next.withOverlays = overrides.withOverlays;
1461
+ }
1462
+ if (Array.isArray(overrides.withTerrains)) {
1463
+ next.withTerrains = overrides.withTerrains;
1464
+ }
1465
+ if (overrides.withAccessRestrictions !== void 0) {
1466
+ next.withAccessRestrictions = overrides.withAccessRestrictions;
1467
+ }
1468
+ if (overrides.withDirectionsControl !== void 0) {
1469
+ next.withDirectionsControl = overrides.withDirectionsControl;
1470
+ }
1471
+ if (overrides.withDownloadControl !== void 0) {
1472
+ next.withDownloadControl = overrides.withDownloadControl;
1473
+ }
1474
+ if (overrides.withNavigationControl !== void 0) {
1475
+ next.withNavigationControl = overrides.withNavigationControl;
1476
+ }
1477
+ if (overrides.withOverlaysControl !== void 0) {
1478
+ next.withOverlaysControl = overrides.withOverlaysControl;
1479
+ }
1480
+ if (overrides.withPreferencesControl !== void 0) {
1481
+ next.withPreferencesControl = overrides.withPreferencesControl;
1482
+ }
1483
+ if (overrides.withProfileAnalysis !== void 0) {
1484
+ next.withProfileAnalysis = overrides.withProfileAnalysis;
1485
+ }
1486
+ if (overrides.withProfileCharacteristics !== void 0) {
1487
+ next.withProfileCharacteristics = overrides.withProfileCharacteristics;
1488
+ }
1489
+ if (overrides.withProfileElevation !== void 0) {
1490
+ next.withProfileElevation = overrides.withProfileElevation;
1491
+ }
1492
+ if (overrides.withProfilePaceControl !== void 0) {
1493
+ next.withProfilePaceControl = overrides.withProfilePaceControl;
1494
+ }
1495
+ if (overrides.withStreetviewControl !== void 0) {
1496
+ next.withStreetviewControl = overrides.withStreetviewControl;
1497
+ }
1498
+ return next;
1499
+ };
1500
+ var languageOptions = () => MAP_LANGUAGES.map((value) => ({ label: languageEndonym[value], value }));
1501
+ var themeOptions = (words) => [
1502
+ { label: words.embed.options.theme.light, value: "light" },
1503
+ { label: words.embed.options.theme.dark, value: "dark" }
1504
+ ];
1505
+ var unitLengthOptions = (words) => [
1506
+ { label: words.preferences.units.metric.name, value: "metric" },
1507
+ { label: words.preferences.units.imperial.name, value: "imperial" }
1508
+ ];
1509
+ var unitPaceOptions = (words) => [
1510
+ { label: words.preferences.units.perTime.name, value: "per-time" },
1511
+ { label: words.preferences.units.perDistance.name, value: "per-distance" }
1512
+ ];
1513
+ var unitSlopeOptions = (words) => [
1514
+ { label: words.preferences.units.degrees.name, value: "degrees" },
1515
+ { label: words.preferences.units.percentage.name, value: "percentage" }
1516
+ ];
1517
+ var unitTemperatureOptions = (words) => [
1518
+ { label: words.preferences.units.celsius.name, value: "celsius" },
1519
+ { label: words.preferences.units.fahrenheit.name, value: "fahrenheit" }
1520
+ ];
1521
+ var terrainVariantOptions = (words) => [
1522
+ { label: words.embed.options.terrainVariant.light, value: "light" },
1523
+ { label: words.embed.options.terrainVariant.dark, value: "dark" }
1524
+ ];
1525
+ var enumFieldOptions = (key, words) => {
1526
+ switch (key) {
1527
+ case "preferredLanguage":
1528
+ return languageOptions();
1529
+ case "preferredTheme":
1530
+ return themeOptions(words);
1531
+ case "preferredUnitLength":
1532
+ return unitLengthOptions(words);
1533
+ case "preferredUnitPace":
1534
+ return unitPaceOptions(words);
1535
+ case "preferredUnitSlope":
1536
+ return unitSlopeOptions(words);
1537
+ case "preferredUnitTemperature":
1538
+ return unitTemperatureOptions(words);
1539
+ case "terrainVariant":
1540
+ return terrainVariantOptions(words);
1541
+ default:
1542
+ return [];
1543
+ }
1544
+ };
1545
+
1546
+ // src/embed/rules/layerOptions.ts
1547
+ var isLayerSlug = (slug) => slug.length > 0 && slug !== ALLOWLIST_WILDCARD;
1548
+ var missingOptions = (selected, known) => [...new Set(selected)].filter((slug) => isLayerSlug(slug) && !known.has(slug)).map((slug) => ({ label: slug, value: slug }));
1549
+ var withSelectedTerrains = (terrains, selected) => {
1550
+ const extra = missingOptions(selected, new Set(terrains.map((option) => option.value)));
1551
+ return extra.length === 0 ? terrains : [...terrains, ...extra];
1552
+ };
1553
+ var cappedOverlayGroups = (groups, allowed) => {
1554
+ if (allowed === void 0 || allowed.includes(ALLOWLIST_WILDCARD)) {
1555
+ return groups;
1556
+ }
1557
+ const permitted = new Set(allowed);
1558
+ return groups.map((group) => ({
1559
+ group: group.group,
1560
+ items: group.items.filter((item) => permitted.has(item.value))
1561
+ })).filter((group) => group.items.length > 0);
1562
+ };
1563
+ var withSelectedOverlays = (groups, selected, otherLabel) => {
1564
+ const extra = missingOptions(
1565
+ selected,
1566
+ new Set(groups.flatMap((group) => group.items.map((item) => item.value)))
1567
+ );
1568
+ return extra.length === 0 ? groups : [...groups, { group: otherLabel, items: extra }];
1569
+ };
1570
+ var embedLayerOptions = (catalog, config, allowedOverlays, otherLabel) => ({
1571
+ overlayGroups: withSelectedOverlays(
1572
+ cappedOverlayGroups(catalog.overlayGroups, allowedOverlays),
1573
+ config.withOverlays,
1574
+ otherLabel
1575
+ ),
1576
+ terrains: withSelectedTerrains(catalog.terrains, [config.terrain, ...config.withTerrains])
1577
+ });
1578
+ var EMBED_TABLE_INSTALL_COMMAND = "npm install @mountaya/elements-react @mountaya/elements @mountaya/client";
1579
+ var tableComponents = {
1580
+ "segment-table": { element: "ItinerarySegmentTable", wrapper: "SegmentTable" },
1581
+ "waypoint-table": { element: "ItineraryWaypointTable", wrapper: "WaypointTable" }
1582
+ };
1583
+ var defaultColumns = {
1584
+ "segment-table": DEFAULT_SEGMENT_TABLE_COLUMNS,
1585
+ "waypoint-table": DEFAULT_WAYPOINT_TABLE_COLUMNS
1586
+ };
1587
+ var instantColumns = /* @__PURE__ */ new Set(["cutoff", "properties"]);
1588
+ var codeString = (value) => JSON.stringify(value).replace(/</g, "\\u003c");
1589
+ var plainAttribute = /^[\w-]*$/;
1590
+ var attribute = (name, value) => plainAttribute.test(value) ? `${name}="${value}"` : `${name}={${codeString(value)}}`;
1591
+ var sameOrder = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
1592
+ var sessionLines = (endpoint) => [
1593
+ "// Your organization requires a session token. This asks your own endpoint for one, which",
1594
+ "// calls POST /v1/sessions with your secret key and answers its body, or the session in it.",
1595
+ "const session = new SessionTokenEngine({",
1596
+ " mint: async () => {",
1597
+ ` const response = await fetch(${codeString(endpoint)}, { credentials: "same-origin" });`,
1598
+ " if (!response.ok) {",
1599
+ ' throw new Error("Session endpoint answered " + response.status);',
1600
+ " }",
1601
+ " const body = await response.json();",
1602
+ "",
1603
+ " return body.data ?? body;",
1604
+ " },",
1605
+ "});",
1606
+ "// The engine mints again before each token expires, for as long as something subscribes.",
1607
+ "session.subscribe(() => undefined);",
1608
+ ""
1609
+ ];
1610
+ var buildEmbedTableCode = (input) => {
1611
+ const { element, wrapper } = tableComponents[input.element];
1612
+ const requireSessionToken = input.requireSessionToken === true;
1613
+ const filtered = input.element === "waypoint-table" && input.serviceFilter === true;
1614
+ const statesColumns = !sameOrder(input.columns, defaultColumns[input.element]);
1615
+ const formatsInstants = input.element === "waypoint-table" && input.columns.some((column) => instantColumns.has(column));
1616
+ const french = input.language === "fr";
1617
+ const imperial = input.length === "imperial";
1618
+ const imports = [
1619
+ ...filtered ? ['import { useState } from "react";', ""] : [],
1620
+ `import { Mountaya${requireSessionToken ? ", SessionTokenEngine" : ""} } from "@mountaya/client/browser";`,
1621
+ ...french ? ['import { frElementsStrings } from "@mountaya/elements/i18n/fr";'] : [],
1622
+ ...imperial ? ['import { defaultUnits, type UnitFormatOptions } from "@mountaya/elements/profile";'] : [],
1623
+ `import { ${element} } from "@mountaya/elements-react/elements";`,
1624
+ 'import { MountayaElementsProvider } from "@mountaya/elements-react/headless";'
1625
+ ];
1626
+ const credential = requireSessionToken ? `{ publishableKey: ${codeString(input.publishableKey)}, sessionToken: session }` : `{ publishableKey: ${codeString(input.publishableKey)} }`;
1627
+ const units = imperial ? [
1628
+ `const units: UnitFormatOptions = { ...defaultUnits, ${input.language === "en" ? "" : `language: ${codeString(input.language)}, `}length: "imperial" };`,
1629
+ ""
1630
+ ] : [];
1631
+ const formatter = formatsInstants ? [
1632
+ "// A cut-off is written in the visitor's own time zone: state `timeZone` to write it in",
1633
+ "// your event's instead.",
1634
+ "const formatCutoffAt = (instant: Date): string =>",
1635
+ ` new Intl.DateTimeFormat(${codeString(input.language)}, { dateStyle: "medium", timeStyle: "short" }).format(instant);`,
1636
+ ""
1637
+ ] : [];
1638
+ const provider = french ? [
1639
+ "<MountayaElementsProvider",
1640
+ " client={client}",
1641
+ ' language="fr"',
1642
+ " translations={{ fr: frElementsStrings }}",
1643
+ ">"
1644
+ ] : input.language === "en" ? ["<MountayaElementsProvider client={client}>"] : [`<MountayaElementsProvider client={client} ${attribute("language", input.language)}>`];
1645
+ const props = [
1646
+ ...statesColumns ? [`columns={[${input.columns.map(codeString).join(", ")}]}`] : [],
1647
+ ...filtered ? ["filter={filter}"] : [],
1648
+ ...formatsInstants ? ["formatCutoffAt={formatCutoffAt}"] : [],
1649
+ attribute("itineraryId", input.itineraryId),
1650
+ ...filtered ? ["onFilterChange={setFilter}"] : [],
1651
+ 'surface="published"',
1652
+ ...imperial ? ["units={units}"] : []
1653
+ ];
1654
+ const tree = [
1655
+ ...provider,
1656
+ ...props.length <= 2 ? [` <${element} ${props.join(" ")} />`] : [` <${element}`, ...props.map((prop) => ` ${prop}`), " />"],
1657
+ "</MountayaElementsProvider>"
1658
+ ];
1659
+ const component = filtered ? [
1660
+ `export const ${wrapper} = () => {`,
1661
+ " // Controlled, so the chosen services can live in a URL. Several at once keep the",
1662
+ " // waypoints that offer all of them.",
1663
+ " const [filter, setFilter] = useState<readonly string[]>([]);",
1664
+ "",
1665
+ " return (",
1666
+ ...tree.map((line) => ` ${line}`),
1667
+ " );",
1668
+ "};"
1669
+ ] : [`export const ${wrapper} = () => (`, ...tree.map((line) => ` ${line}`), ");"];
1670
+ return [
1671
+ 'import "@mountaya/elements-react/styles.css";',
1672
+ "",
1673
+ ...imports,
1674
+ "",
1675
+ ...requireSessionToken ? sessionLines(input.sessionEndpoint ?? EMBED_SESSION_ENDPOINT) : [],
1676
+ "const client = new Mountaya({",
1677
+ ` credential: ${credential},`,
1678
+ "});",
1679
+ "",
1680
+ ...units,
1681
+ ...formatter,
1682
+ ...component
1683
+ ].join("\n");
1684
+ };
1685
+
1686
+ // src/itinerary/rules/ceiling.ts
1687
+ var itineraryCeiling = (limit, count) => {
1688
+ if (limit === null || !Number.isFinite(limit) || limit < 0) {
1689
+ return { full: false, limit: null };
1690
+ }
1691
+ return { full: count >= limit, limit };
1692
+ };
1693
+ var firstSegmentEditInput = (activity, segmentId, random) => ({
1694
+ activitySlug: activity?.slug ?? void 0,
1695
+ color: pickLivelyColor(null, void 0, random),
1696
+ mode: defaultEngineForActivity(activity?.capabilities),
1697
+ name: defaultSegmentName(0),
1698
+ segmentId
1699
+ });
1700
+ var createFormChanged = (state) => state.name.trim() !== state.seededName.trim() || state.activityId !== null && state.activityId !== state.defaultActivityId || state.organizationId !== null && state.organizationId !== state.defaultOrganizationId || state.collectionIds.length > 0;
1701
+
1702
+ // src/itinerary/rules/view.ts
1703
+ var persistedItineraryView = (itinerary) => ({
1704
+ mode: "persisted",
1705
+ source: {
1706
+ activity_id: itinerary.activity_id,
1707
+ id: itinerary.id,
1708
+ segments: itinerary.segments,
1709
+ waypoints: itinerary.waypoints
1710
+ }
1711
+ });
1712
+
1713
+ // src/itinerary/rules/editorView.ts
1714
+ var emptyEditorView = Object.freeze({
1715
+ mode: "persisted",
1716
+ source: Object.freeze({ activity_id: null, id: null, segments: [], waypoints: [] })
1717
+ });
1718
+ var editorItineraryView = (sources) => {
1719
+ const { draft, itinerary, selectedCandidate: selectedCandidate2, suggestSurfaceShows } = sources;
1720
+ if (draft !== null) {
1721
+ return { mode: "preview", source: draftToView(draft) };
1722
+ }
1723
+ if (selectedCandidate2 !== null && suggestSurfaceShows) {
1724
+ return { mode: "preview", source: suggestionCandidateToView(selectedCandidate2) };
1725
+ }
1726
+ return itinerary === null ? emptyEditorView : persistedItineraryView(itinerary);
1727
+ };
1728
+
1729
+ // src/itinerary/rules/friendlyName.ts
1730
+ var pick = (items, random) => {
1731
+ const index = Math.floor(random() * items.length);
1732
+ const clamped = Number.isFinite(index) ? Math.min(Math.max(index, 0), items.length - 1) : 0;
1733
+ return items[clamped] ?? "";
1734
+ };
1735
+ var generateFriendlyName = (copy, random) => {
1736
+ const adjective = pick(copy.nameAdjectives, random);
1737
+ const noun = pick(copy.nameNouns, random);
1738
+ if (adjective === "" || noun === "") {
1739
+ return `${adjective}${noun}`;
1740
+ }
1741
+ return copy.friendlyName(adjective, noun);
1742
+ };
1743
+ var IMPORT_FILE_MAX_SIZE = convertDataSize(20, "megabyte", "byte");
1744
+ var IMPORT_FILE_FORMATS = [
1745
+ { extension: ".gpx", mimeTypes: ["application/gpx+xml"], provider: "gpx" },
1746
+ {
1747
+ extension: ".geojson",
1748
+ mimeTypes: ["application/geo+json", "application/json"],
1749
+ provider: "geojson"
1750
+ },
1751
+ {
1752
+ extension: ".kml",
1753
+ mimeTypes: ["application/vnd.google-earth.kml+xml", "text/xml"],
1754
+ provider: "kml"
1755
+ },
1756
+ {
1757
+ extension: ".kmz",
1758
+ mimeTypes: [
1759
+ "application/vnd.google-earth.kmz",
1760
+ "application/zip",
1761
+ "application/x-zip-compressed"
1762
+ ],
1763
+ provider: "kmz"
1764
+ },
1765
+ {
1766
+ extension: ".fit",
1767
+ mimeTypes: ["application/vnd.ant.fit", "application/octet-stream"],
1768
+ provider: "fit"
1769
+ },
1770
+ {
1771
+ extension: ".tcx",
1772
+ mimeTypes: ["application/vnd.garmin.tcx+xml", "application/xml"],
1773
+ provider: "tcx"
1774
+ }
1775
+ ];
1776
+ IMPORT_FILE_FORMATS.map((format) => format.extension);
1777
+ var importDropzoneAccept = IMPORT_FILE_FORMATS.reduce((accept, format) => {
1778
+ for (const mimeType of format.mimeTypes) {
1779
+ accept[mimeType] = [...accept[mimeType] ?? [], format.extension];
1780
+ }
1781
+ return accept;
1782
+ }, {});
1783
+ var fileProviderByExtension = new Map(
1784
+ IMPORT_FILE_FORMATS.map((format) => [format.extension, format.provider])
1785
+ );
1786
+ var detectFileProvider = (fileName) => {
1787
+ const lowered = fileName.toLowerCase();
1788
+ for (const [extension, provider] of fileProviderByExtension) {
1789
+ if (lowered.endsWith(extension)) {
1790
+ return provider;
1791
+ }
1792
+ }
1793
+ return null;
1794
+ };
1795
+
1796
+ // src/itinerary/rules/importTotals.ts
1797
+ var EMPTY_SEGMENTS = Object.freeze([]);
1798
+ var importSegmentCounts = (segments) => {
1799
+ let routable = 0;
1800
+ let snapped = 0;
1801
+ for (const segment of segments) {
1802
+ if (segment.directions === null) {
1803
+ continue;
1804
+ }
1805
+ routable += 1;
1806
+ if (segment.mode === "directions") {
1807
+ snapped += 1;
1808
+ }
1809
+ }
1810
+ return {
1811
+ exact: segments.length - snapped,
1812
+ routable,
1813
+ snapped,
1814
+ total: segments.length,
1815
+ unroutable: segments.length - routable
1816
+ };
1817
+ };
1818
+ var itinerarySpriteIcons = (itinerary) => {
1819
+ const [startIcon, endIcon] = ITINERARY_ENDPOINT_ICONS;
1820
+ const icons = [];
1821
+ for (const waypoint of itinerary.waypoints ?? []) {
1822
+ if (waypoint.icon && waypoint.color) {
1823
+ icons.push({ color: waypoint.color, icon: waypoint.icon });
1824
+ }
1825
+ }
1826
+ for (const segment of itinerary.segments ?? []) {
1827
+ if (segment.color) {
1828
+ icons.push(
1829
+ { color: segment.color, icon: startIcon },
1830
+ { color: segment.color, icon: endIcon }
1831
+ );
1832
+ }
1833
+ }
1834
+ return icons;
1835
+ };
1836
+ var itineraryEmphasisFor = (selection, itinerary) => {
1837
+ if (selection !== null) {
1838
+ return { id: selection.id, mode: selection.kind };
1839
+ }
1840
+ return itinerary === null ? { mode: "none" } : { id: itinerary.id, mode: "itinerary" };
1841
+ };
1842
+ var chosenAndOther = (segment) => {
1843
+ const chosen = chosenCandidate(segment);
1844
+ const other = chosen === segment.linestring ? segment.directions : segment.linestring;
1845
+ return { chosen: chosen.geojson, other: other?.geojson ?? null };
1846
+ };
1847
+ var [DRAFT_START_ICON, DRAFT_END_ICON] = ITINERARY_ENDPOINT_ICONS;
1848
+ var endpointMarkers = (draft, active) => chainEndpointMarkers(
1849
+ draft.segments.map((segment) => ({
1850
+ color: segment.color,
1851
+ geometry: chosenAndOther(segment).chosen,
1852
+ id: segment.id
1853
+ })),
1854
+ active
1855
+ );
1856
+ var chainEndpointMarkers = (chain, active) => {
1857
+ const first = chain[0];
1858
+ const last = chain[chain.length - 1];
1859
+ if (!first || !last) {
1860
+ return [];
1861
+ }
1862
+ const markers = [];
1863
+ if (first.id !== active.segmentId) {
1864
+ const head = lngLatOf(extractLines(first.geometry)[0]?.coordinates[0]);
1865
+ if (head) {
1866
+ markers.push({ color: first.color, icon: DRAFT_START_ICON, lngLat: head });
1867
+ }
1868
+ }
1869
+ if (last.id !== active.segmentId) {
1870
+ const tail = lngLatOf(extractLines(last.geometry).at(-1)?.coordinates.at(-1));
1871
+ if (tail) {
1872
+ markers.push({ color: last.color, icon: DRAFT_END_ICON, lngLat: tail });
1873
+ }
1874
+ }
1875
+ return markers;
1876
+ };
1877
+ var draftToPreviewRender = (glyphs, draft, active) => {
1878
+ const lines = [];
1879
+ for (const segment of draft.segments) {
1880
+ if (segment.id === active.segmentId) {
1881
+ continue;
1882
+ }
1883
+ const { chosen, other } = chosenAndOther(segment);
1884
+ for (const line of extractLines(chosen)) {
1885
+ lines.push({ color: segment.color, coordinates: line.coordinates, dashed: false });
1886
+ }
1887
+ if (other) {
1888
+ for (const line of extractLines(other)) {
1889
+ lines.push({ color: segment.color, coordinates: line.coordinates, dashed: true });
1890
+ }
1891
+ }
1892
+ }
1893
+ const waypoints = [];
1894
+ for (const waypoint of draft.waypoints) {
1895
+ if (waypoint.id === active.waypointId) {
1896
+ continue;
1897
+ }
1898
+ const lngLat = lngLatOf(extractPoint(waypoint.geojson)?.coordinates);
1899
+ if (!lngLat) {
1900
+ continue;
1901
+ }
1902
+ waypoints.push({
1903
+ // The draft carries no per-waypoint color, so fall back to the ONE default tint:
1904
+ // the same hex the tile builder coalesces to when a waypoint names none, so the
1905
+ // overlay marker and the tile marker for the same point are one colour. A null icon
1906
+ // falls back to the generic pin glyph, matching the persisted render.
1907
+ color: DEFAULT_WAYPOINT_COLOR,
1908
+ icon: waypoint.icon ?? glyphs.WAYPOINT_FALLBACK_ICON,
1909
+ lngLat
1910
+ });
1911
+ }
1912
+ waypoints.push(...endpointMarkers(draft, active));
1913
+ return { lines, waypoints };
1914
+ };
1915
+ var itineraryToPreviewRender = (glyphs, itinerary, active) => {
1916
+ const chain = (itinerary.segments ?? []).map((segment) => ({
1917
+ color: segment.color ?? DEFAULT_SEGMENT_COLOR,
1918
+ geometry: segment.geojson,
1919
+ id: segment.id
1920
+ }));
1921
+ const lines = [];
1922
+ for (const segment of chain) {
1923
+ if (segment.id === active.segmentId) {
1924
+ continue;
1925
+ }
1926
+ for (const line of extractLines(segment.geometry)) {
1927
+ lines.push({ color: segment.color, coordinates: line.coordinates, dashed: false });
1928
+ }
1929
+ }
1930
+ const waypoints = [];
1931
+ for (const waypoint of itinerary.waypoints ?? []) {
1932
+ if (waypoint.id === active.waypointId) {
1933
+ continue;
1934
+ }
1935
+ const lngLat = lngLatOf(extractPoint(waypoint.geojson)?.coordinates);
1936
+ if (!lngLat) {
1937
+ continue;
1938
+ }
1939
+ waypoints.push({
1940
+ // Its own colour, unlike a draft's: a persisted waypoint has one, and the fallback is the
1941
+ // hex the tile builder coalesces to so the overlay marker and the tile marker for the same
1942
+ // point are one colour.
1943
+ color: waypoint.color ?? DEFAULT_WAYPOINT_COLOR,
1944
+ icon: waypoint.icon ?? glyphs.WAYPOINT_FALLBACK_ICON,
1945
+ lngLat
1946
+ });
1947
+ }
1948
+ waypoints.push(...chainEndpointMarkers(chain, active));
1949
+ return { lines, waypoints };
1950
+ };
1951
+ var itineraryExclusions = (itinerary) => ({
1952
+ segmentIds: (itinerary.segments ?? []).map((segment) => segment.id),
1953
+ waypointIds: (itinerary.waypoints ?? []).map((waypoint) => waypoint.id)
1954
+ });
1955
+ var draftGeometries = (draft) => {
1956
+ const geometries = [];
1957
+ for (const segment of draft.segments) {
1958
+ geometries.push(chosenAndOther(segment).chosen);
1959
+ }
1960
+ for (const waypoint of draft.waypoints) {
1961
+ geometries.push(waypoint.geojson);
1962
+ }
1963
+ return geometries;
1964
+ };
1965
+ var zoneBandsToPreviewRender = (glyphs, preview) => {
1966
+ const color = zoneLevelColors[preview.level];
1967
+ const lines = [];
1968
+ for (const band of preview.bands) {
1969
+ for (const ring of band.geometry.coordinates) {
1970
+ lines.push({ color, coordinates: ring, dashed: false });
1971
+ }
1972
+ }
1973
+ const waypoints = preview.origin ? [
1974
+ {
1975
+ color,
1976
+ icon: glyphs.activityMarkerIcon(preview.activity) ?? glyphs.WAYPOINT_FALLBACK_ICON,
1977
+ lngLat: preview.origin
1978
+ }
1979
+ ] : [];
1980
+ return { lines, waypoints };
1981
+ };
1982
+
1983
+ // src/layers/rules/reachabilityIcon.ts
1984
+ var REACHABILITY_GLYPH = "reachability";
1985
+ var MIN_VALUE_KEY = "minValue";
1986
+ var MAX_VALUE_KEY = "maxValue";
1987
+ var overlayReadouts = {
1988
+ humidity: { format: formatHumidity, glyph: "datum-humidity" },
1989
+ snowdepth: { format: formatSnowDepth, glyph: "datum-snow-depth" },
1990
+ "snowfall-daily": { format: formatSnowfall, glyph: "datum-snowfall" },
1991
+ "snowfall-hourly": { format: formatSnowfall, glyph: "datum-snowfall" },
1992
+ "temperature-actual": { format: formatTemperature, glyph: "datum-temperature" },
1993
+ "temperature-perceived": { format: formatTemperature, glyph: "datum-temperature" },
1994
+ "temperature-soil": { format: formatTemperature, glyph: "datum-temperature" },
1995
+ visibility: { format: formatDistance, glyph: "datum-visibility" },
1996
+ wind: {
1997
+ format: (value, options) => formatSpeed(value, { ...options, pace: "per-time" }),
1998
+ glyph: "datum-wind"
1999
+ }
2000
+ };
2001
+ var overlayReadoutFor = (slug) => (
2002
+ // An own member alone: a slug is a free string, and `constructor` names what every object
2003
+ // inherits, which is no readout.
2004
+ slug && Object.hasOwn(overlayReadouts, slug) ? overlayReadouts[slug] ?? null : null
2005
+ );
2006
+ var extractOverlayBand = (features) => {
2007
+ for (const feature of features) {
2008
+ const min = feature[MIN_VALUE_KEY];
2009
+ const max = feature[MAX_VALUE_KEY];
2010
+ const hasMin = typeof min === "number" && Number.isFinite(min);
2011
+ const hasMax = typeof max === "number" && Number.isFinite(max);
2012
+ if (hasMin || hasMax) {
2013
+ return { max: hasMax ? max : null, min: hasMin ? min : null };
2014
+ }
2015
+ }
2016
+ return null;
2017
+ };
2018
+
2019
+ // src/map/rules/baseTerrain.ts
2020
+ var resolveBaseTerrain = (terrains, slug, variant, demUrl) => {
2021
+ const terrain = terrains.find((candidate) => candidate.slug === slug) ?? terrains[0];
2022
+ if (!terrain) {
2023
+ return null;
2024
+ }
2025
+ const tint = terrain.variants[variant] ?? terrain.variants.light ?? terrain.variants.dark;
2026
+ if (!tint) {
2027
+ return null;
2028
+ }
2029
+ const config = { styleUrl: tint.style.url };
2030
+ if (demUrl) {
2031
+ config.demUrl = demUrl;
2032
+ }
2033
+ return config;
2034
+ };
2035
+ var attributeOf = (hit, name) => {
2036
+ const value = hit.properties[name];
2037
+ return typeof value === "string" && value !== "" ? value : null;
2038
+ };
2039
+ var itineraryTileFeature = (hit) => {
2040
+ const waypointId = attributeOf(hit, "waypoint_id");
2041
+ if (waypointId !== null) {
2042
+ return { id: waypointId, kind: "waypoint" };
2043
+ }
2044
+ const segmentId = attributeOf(hit, "segment_id");
2045
+ return segmentId === null ? null : { id: segmentId, kind: "segment" };
2046
+ };
2047
+ var drawnByItinerary = (hit) => attributeOf(hit, "itinerary_id") !== null || itineraryTileFeature(hit) !== null;
2048
+ var itineraryLayerIdsOf = (sources) => {
2049
+ const lines = [];
2050
+ const points = [];
2051
+ const icons = [];
2052
+ for (const source of sources) {
2053
+ for (const layer of source.layers) {
2054
+ if (layer.source_layer === ITINERARY_LINE_SOURCE_LAYER) {
2055
+ lines.push(layer.id);
2056
+ } else if (layer.source_layer === ITINERARY_POINT_SOURCE_LAYER) {
2057
+ points.push(layer.id);
2058
+ }
2059
+ }
2060
+ const icon = roadAccessIconLayerIdOf(source);
2061
+ if (icon !== null) {
2062
+ icons.push(icon);
2063
+ }
2064
+ }
2065
+ return [...lines, ...points, ...icons];
2066
+ };
2067
+ var roadAccessStretchOf = (hit) => {
2068
+ if (hit.sourceLayer !== ITINERARY_RESTRICTION_SOURCE_LAYER) {
2069
+ return null;
2070
+ }
2071
+ const segmentId = attributeOf(hit, "segment_id");
2072
+ const itineraryId = attributeOf(hit, "itinerary_id");
2073
+ if (segmentId === null || itineraryId === null) {
2074
+ return null;
2075
+ }
2076
+ const stated = hit.properties.kind;
2077
+ const kind = ROAD_ACCESS_KINDS.find((known) => known === stated) ?? "restricted";
2078
+ return { itineraryId, kind, segmentId };
2079
+ };
2080
+ var itineraryClickTarget = (kind, hit, state, readOnly) => {
2081
+ const itinerary = state.activeItinerary;
2082
+ const feature = itineraryTileFeature(hit);
2083
+ const ofTheOpenItinerary = itinerary !== null && hit.properties.itinerary_id === itinerary.id;
2084
+ if (kind !== "itinerary" && !readOnly && !ofTheOpenItinerary) {
2085
+ return null;
2086
+ }
2087
+ if (kind === "roadAccess") {
2088
+ const stretch = roadAccessStretchOf(hit);
2089
+ return stretch === null ? null : { kind, stretch };
2090
+ }
2091
+ if (kind === "segment") {
2092
+ if (feature?.kind !== "segment") {
2093
+ return null;
2094
+ }
2095
+ const segmentId = feature.id;
2096
+ const editable = !readOnly && itinerary !== null && itinerary.segments.some((segment) => segment.id === segmentId) && hit.sourceLayer !== ITINERARY_RESTRICTION_SOURCE_LAYER && showingDraftSurface(state) === null && !state.agentDriving && state.segmentSplitPick === null && state.collabByResource[collabResourceKey({ id: itinerary.id, kind: "itineraries" })]?.locks[collabLockKey("segment", segmentId)] === void 0;
2097
+ return { edit: editable, kind, segmentId };
2098
+ }
2099
+ if (kind === "waypoint") {
2100
+ return feature?.kind === "waypoint" ? {
2101
+ details: ofTheOpenItinerary,
2102
+ kind,
2103
+ waypointId: feature.id
2104
+ } : null;
2105
+ }
2106
+ const itineraryId = hit.properties.itinerary_id;
2107
+ if (readOnly || typeof itineraryId !== "string" || itineraryId.length === 0) {
2108
+ return null;
2109
+ }
2110
+ return itinerary?.id === itineraryId ? null : { itineraryId, kind };
2111
+ };
2112
+ var zoneClickTarget = (hit, activeZone, userId, writableOrganizationIds) => {
2113
+ const zoneId = hit.properties.id ?? hit.id;
2114
+ if (typeof zoneId !== "string" || !hasUuidShape(zoneId)) {
2115
+ return null;
2116
+ }
2117
+ if (activeZone?.id === zoneId) {
2118
+ const geometry = activeZone.geojson.geometry;
2119
+ const editable2 = canEditOwnedResource(
2120
+ { createdById: activeZone.created_by.id, organizationId: activeZone.organization_id },
2121
+ userId,
2122
+ writableOrganizationIds
2123
+ );
2124
+ if (!editable2 || geometry.type !== "Polygon" || activeZone.source) {
2125
+ return null;
2126
+ }
2127
+ return {
2128
+ input: {
2129
+ intent: "edit",
2130
+ level: activeZone.level,
2131
+ mode: activeZone.mode,
2132
+ seedGeometry: geometry,
2133
+ zoneId
2134
+ },
2135
+ kind: "reshape"
2136
+ };
2137
+ }
2138
+ const createdBy = hit.properties.created_by;
2139
+ const organizationId = hit.properties.organization_id;
2140
+ const editable = canEditOwnedResource(
2141
+ {
2142
+ createdById: typeof createdBy === "string" ? createdBy : null,
2143
+ organizationId: typeof organizationId === "string" ? organizationId : null
2144
+ },
2145
+ userId,
2146
+ writableOrganizationIds
2147
+ );
2148
+ return { kind: editable ? "edit" : "view", zoneId };
2149
+ };
2150
+ var mapInteractionScope = (state) => {
2151
+ if (state.segmentEditSession !== null || state.waypointEditSession !== null || state.zoneEditSession !== null) {
2152
+ return "locked";
2153
+ }
2154
+ if (state.activeZone !== null) {
2155
+ return "zone";
2156
+ }
2157
+ return state.activeItinerary === null ? "free" : "itinerary";
2158
+ };
2159
+
2160
+ // src/map/rules/contextMenuReadout.ts
2161
+ var READOUT_KEYS = ["elevation", "slope", "aspect", "steepness_class"];
2162
+ var contextMenuReadout = (features) => {
2163
+ const rows = [];
2164
+ for (const key of READOUT_KEYS) {
2165
+ const value = features.find((feature) => feature[key] != null)?.[key];
2166
+ if (value != null) {
2167
+ rows.push({ key, value });
2168
+ }
2169
+ }
2170
+ return rows;
2171
+ };
2172
+ var SUGGESTION_PREVIEW_COLOR = "#228be6";
2173
+ var SUGGESTION_START_ICON = ITINERARY_ENDPOINT_ICONS[0];
2174
+ var SUGGESTION_END_ICON = ITINERARY_ENDPOINT_ICONS[1];
2175
+ var suggestionPreviewRender = (inputs) => {
2176
+ const { candidates, end, routeType, selectedSeed, start } = inputs;
2177
+ const candidate = selectedSeed === null ? null : candidates.find((entry) => entry.seed === selectedSeed) ?? null;
2178
+ const lines = candidate ? extractLines(candidate.geometry).map((line) => ({
2179
+ color: candidate.color,
2180
+ coordinates: line.coordinates,
2181
+ dashed: false
2182
+ })) : [];
2183
+ const waypoints = [];
2184
+ if (start) {
2185
+ waypoints.push({ color: SUGGESTION_PREVIEW_COLOR, icon: SUGGESTION_START_ICON, lngLat: start });
2186
+ }
2187
+ if (routeType === "point_to_point" && end) {
2188
+ waypoints.push({ color: SUGGESTION_PREVIEW_COLOR, icon: SUGGESTION_END_ICON, lngLat: end });
2189
+ }
2190
+ return { lines, waypoints };
2191
+ };
2192
+ var previewProjection = (glyphs, input) => {
2193
+ const { activeItinerary, draft, suggestion, tiled, zonePreview } = input;
2194
+ const editing = { segmentId: input.editSegmentId, waypointId: input.editWaypointId };
2195
+ if (zonePreview && zonePreview.bands.length > 0) {
2196
+ return {
2197
+ draft: null,
2198
+ exclusions: null,
2199
+ render: zoneBandsToPreviewRender(glyphs, zonePreview)
2200
+ };
2201
+ }
2202
+ if (draft && (draft.segments.length > 0 || draft.waypoints.length > 0)) {
2203
+ return { draft, exclusions: null, render: draftToPreviewRender(glyphs, draft, editing) };
2204
+ }
2205
+ if (suggestion) {
2206
+ const render = suggestionPreviewRender(suggestion);
2207
+ if (render.lines.length > 0 || render.waypoints.length > 0) {
2208
+ return { draft: null, exclusions: null, render };
2209
+ }
2210
+ }
2211
+ if (!tiled && activeItinerary) {
2212
+ return {
2213
+ draft: null,
2214
+ exclusions: itineraryExclusions(activeItinerary),
2215
+ render: itineraryToPreviewRender(glyphs, activeItinerary, editing)
2216
+ };
2217
+ }
2218
+ return { draft: null, exclusions: null, render: null };
2219
+ };
2220
+ var peerDraftGhosts = (input) => {
2221
+ const present = new Set(input.presentPeerIds);
2222
+ const ghosts = [];
2223
+ for (const [key, draft] of Object.entries(input.drafts)) {
2224
+ if (!present.has(draft.userId)) {
2225
+ continue;
2226
+ }
2227
+ const color = collabPeerColor(draft.userId);
2228
+ const label = input.resolveName?.(draft.userId) ?? peerDraftInitials(draft.userId);
2229
+ if (draft.kind === "segment") {
2230
+ if (draft.segment.id === input.localSegmentEditId) {
2231
+ continue;
2232
+ }
2233
+ const line = extractLines(draft.segment.geojson).find(
2234
+ (candidate) => candidate.coordinates.length >= 2
2235
+ );
2236
+ if (!line) {
2237
+ continue;
2238
+ }
2239
+ ghosts.push({
2240
+ color,
2241
+ entity: { id: draft.segment.id, kind: "segment" },
2242
+ geometry: line,
2243
+ key,
2244
+ label
2245
+ });
2246
+ continue;
2247
+ }
2248
+ const zoneId = key.slice(key.indexOf("/") + 1);
2249
+ if (zoneId === input.localZoneEditId) {
2250
+ continue;
2251
+ }
2252
+ ghosts.push({
2253
+ color,
2254
+ entity: { id: zoneId, kind: "zone" },
2255
+ geometry: draft.zone,
2256
+ key,
2257
+ label
2258
+ });
2259
+ }
2260
+ return ghosts;
2261
+ };
2262
+ var permittedEnrichmentOverlays = (layers, activeEnrichments, overlaysEntitled, poisEntitled) => [...new Set(activeEnrichments)].flatMap((slug) => {
2263
+ if (!(slug === POIS_OVERLAY_SLUG ? poisEntitled : overlaysEntitled)) {
2264
+ return [];
2265
+ }
2266
+ const overlay = findOverlay({ overlays: layers.overlays ?? [] }, slug);
2267
+ return overlay === null ? [] : [overlay];
2268
+ });
2269
+ var permittedClassicOverlay = (layers, activeOverlay, overlaysEntitled) => overlaysEntitled && activeOverlay !== null ? findOverlay({ overlays: layers.overlays ?? [] }, activeOverlay) : null;
2270
+ var poiGroupByLayerKey = new Map(
2271
+ POI_GROUPS.flatMap((group) => group.layerKeys.map((key) => [key, group.id]))
2272
+ );
2273
+ var poiLayerVisibility = (layers, activePoiGroups) => {
2274
+ const overlay = findOverlay({ overlays: layers.overlays ?? [] }, POIS_OVERLAY_SLUG);
2275
+ if (!overlay) {
2276
+ return [];
2277
+ }
2278
+ const active = new Set(activePoiGroups);
2279
+ return overlay.sources.flatMap(
2280
+ (source) => source.layers.map((layer) => {
2281
+ const group = poiGroupByLayerKey.get(layer.key);
2282
+ return { layerId: layer.id, visible: group === void 0 || active.has(group) };
2283
+ })
2284
+ );
2285
+ };
2286
+ var ZONE_TIME_REFERENCE_INTERVAL_MS = /* @__PURE__ */ convertDuration(
2287
+ 1,
2288
+ "minute",
2289
+ "millisecond"
2290
+ );
2291
+ var zoneTimeReferenceSeconds = (overlayTimestamp, nowMs) => {
2292
+ const pinnedMs = overlayTimestamp ? new Date(overlayTimestamp).getTime() : Number.NaN;
2293
+ if (!Number.isNaN(pinnedMs)) {
2294
+ return Math.floor(convertDuration(pinnedMs, "millisecond", "second"));
2295
+ }
2296
+ const intervalStartMs = Math.floor(nowMs / ZONE_TIME_REFERENCE_INTERVAL_MS) * ZONE_TIME_REFERENCE_INTERVAL_MS;
2297
+ return convertDuration(intervalStartMs, "millisecond", "second");
2298
+ };
2299
+ var activeSegmentLines = (itinerary) => (itinerary?.segments ?? []).flatMap(
2300
+ (segment) => extractLines(segment.geojson).map((line) => line.coordinates)
2301
+ );
2302
+ var resolveDemUrl = (layers, demUrl) => demUrl || layers?.elevation?.url || void 0;
2303
+ var SEARCH_REFUSED_NAME = "SearchRefusedError";
2304
+ var SearchRefusedError = class extends MountayaElementsError {
2305
+ name = SEARCH_REFUSED_NAME;
2306
+ /** The refusal's machine-readable code, or undefined for a refusal that carried none. */
2307
+ code;
2308
+ /**
2309
+ * The server's own sentence for the refusal, already in the reader's language, or undefined
2310
+ * where the refusal carried none.
2311
+ */
2312
+ detail;
2313
+ constructor(refusal) {
2314
+ super(refusal.error);
2315
+ this.code = refusal.code;
2316
+ this.detail = refusal.detail;
2317
+ }
2318
+ };
2319
+ var targetFlags = {
2320
+ collections: true,
2321
+ itineraries: true,
2322
+ places: true,
2323
+ pois: true,
2324
+ ways: true,
2325
+ zones: true
2326
+ };
2327
+ var isTargetName = (name) => Object.hasOwn(targetFlags, name);
2328
+ var enabledTarget = (targets) => Object.keys(targetFlags).find(
2329
+ (name) => isTargetName(name) && targets[name] === true
2330
+ );
2331
+ var createSearchFetch = (dispatch) => async (input) => {
2332
+ const target = enabledTarget(input.targets);
2333
+ if (target === void 0) {
2334
+ throw new MountayaElementsError("no search target requested");
2335
+ }
2336
+ const result = await dispatch("studio.search.run", {
2337
+ // The wire types the coordinates as an open number[] and the tool takes fixed tuples, so a
2338
+ // pair of the wrong length or with a non-finite member is dropped here and the round runs
2339
+ // unscoped: the boundary would otherwise reject a shape the caller cannot fix.
2340
+ bbox: boundsTuple(input.bbox),
2341
+ focus: pointTuple(input.focus),
2342
+ language: input.language ?? void 0,
2343
+ limit: input.limit ?? void 0,
2344
+ query: input.query,
2345
+ target
2346
+ });
2347
+ if (!result.ok) {
2348
+ throw new SearchRefusedError(result);
2349
+ }
2350
+ return result.data;
2351
+ };
2352
+ var buildSegmentChainMerges = (segments, lockedSegmentIds = /* @__PURE__ */ new Set()) => {
2353
+ const byAbsorber = /* @__PURE__ */ new Map();
2354
+ const byFolded = /* @__PURE__ */ new Map();
2355
+ for (let index = 1; index < segments.length; index += 1) {
2356
+ const previous = segments[index - 1];
2357
+ const segment = segments[index];
2358
+ if (!previous || !segment) {
2359
+ continue;
2360
+ }
2361
+ let disabledReason = null;
2362
+ if (previous.mode !== segment.mode) {
2363
+ disabledReason = "engine";
2364
+ } else if (previous.group_id !== segment.group_id) {
2365
+ disabledReason = "group";
2366
+ } else if (exceedsMergeViaCeiling(previous, segment)) {
2367
+ disabledReason = "waypointsMax";
2368
+ } else if (lockedSegmentIds.has(previous.id) || lockedSegmentIds.has(segment.id)) {
2369
+ disabledReason = "locked";
2370
+ }
2371
+ const merge = {
2372
+ disabledReason,
2373
+ intoSegmentId: segment.id,
2374
+ segmentId: previous.id
2375
+ };
2376
+ byFolded.set(previous.id, merge);
2377
+ byAbsorber.set(segment.id, merge);
2378
+ }
2379
+ return { byAbsorber, byFolded };
2380
+ };
2381
+ var segmentChainEnds = (segments) => ({
2382
+ committedIds: new Set(segments.map((segment) => segment.id)),
2383
+ firstCommittedId: segments[0]?.id ?? null,
2384
+ lastCommittedId: segments.at(-1)?.id ?? null
2385
+ });
2386
+ var buildSegmentGroupRuns = (segments, groups) => {
2387
+ const byId = new Map(groups.map((group) => [group.id, group]));
2388
+ const memberCounts = /* @__PURE__ */ new Map();
2389
+ for (const segment of segments) {
2390
+ if (segment.group_id !== null) {
2391
+ memberCounts.set(segment.group_id, (memberCounts.get(segment.group_id) ?? 0) + 1);
2392
+ }
2393
+ }
2394
+ const groupOf = (segment) => segment.group_id === null ? null : byId.get(segment.group_id) ?? null;
2395
+ const runs = /* @__PURE__ */ new Map();
2396
+ segments.forEach((segment, index) => {
2397
+ const group = groupOf(segment);
2398
+ const previous = segments[index - 1];
2399
+ const next = segments[index + 1];
2400
+ runs.set(segment.id, {
2401
+ group,
2402
+ hasFreeNeighbour: previous !== void 0 && groupOf(previous) === null || next !== void 0 && groupOf(next) === null,
2403
+ isFirst: group === null ? false : previous?.group_id !== group.id,
2404
+ isLast: group === null ? false : next?.group_id !== group.id,
2405
+ memberCount: group === null ? 0 : memberCounts.get(group.id) ?? 0
2406
+ });
2407
+ });
2408
+ return runs;
2409
+ };
2410
+ var segmentGroupDissolvesOnLeave = (memberCount) => memberCount - 1 < SEGMENT_GROUP_MIN_MEMBERS;
2411
+
2412
+ // src/segments/rules/commit.ts
2413
+ var buildSegmentEditCommitInput = ({
2414
+ coordinates,
2415
+ draftColor,
2416
+ draftName,
2417
+ itineraryId,
2418
+ mode,
2419
+ segmentId
2420
+ }) => {
2421
+ if (draftName !== null) {
2422
+ return mode === "directions" ? {
2423
+ color: draftColor ?? void 0,
2424
+ itineraryId,
2425
+ mode: "directions",
2426
+ name: draftName,
2427
+ vias: coordinates
2428
+ } : {
2429
+ color: draftColor ?? void 0,
2430
+ itineraryId,
2431
+ line: coordinates,
2432
+ mode: "linestring",
2433
+ name: draftName
2434
+ };
2435
+ }
2436
+ return mode === "directions" ? { itineraryId, mode: "directions", segmentId, vias: coordinates } : { itineraryId, line: coordinates, mode: "linestring", segmentId };
2437
+ };
2438
+ var draftSeed = (segment) => {
2439
+ if (segment.mode === "directions") {
2440
+ if (!segment.directions) {
2441
+ return null;
2442
+ }
2443
+ const vias = extractVias(segment.directions.geojson);
2444
+ const rawSeed = vias.length > 0 ? vias : simplifyToVias(segmentLineCoordinates(segment.directions.geojson), DIRECTIONS_VIA_MAX);
2445
+ return rawSeed.length > 0 ? seedFromCoordinates(rawSeed) : null;
2446
+ }
2447
+ const line = segmentLineCoordinates(segment.linestring.geojson);
2448
+ return line.length > 0 ? seedFromCoordinates(line) : null;
2449
+ };
2450
+ var beginDraftSegmentEdit = (dispatch, segment, anchor, activitySlug) => {
2451
+ const mode = segment.mode;
2452
+ const seed = draftSeed(segment);
2453
+ if (!seed) {
2454
+ return Promise.resolve(null);
2455
+ }
2456
+ const previousPin = anchor.previousEnd ? clampSeedPoint(anchor.previousEnd) : null;
2457
+ const pinnedStart = anchor.isFirst ? void 0 : previousPin ?? seed.pinnedStart;
2458
+ return dispatch("studio.itinerary.segment.editBegin", {
2459
+ activitySlug: activitySlug ?? void 0,
2460
+ color: hexColorSchema.safeParse(segment.color).success ? segment.color : DEFAULT_SEGMENT_COLOR,
2461
+ mode,
2462
+ pinnedStart,
2463
+ seedVias: seed.seedVias,
2464
+ segmentId: segment.id
2465
+ });
2466
+ };
2467
+ var heldRun = (segments, groupId) => segments.filter((segment) => segment.group_id === groupId).map((segment) => segment.id);
2468
+ var segmentGroupForm = (group, segments) => ({
2469
+ color: group.color,
2470
+ name: group.name,
2471
+ opened: { color: group.color, groupId: group.id, name: group.name, speed: group.speed },
2472
+ segmentIds: heldRun(segments, group.id),
2473
+ speed: group.speed
2474
+ });
2475
+ var formRefusal = (form) => {
2476
+ if (form.segmentIds.length < SEGMENT_GROUP_MIN_MEMBERS) {
2477
+ return "minMembers";
2478
+ }
2479
+ return displayNameSchema.safeParse(form.name).success ? null : "nameError";
2480
+ };
2481
+ var sameRun = (left, right) => left.length === right.length && left.every((id, index) => id === right[index]);
2482
+ var segmentGroupSavePlan = (itineraryId, segments, form) => {
2483
+ const name = form.name.trim();
2484
+ const refusal = formRefusal(form);
2485
+ const { opened } = form;
2486
+ if (opened === null) {
2487
+ const create = {
2488
+ input: {
2489
+ color: form.color,
2490
+ itineraryId,
2491
+ name,
2492
+ segmentIds: [...form.segmentIds],
2493
+ speed: form.speed
2494
+ },
2495
+ name: "studio.itinerary.group.create"
2496
+ };
2497
+ return { changed: true, refusal, steps: refusal === null ? [create] : [] };
2498
+ }
2499
+ const subject = { groupId: opened.groupId, itineraryId };
2500
+ const runMoved = !sameRun(heldRun(segments, opened.groupId), form.segmentIds);
2501
+ const display = {
2502
+ ...form.color === opened.color ? {} : { color: form.color },
2503
+ ...name === opened.name.trim() ? {} : { name },
2504
+ ...form.speed === opened.speed ? {} : { speed: form.speed }
2505
+ };
2506
+ const displayMoved = Object.keys(display).length > 0;
2507
+ const changed = runMoved || displayMoved;
2508
+ if (refusal !== null) {
2509
+ return { changed, refusal, steps: [] };
2510
+ }
2511
+ const steps = [];
2512
+ if (runMoved) {
2513
+ steps.push({
2514
+ input: { ...subject, segmentIds: [...form.segmentIds] },
2515
+ name: "studio.itinerary.group.setRange"
2516
+ });
2517
+ }
2518
+ if (displayMoved) {
2519
+ steps.push({ input: { ...display, ...subject }, name: "studio.itinerary.group.update" });
2520
+ }
2521
+ return { changed, refusal, steps };
2522
+ };
2523
+
2524
+ // src/share/rules/targets.ts
2525
+ var buildShareText = (name, meta) => meta ? `${name} \xB7 ${meta}` : name;
2526
+ var SOCIAL_SHARE_TARGETS = [
2527
+ {
2528
+ buildHref: (url, text2) => `https://wa.me/?text=${encodeURIComponent(`${text2} ${url}`)}`,
2529
+ id: "whatsapp"
2530
+ },
2531
+ {
2532
+ buildHref: (url, text2) => `https://twitter.com/intent/tweet?text=${encodeURIComponent(text2)}&url=${encodeURIComponent(url)}`,
2533
+ id: "x"
2534
+ },
2535
+ {
2536
+ buildHref: (url, text2) => `https://t.me/share/url?url=${encodeURIComponent(url)}&text=${encodeURIComponent(text2)}`,
2537
+ id: "telegram"
2538
+ },
2539
+ {
2540
+ buildHref: (url) => `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`,
2541
+ id: "facebook"
2542
+ },
2543
+ {
2544
+ buildHref: (url, text2) => `https://www.reddit.com/submit?url=${encodeURIComponent(url)}&title=${encodeURIComponent(text2)}`,
2545
+ id: "reddit"
2546
+ },
2547
+ {
2548
+ buildHref: (url) => `https://www.linkedin.com/sharing/share-offsite/?url=${encodeURIComponent(url)}`,
2549
+ id: "linkedin"
2550
+ },
2551
+ {
2552
+ buildHref: (url, text2) => `mailto:?subject=${encodeURIComponent(text2)}&body=${encodeURIComponent(url)}`,
2553
+ id: "email"
2554
+ }
2555
+ ];
2556
+
2557
+ // src/share/rules/viewConfig.ts
2558
+ var fallbackLanguage = resolveOrgEmbedDefaults(void 0).preferredLanguage;
2559
+ var buildShareViewConfig = (target, language) => {
2560
+ const known = languageSchema.safeParse(language);
2561
+ return {
2562
+ activity: null,
2563
+ collectionId: target.kind === "collection" ? target.id : null,
2564
+ embedded: true,
2565
+ enrichments: [],
2566
+ itineraryId: target.kind === "itinerary" ? target.id : null,
2567
+ overlay: null,
2568
+ preferredLanguage: known.success ? known.data : fallbackLanguage,
2569
+ preferredTheme: "light",
2570
+ preferredUnitLength: "metric",
2571
+ preferredUnitPace: "per-time",
2572
+ preferredUnitSlope: "degrees",
2573
+ preferredUnitTemperature: "celsius",
2574
+ segmentsColor: "",
2575
+ terrain: DEFAULT_TERRAIN,
2576
+ terrainVariant: "light",
2577
+ // A share link always warns where its route's access is restricted: no organization
2578
+ // default reaches a share view to turn it off.
2579
+ withAccessRestrictions: true,
2580
+ // Left to the server, which resolves the share link's organization's own defaults.
2581
+ withCollectionItineraries: null,
2582
+ withCollectionZones: null,
2583
+ withDirectionsControl: false,
2584
+ withDownloadControl: true,
2585
+ withNavigationControl: true,
2586
+ withOverlays: [],
2587
+ withOverlaysControl: true,
2588
+ withPreferencesControl: true,
2589
+ withProfileAnalysis: true,
2590
+ withProfileCharacteristics: true,
2591
+ withProfileElevation: true,
2592
+ withProfilePaceControl: true,
2593
+ withStreetviewControl: false,
2594
+ withTerrains: []
2595
+ };
2596
+ };
2597
+ var previewRefreshDisposition = (status, plan) => {
2598
+ if (status === null || status.kind === "recording") {
2599
+ return { kind: "keep" };
2600
+ }
2601
+ if (status.kind === "previewing") {
2602
+ return { kind: "restart" };
2603
+ }
2604
+ return { fraction: representativeStillFraction(plan), kind: "park" };
2605
+ };
2606
+ var videoRouteSpans = (itinerary, segmentId) => {
2607
+ const segments = segmentsForSelection(itinerary, segmentId);
2608
+ const stretches = new Map(
2609
+ buildInfoBands(segments, (segment) => [
2610
+ { from_index: 0, to_index: Number.MAX_SAFE_INTEGER, value: segment }
2611
+ ]).map((band) => [band.value, band])
2612
+ );
2613
+ const spans = [];
2614
+ let startKm = 0;
2615
+ for (const segment of segments) {
2616
+ const endKm = stretches.get(segment)?.endKm ?? startKm;
2617
+ spans.push({
2618
+ endKm,
2619
+ name: segment.name,
2620
+ speed: segment.speed === null ? null : convertSpeed(segment.speed, "kilometer-per-hour", "meter-per-second"),
2621
+ startKm
2622
+ });
2623
+ startKm = endKm;
2624
+ }
2625
+ return spans;
2626
+ };
2627
+
2628
+ // src/video/rules/profileSource.ts
2629
+ var videoProfileSource = (itinerary, segmentId) => {
2630
+ const segments = segmentsForSelection(itinerary, segmentId);
2631
+ return {
2632
+ elevationPoints: buildElevationPoints(segments),
2633
+ segmentSpans: videoRouteSpans(itinerary, segmentId),
2634
+ slopeBands: buildInfoBands(segments, (segment) => segment.slope_info),
2635
+ surfaceBands: buildInfoBands(segments, (segment) => segment.surface_info),
2636
+ waytypeBands: buildInfoBands(segments, (segment) => segment.way_type_info)
2637
+ };
2638
+ };
2639
+
2640
+ // src/video/rules/shotDefaults.ts
2641
+ var DEFAULT_SHOT_PITCH_DEG = 60;
2642
+ var DEFAULT_SHOT_ZOOM = 13;
2643
+ var DEFAULT_HOLD_MS = 2e3;
2644
+ var PREVIEW_PLAN_REFRESH_DEBOUNCE_MS = 250;
2645
+
2646
+ // src/video/rules/stepOrder.ts
2647
+ var VIDEO_STEP_ORDER = ["format", "camera", "profile", "review"];
2648
+ var studioCapabilitySchema = z4.enum(["authenticated", "editor", "embedding", "share"]);
2649
+ var studioConfigSchema = z4.object({
2650
+ /** The base terrain the studio opens on, by slug. */
2651
+ terrain: z4.string(),
2652
+ /** Which variant of the base terrain draws, light or dark. */
2653
+ terrainVariant: terrainVariantSchema,
2654
+ /** Whether the directions control shows. */
2655
+ withDirectionsControl: z4.boolean(),
2656
+ /** Whether the download control shows. */
2657
+ withDownloadControl: z4.boolean(),
2658
+ /**
2659
+ * Whether the layers control shows: the button that opens the panel switching terrains and
2660
+ * overlays. Its own gate, never the time slider's: an embed answers it from the overlays its
2661
+ * cap leaves and the terrains it names (`layersControlOffered`).
2662
+ */
2663
+ withLayersControl: z4.boolean(),
2664
+ /** Whether the navigation control shows. */
2665
+ withNavigationControl: z4.boolean(),
2666
+ /** The overlays the studio may switch to, by slug; empty offers every one. */
2667
+ withOverlays: z4.array(z4.string()),
2668
+ /**
2669
+ * Whether the overlay time slider shows, letting a viewer move the overlays backwards or
2670
+ * forwards in time. It neither offers nor hides the layers control.
2671
+ */
2672
+ withOverlaysControl: z4.boolean(),
2673
+ /** Whether the units and language control shows. */
2674
+ withPreferencesControl: z4.boolean(),
2675
+ /** Whether the Street View control shows. */
2676
+ withStreetviewControl: z4.boolean(),
2677
+ /** The terrains the studio may switch between, by slug; empty offers every one. */
2678
+ withTerrains: z4.array(z4.string())
2679
+ });
2680
+ var defaultStudioConfig = studioConfigSchema.parse({
2681
+ terrain: DEFAULT_TERRAIN,
2682
+ terrainVariant: "light",
2683
+ withDirectionsControl: true,
2684
+ withDownloadControl: true,
2685
+ withLayersControl: true,
2686
+ withNavigationControl: true,
2687
+ withOverlays: [],
2688
+ withOverlaysControl: true,
2689
+ withPreferencesControl: true,
2690
+ withStreetviewControl: true,
2691
+ withTerrains: []
2692
+ });
2693
+ var embedBaseline = resolveOrgEmbedDefaults(void 0);
2694
+ var memberOr = (schema, value, fallback) => {
2695
+ const parsed = schema.safeParse(value);
2696
+ return parsed.success ? parsed.data : fallback;
2697
+ };
2698
+ var listOr = (schema, value, fallback) => {
2699
+ const parsed = schema.safeParse(value);
2700
+ return parsed.success ? parsed.data : [...fallback];
2701
+ };
2702
+ var embedConfigToStudioConfig = (embedConfig, cap) => {
2703
+ const { shape } = studioConfigSchema;
2704
+ const withOverlays = listOr(
2705
+ shape.withOverlays,
2706
+ embedConfig.withOverlays,
2707
+ embedBaseline.withOverlays
2708
+ );
2709
+ const withTerrains = listOr(
2710
+ shape.withTerrains,
2711
+ embedConfig.withTerrains,
2712
+ embedBaseline.withTerrains
2713
+ );
2714
+ return {
2715
+ terrain: memberOr(shape.terrain, embedConfig.terrain, embedBaseline.terrain),
2716
+ terrainVariant: memberOr(
2717
+ shape.terrainVariant,
2718
+ embedConfig.terrainVariant,
2719
+ embedBaseline.terrainVariant
2720
+ ),
2721
+ withDirectionsControl: memberOr(
2722
+ shape.withDirectionsControl,
2723
+ embedConfig.withDirectionsControl,
2724
+ embedBaseline.withDirectionsControl
2725
+ ),
2726
+ withDownloadControl: memberOr(
2727
+ shape.withDownloadControl,
2728
+ embedConfig.withDownloadControl,
2729
+ embedBaseline.withDownloadControl
2730
+ ),
2731
+ withLayersControl: layersControlOffered({ withOverlays, withTerrains }, cap),
2732
+ withNavigationControl: memberOr(
2733
+ shape.withNavigationControl,
2734
+ embedConfig.withNavigationControl,
2735
+ embedBaseline.withNavigationControl
2736
+ ),
2737
+ withOverlays,
2738
+ withOverlaysControl: memberOr(
2739
+ shape.withOverlaysControl,
2740
+ embedConfig.withOverlaysControl,
2741
+ embedBaseline.withOverlaysControl
2742
+ ),
2743
+ withPreferencesControl: memberOr(
2744
+ shape.withPreferencesControl,
2745
+ embedConfig.withPreferencesControl,
2746
+ embedBaseline.withPreferencesControl
2747
+ ),
2748
+ withStreetviewControl: memberOr(
2749
+ shape.withStreetviewControl,
2750
+ embedConfig.withStreetviewControl,
2751
+ embedBaseline.withStreetviewControl
2752
+ ),
2753
+ withTerrains
2754
+ };
2755
+ };
2756
+ var clampStudioConfigToSafetyRules = (config, safetyRules) => {
2757
+ if (safetyRules === void 0) {
2758
+ return config;
2759
+ }
2760
+ let next = config;
2761
+ if (next.withOverlaysControl && safetyRules.with_overlays_control === false) {
2762
+ next = { ...next, withOverlaysControl: false };
2763
+ }
2764
+ const cap = safetyRules.with_overlays;
2765
+ if (cap === void 0) {
2766
+ return next;
2767
+ }
2768
+ if (allowlistMode(cap, "cap") === "specific") {
2769
+ const unrestricted = allowlistUnrestricted(next.withOverlays);
2770
+ const offered = unrestricted ? [...cap] : next.withOverlays.filter((slug) => cap.includes(slug));
2771
+ if (offered.length > 0 && (unrestricted || offered.length !== next.withOverlays.length)) {
2772
+ next = { ...next, withOverlays: offered };
2773
+ }
2774
+ }
2775
+ if (next.withLayersControl && !layersControlOffered(next, cap)) {
2776
+ next = { ...next, withLayersControl: false };
2777
+ }
2778
+ return next;
2779
+ };
2780
+
2781
+ // src/viewer/rules/platformViewer.ts
2782
+ var createPlatformViewer = ({
2783
+ isPersonalScope = defaultStudioScope.isPersonalScope,
2784
+ memberships,
2785
+ personalSpace,
2786
+ scope,
2787
+ viewer
2788
+ }) => {
2789
+ const scopeOf = (organizationId) => organizationId === void 0 || organizationId === "" || isPersonalScope(organizationId) ? null : organizationId;
2790
+ const answerFor = (organizationId) => organizationId === null ? personalSpace?.read() : memberships.read()?.find((membership) => membership.organization_id === organizationId);
2791
+ return {
2792
+ getItineraryLimit: (organizationId) => answerFor(scopeOf(organizationId))?.itinerary_limit ?? null,
2793
+ getPreferences: () => viewer.getPreferences(),
2794
+ getUserId: () => viewer.getUserId(),
2795
+ hasEntitlement: (entitlement) => answerFor(scopeOf(scope.read()))?.studio_entitlements.includes(entitlement) ?? false,
2796
+ setPreferences: (partial) => viewer.setPreferences(partial),
2797
+ subscribe: (onChange) => {
2798
+ let inView = scopeOf(scope.read());
2799
+ const releases = [
2800
+ viewer.subscribe(onChange),
2801
+ memberships.subscribe(onChange),
2802
+ personalSpace?.subscribe(onChange),
2803
+ scope.subscribe(() => {
2804
+ const next = scopeOf(scope.read());
2805
+ if (next !== inView) {
2806
+ inView = next;
2807
+ onChange();
2808
+ }
2809
+ })
2810
+ ];
2811
+ return () => {
2812
+ for (const release of releases) {
2813
+ release?.();
2814
+ }
2815
+ };
2816
+ }
2817
+ };
2818
+ };
2819
+
2820
+ // src/viewer/rules/url.ts
2821
+ var nothingMirrored = {};
2822
+ var releaseNothing = () => {
2823
+ };
2824
+ var inertStudioUrlSeam = {
2825
+ read: () => nothingMirrored,
2826
+ readOnce: () => nothingMirrored,
2827
+ subscribe: () => releaseNothing,
2828
+ write: () => {
2829
+ }
2830
+ };
2831
+
2832
+ // src/viewer/rules/viewerSeam.ts
2833
+ var sameViewerValues = (a, b) => {
2834
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])) {
2835
+ if (Reflect.get(a, key) !== Reflect.get(b, key)) {
2836
+ return false;
2837
+ }
2838
+ }
2839
+ return true;
2840
+ };
2841
+ var inertViewer = /* @__PURE__ */ createStaticViewer();
2842
+ var mintRowId = (ids = studioSeamAbsences.ids) => ids.next();
2843
+ var shownMinutes = (seconds) => seconds == null ? null : Math.round(seconds / SECONDS_PER_MINUTE);
2844
+ var storedSeconds = (minutes) => minutes === null ? null : Math.round(minutes) * SECONDS_PER_MINUTE;
2845
+ var stopSeconds = (draft) => {
2846
+ const stored = draft.storedStopSeconds;
2847
+ return stored !== void 0 && shownMinutes(stored) === draft.stopMinutes ? stored : storedSeconds(draft.stopMinutes);
2848
+ };
2849
+ var cutoffInstant = (cutoffAt) => {
2850
+ if (cutoffAt === null) {
2851
+ return null;
2852
+ }
2853
+ if (Number.isNaN(cutoffAt.getTime())) {
2854
+ throw new MountayaElementsError(
2855
+ "patch waypoint details: the cut-off is no valid date. Set it to a date and a time, or clear it."
2856
+ );
2857
+ }
2858
+ return cutoffAt.toISOString();
2859
+ };
2860
+ var text = (value) => value ?? "";
2861
+ var orNull = (value) => {
2862
+ const trimmed = value.trim();
2863
+ return trimmed === "" ? null : trimmed;
2864
+ };
2865
+ var draftFromWaypoint = (waypoint) => ({
2866
+ // Left out, and not stated as undefined, for a waypoint that stores no stop duration.
2867
+ ...waypoint.timing?.stop_duration == null ? {} : { storedStopSeconds: waypoint.timing.stop_duration },
2868
+ address: text(waypoint.contact?.address),
2869
+ amenities: [...waypoint.amenities ?? []],
2870
+ bookingUrl: text(waypoint.contact?.booking_url),
2871
+ cutoffAt: waypoint.timing?.cutoff_at ?? null,
2872
+ email: text(waypoint.contact?.email),
2873
+ links: (waypoint.media?.links ?? []).map((link) => ({
2874
+ label: link.label,
2875
+ rowId: mintRowId(),
2876
+ url: link.url
2877
+ })),
2878
+ openingHours: text(waypoint.contact?.opening_hours),
2879
+ phone: text(waypoint.contact?.phone),
2880
+ photos: (waypoint.media?.photos ?? []).map((photo) => ({
2881
+ caption: text(photo.caption),
2882
+ rowId: mintRowId(),
2883
+ url: photo.url
2884
+ })),
2885
+ properties: (waypoint.properties ?? []).map((property) => ({
2886
+ format: property.format ?? "text",
2887
+ key: property.key,
2888
+ label: property.label,
2889
+ rowId: mintRowId(),
2890
+ value: property.value
2891
+ })),
2892
+ stopMinutes: shownMinutes(waypoint.timing?.stop_duration),
2893
+ website: text(waypoint.contact?.website)
2894
+ });
2895
+ var patchFromDraft = (draft) => {
2896
+ const timing = {
2897
+ cutoff_at: cutoffInstant(draft.cutoffAt),
2898
+ stop_duration: stopSeconds(draft)
2899
+ };
2900
+ const contact = {
2901
+ address: orNull(draft.address),
2902
+ booking_url: orNull(draft.bookingUrl),
2903
+ email: orNull(draft.email),
2904
+ opening_hours: orNull(draft.openingHours),
2905
+ phone: orNull(draft.phone),
2906
+ website: orNull(draft.website)
2907
+ };
2908
+ const photos = draft.photos.filter((photo) => photo.url.trim() !== "").map((photo) => ({ caption: orNull(photo.caption), url: photo.url.trim() }));
2909
+ const links = draft.links.filter((link) => link.label.trim() !== "" && link.url.trim() !== "").map((link) => ({ label: link.label.trim(), url: link.url.trim() }));
2910
+ const properties = draft.properties.filter((property) => property.key.trim() !== "" && property.label.trim() !== "").map((property) => ({
2911
+ format: property.format,
2912
+ key: property.key.trim(),
2913
+ label: property.label.trim(),
2914
+ value: property.value.trim()
2915
+ }));
2916
+ const media = { links, photos };
2917
+ return {
2918
+ amenities: draft.amenities,
2919
+ contact: Object.values(contact).every((value) => value === null) ? null : contact,
2920
+ media: links.length === 0 && photos.length === 0 ? null : media,
2921
+ properties: properties.length === 0 ? null : properties,
2922
+ timing: Object.values(timing).every((value) => value === null) ? null : timing
2923
+ };
2924
+ };
2925
+ var nextPropertyKey = (properties) => {
2926
+ const taken = new Set(properties.map((property) => property.key));
2927
+ let index = properties.length + 1;
2928
+ while (taken.has(`field-${index}`)) {
2929
+ index += 1;
2930
+ }
2931
+ return `field-${index}`;
2932
+ };
2933
+
2934
+ // src/waypoints/rules/detailsPreview.ts
2935
+ var previewWaypoint = (waypoint, fields) => {
2936
+ const patch = patchFromDraft(fields.draft);
2937
+ const description = fields.description.trim();
2938
+ const name = fields.name.trim();
2939
+ return {
2940
+ ...waypoint,
2941
+ amenities: patch.amenities ?? [],
2942
+ color: fields.color,
2943
+ contact: patch.contact ?? null,
2944
+ description: description === "" ? null : description,
2945
+ icon: fields.icon,
2946
+ media: patch.media ?? null,
2947
+ name: name === "" ? null : name,
2948
+ properties: patch.properties ?? null,
2949
+ timing: patch.timing == null ? null : { ...patch.timing, cutoff_at: fields.draft.cutoffAt }
2950
+ };
2951
+ };
2952
+ var waypointDetailsForm = (waypoint) => {
2953
+ const fields = {
2954
+ color: waypoint.color ?? DEFAULT_WAYPOINT_COLOR,
2955
+ description: waypoint.description ?? "",
2956
+ details: draftFromWaypoint(waypoint),
2957
+ icon: waypoint.icon,
2958
+ name: waypoint.name ?? ""
2959
+ };
2960
+ return { ...fields, opened: fields };
2961
+ };
2962
+ var filledAndRefused = (value, accepts) => value.trim() !== "" && !accepts(value.trim());
2963
+ var detailsRefusal = (details) => {
2964
+ if (filledAndRefused(details.phone, isWaypointPhone)) {
2965
+ return "phoneInvalid";
2966
+ }
2967
+ if (filledAndRefused(details.email, isWaypointEmail)) {
2968
+ return "emailInvalid";
2969
+ }
2970
+ const addresses = [
2971
+ details.website,
2972
+ details.bookingUrl,
2973
+ ...details.photos.map((photo) => photo.url),
2974
+ ...details.links.map((link) => link.url)
2975
+ ];
2976
+ if (addresses.some((address) => filledAndRefused(address, isWaypointWebUrl))) {
2977
+ return "urlInvalid";
2978
+ }
2979
+ if (details.properties.some((property) => filledAndRefused(property.key, isWaypointPropertyKey))) {
2980
+ return "keyInvalid";
2981
+ }
2982
+ const mismatched = details.properties.some(
2983
+ (property) => !waypointPropertyValueMatchesFormat(property.value, property.format)
2984
+ );
2985
+ return mismatched ? "valueFormatInvalid" : null;
2986
+ };
2987
+ var formRefusal2 = (form) => {
2988
+ const name = form.name.trim();
2989
+ if (name !== "" && !displayNameSchema.safeParse(name).success) {
2990
+ return "nameInvalid";
2991
+ }
2992
+ if (!descriptionSchema.safeParse(form.description).success) {
2993
+ return "descriptionInvalid";
2994
+ }
2995
+ return detailsRefusal(form.details);
2996
+ };
2997
+ var DETAILS_MEMBERS = ["amenities", "contact", "media", "properties", "timing"];
2998
+ var openedPatches = /* @__PURE__ */ new WeakMap();
2999
+ var openedPatch = (draft) => {
3000
+ const held = openedPatches.get(draft);
3001
+ if (held !== void 0) {
3002
+ return held;
3003
+ }
3004
+ const patch = patchFromDraft(draft);
3005
+ openedPatches.set(draft, patch);
3006
+ return patch;
3007
+ };
3008
+ var orNull2 = (value) => {
3009
+ const trimmed = value.trim();
3010
+ return trimmed === "" ? null : trimmed;
3011
+ };
3012
+ var waypointSavePlan = (itineraryId, waypoint, form) => {
3013
+ const subject = { itineraryId, waypointId: waypoint.id };
3014
+ const { opened } = form;
3015
+ const name = form.name.trim();
3016
+ const openedName = opened.name.trim();
3017
+ const nameMoved = name === "" ? waypoint.mode === "point" && openedName !== "" : name !== openedName;
3018
+ const icon = userWaypointIconSchema.safeParse(form.icon);
3019
+ const iconMoved = icon.success && icon.data !== opened.icon;
3020
+ const colorMoved = form.color !== opened.color;
3021
+ const descriptionMoved = form.description.trim() !== opened.description.trim();
3022
+ const patch = patchFromDraft(form.details);
3023
+ const baseline = openedPatch(opened.details);
3024
+ const movedDetails = DETAILS_MEMBERS.filter(
3025
+ (member) => JSON.stringify(patch[member]) !== JSON.stringify(baseline[member])
3026
+ );
3027
+ const detailsMoved = descriptionMoved || movedDetails.length > 0;
3028
+ const changed = nameMoved || iconMoved || colorMoved || detailsMoved;
3029
+ const refusal = formRefusal2(form);
3030
+ if (refusal !== null) {
3031
+ return { changed, refusal, steps: [] };
3032
+ }
3033
+ const details = detailsMoved ? {
3034
+ input: {
3035
+ ...movedDetails.includes("amenities") ? { amenities: patch.amenities } : {},
3036
+ ...movedDetails.includes("contact") ? { contact: patch.contact } : {},
3037
+ ...movedDetails.includes("media") ? { media: patch.media } : {},
3038
+ ...movedDetails.includes("properties") ? { properties: patch.properties } : {},
3039
+ ...movedDetails.includes("timing") ? { timing: patch.timing } : {},
3040
+ ...subject,
3041
+ ...descriptionMoved ? { description: orNull2(form.description) } : {}
3042
+ },
3043
+ name: "studio.itinerary.waypoint.setDetails"
3044
+ } : null;
3045
+ const accepted = details === null || itineraryWaypointsToolContracts["studio.itinerary.waypoint.setDetails"].input.safeParse(
3046
+ details.input
3047
+ ).success;
3048
+ if (details !== null && !accepted) {
3049
+ return { changed, refusal, steps: [details] };
3050
+ }
3051
+ const steps = [];
3052
+ if (nameMoved) {
3053
+ steps.push({
3054
+ input: { ...subject, name: name === "" ? null : name },
3055
+ name: "studio.itinerary.waypoint.rename"
3056
+ });
3057
+ }
3058
+ if (iconMoved) {
3059
+ steps.push({
3060
+ input: { ...subject, icon: icon.data },
3061
+ name: "studio.itinerary.waypoint.setIcon"
3062
+ });
3063
+ }
3064
+ if (colorMoved) {
3065
+ steps.push({
3066
+ input: { ...subject, color: form.color },
3067
+ name: "studio.itinerary.waypoint.recolor"
3068
+ });
3069
+ }
3070
+ if (details !== null) {
3071
+ steps.push(details);
3072
+ }
3073
+ return { changed, refusal, steps };
3074
+ };
3075
+
3076
+ // src/waypoints/rules/liveWaypoint.ts
3077
+ var substituteLiveWaypoint = (waypoints, session, itineraryId) => {
3078
+ if (session === null) {
3079
+ return waypoints;
3080
+ }
3081
+ const { draft, waypointId } = session;
3082
+ const name = draft.name === "" ? null : draft.name;
3083
+ const index = waypoints.findIndex((waypoint) => waypoint.id === waypointId);
3084
+ const saved = waypoints[index];
3085
+ if (saved === void 0) {
3086
+ return session.intent === "create" ? [
3087
+ ...waypoints,
3088
+ synthesizeDraftWaypoint({
3089
+ draft: { color: draft.color, icon: draft.icon, lngLat: draft.lngLat, name },
3090
+ itineraryId,
3091
+ waypointId
3092
+ })
3093
+ ] : waypoints;
3094
+ }
3095
+ const savedPoint = saved.geojson?.type === "Point" ? saved.geojson.coordinates : null;
3096
+ const moved = draft.lngLat !== null && (savedPoint === null || savedPoint[0] !== draft.lngLat[0] || savedPoint[1] !== draft.lngLat[1]);
3097
+ const live = {
3098
+ ...saved,
3099
+ color: draft.color,
3100
+ geojson: moved && draft.lngLat !== null ? { coordinates: [draft.lngLat[0], draft.lngLat[1]], type: "Point" } : saved.geojson,
3101
+ icon: draft.icon,
3102
+ name
3103
+ };
3104
+ return waypoints.map((waypoint, at) => at === index ? live : waypoint);
3105
+ };
3106
+ var defaultWaypointName = (label, occurrence) => `${label} #${occurrence}`;
3107
+ var iconOf = (icon) => icon ?? DEFAULT_WAYPOINT_ICON;
3108
+ var waypointIconOccurrence = (waypoints, index) => {
3109
+ const entry = waypoints[index];
3110
+ if (entry === void 0) {
3111
+ return 0;
3112
+ }
3113
+ const target = iconOf(entry.icon);
3114
+ let occurrence = 0;
3115
+ for (let position = 0; position <= index; position += 1) {
3116
+ const candidate = waypoints[position];
3117
+ if (candidate !== void 0 && iconOf(candidate.icon) === target) {
3118
+ occurrence += 1;
3119
+ }
3120
+ }
3121
+ return occurrence;
3122
+ };
3123
+ var waypointIconLabel = (icon, names) => names[iconOf(icon)];
3124
+ var waypointDefaultName = (waypoints, index, names, icon = waypoints[index]?.icon) => {
3125
+ if (icon === waypoints[index]?.icon) {
3126
+ return defaultWaypointName(
3127
+ waypointIconLabel(icon, names),
3128
+ waypointIconOccurrence(waypoints, index)
3129
+ );
3130
+ }
3131
+ const target = iconOf(icon);
3132
+ const before = waypoints.slice(0, Math.max(0, index)).filter((waypoint) => iconOf(waypoint.icon) === target).length;
3133
+ return defaultWaypointName(waypointIconLabel(icon, names), before + 1);
3134
+ };
3135
+ var waypointDefaultNames = (waypoints, names) => {
3136
+ const counts = /* @__PURE__ */ new Map();
3137
+ return waypoints.map((waypoint) => {
3138
+ const icon = iconOf(waypoint.icon);
3139
+ const occurrence = (counts.get(icon) ?? 0) + 1;
3140
+ counts.set(icon, occurrence);
3141
+ return defaultWaypointName(waypointIconLabel(icon, names), occurrence);
3142
+ });
3143
+ };
3144
+ var nextWaypointDefaultName = (saved, icon, names) => defaultWaypointName(
3145
+ waypointIconLabel(icon, names),
3146
+ saved.filter((waypoint) => iconOf(waypoint.icon) === iconOf(icon)).length + 1
3147
+ );
3148
+ var resolveWaypointName = (name, defaultName) => name !== null && name !== "" ? name : defaultName;
3149
+
3150
+ // src/waypoints/rules/sections.ts
3151
+ var WAYPOINT_SECTIONS = [
3152
+ { glyph: "appearance", id: "appearance" },
3153
+ { glyph: "amenities", id: "amenities" },
3154
+ { glyph: "timing", id: "timing" },
3155
+ { glyph: "contact", id: "contact" },
3156
+ { glyph: "media", id: "media" },
3157
+ { glyph: "properties", id: "properties" }
3158
+ ];
3159
+ var waypointSectionLabel = (words, id) => {
3160
+ const copy = words.waypointDetails;
3161
+ switch (id) {
3162
+ case "amenities":
3163
+ return copy.amenitiesSection;
3164
+ case "appearance":
3165
+ return copy.appearanceSection;
3166
+ case "contact":
3167
+ return copy.contactSection;
3168
+ case "media":
3169
+ return copy.mediaSection;
3170
+ case "properties":
3171
+ return copy.propertiesSection;
3172
+ case "timing":
3173
+ return copy.timingSection;
3174
+ }
3175
+ };
3176
+
3177
+ // src/waypoints/rules/waypointDraft.ts
3178
+ var recordWaypointDraftChange = (bus, context, change) => {
3179
+ const state = context.ui.getState();
3180
+ const waypointId = state.waypointEditSession?.waypointId;
3181
+ if (waypointId === void 0) {
3182
+ return "drop";
3183
+ }
3184
+ const disposition = draftChangeDisposition({
3185
+ agentDriving: state.agentDriving,
3186
+ programmatic: false
3187
+ });
3188
+ if (disposition !== "record") {
3189
+ return disposition;
3190
+ }
3191
+ void Promise.resolve(
3192
+ bus.dispatch(context, "studio.itinerary.waypoint.editSetPosition", {
3193
+ lngLat: change.lngLat,
3194
+ poiSeed: change.poiSeed,
3195
+ waypointId
3196
+ })
3197
+ ).then(void 0, () => {
3198
+ });
3199
+ return disposition;
3200
+ };
3201
+
3202
+ // src/zones/rules/zoneDraft.ts
3203
+ var recordZoneDraftChange = (ui, draft) => {
3204
+ const state = ui.getState();
3205
+ const disposition = draftChangeDisposition({
3206
+ agentDriving: state.agentDriving,
3207
+ programmatic: draft.programmatic
3208
+ });
3209
+ if (disposition !== "record") {
3210
+ return disposition;
3211
+ }
3212
+ const geometry = wrapZoneGeometryPastRange(draft.geometry);
3213
+ if (draft.phase === "live") {
3214
+ state.setZoneEditLiveDraft(geometry);
3215
+ } else {
3216
+ state.pushZoneDraft(geometry);
3217
+ }
3218
+ return disposition;
3219
+ };
3220
+
3221
+ export { DEFAULT_HOLD_MS, DEFAULT_SHOT_PITCH_DEG, DEFAULT_SHOT_ZOOM, EMBED_CONFIG_FIELDS, EMBED_ELEMENTS, EMBED_IFRAME_RADIUS_PX, EMBED_SECTION_ORDER, EMBED_SEGMENT_TABLE_COLUMNS, EMBED_SESSION_ENDPOINT, EMBED_TABLE_INSTALL_COMMAND, EMBED_WAYPOINT_TABLE_COLUMNS, EMPTY_SEGMENTS, IMPORT_FILE_FORMATS, IMPORT_FILE_MAX_SIZE, PREVIEW_PLAN_REFRESH_DEBOUNCE_MS, REACHABILITY_GLYPH, SOCIAL_SHARE_TARGETS, StudioPersistenceRefusedError, VIDEO_STEP_ORDER, WAYPOINT_SECTIONS, ZONE_TIME_REFERENCE_INTERVAL_MS, activeSegmentLines, applyEmbedOverrides, beginDraftSegmentEdit, buildEmbedIframe, buildEmbedSearch, buildEmbedSessionScript, buildEmbedSrc, buildEmbedTableCode, buildEmbedViewHash, buildSegmentChainMerges, buildSegmentEditCommitInput, buildSegmentGroupRuns, buildShareText, buildShareViewConfig, canDeleteCollection, canEditCollection, canEditCollectionMetadata, clampConfigToAllowlists, clampConfigToFieldDependencies, clampEmbedConfigToSecurity, clampStudioConfigToSafetyRules, collectionCreateScope, collectionFormSchema, contextMenuReadout, createFormChanged, createPlatformViewer, createSearchFetch, defaultEmbedTableOptions, defaultStudioConfig, defaultWaypointName, defineRegistry, detectFileProvider, displaySeedDispatches, draftFromWaypoint, draftGeometries, drawnByItinerary, editHijacksNativeShortcut, editKeyIntent, editShortcuts, editToolName, editorItineraryView, embedConfigToStudioConfig, embedElementSectionFields, embedElementSections, embedElementSupportsField, embedFieldDependencies, embedLayerOptions, embedSectionChanges, embedSectionFieldKeys, embedTableChanges, embedTableColumns, enumFieldOptions, extractOverlayBand, fieldDependenciesUnmet, firstSegmentEditInput, generateFriendlyName, importDropzoneAccept, importSegmentCounts, inertStudioUrlSeam, inertViewer, isEmbedTableElement, isLoopbackDomain, isStudioSessionToken, itineraryCeiling, itineraryClickTarget, itineraryEmphasisFor, itineraryLayerIdsOf, itinerarySpriteIcons, itineraryTileFeature, lateBoundTools, layersControlOffered, localStudioPersistence, mapInteractionScope, memoryStudioPersistence, mintRowId, nextPropertyKey, nextWaypointDefaultName, normalizeDefaultProps, overlayReadoutFor, overlaysOffered, patchFromDraft, peerDraftGhosts, permittedClassicOverlay, permittedEnrichmentOverlays, persistedItineraryView, poiLayerVisibility, previewProjection, previewRefreshDisposition, previewWaypoint, projectEntityCollections, recordWaypointDraftChange, recordZoneDraftChange, resolveBaseTerrain, resolveDemUrl, resolveEmbedDefaults, resolveOrgEmbedDefaults, resolveWaypointName, restStudioPersistence, sameViewerValues, sectionDefaultPropsFields, sectionFields, segmentChainEnds, segmentEditTooltipContent, segmentGroupDissolvesOnLeave, segmentGroupForm, segmentGroupSavePlan, sessionTokenSurface, studioCapabilitySchema, studioCollabTools, studioConfigSchema, substituteLiveWaypoint, terrainVariantOptions, toggleEmbedTableColumn, truncateKey, videoProfileSource, videoRouteSpans, waypointDefaultName, waypointDefaultNames, waypointDetailsForm, waypointEditTooltipText, waypointIconLabel, waypointIconOccurrence, waypointSavePlan, waypointSectionLabel, zoneClickTarget, zoneEditTooltipText, zoneTimeReferenceSeconds };
3222
+ //# sourceMappingURL=index.js.map
3223
+ //# sourceMappingURL=index.js.map