@mountaya/studio 0.0.0-stage → 0.2.0

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