@mountaya/elements 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 (828) hide show
  1. package/CHANGELOG.md +273 -0
  2. package/LICENCE.fr.txt +280 -0
  3. package/LICENSE.txt +262 -0
  4. package/README.md +1510 -2
  5. package/THIRD-PARTY-NOTICES.txt +103 -0
  6. package/dist/agent/index.cjs +1211 -0
  7. package/dist/agent/index.cjs.map +1 -0
  8. package/dist/agent/index.d.cts +1966 -0
  9. package/dist/agent/index.d.ts +1966 -0
  10. package/dist/agent/index.js +1181 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/camera/index.cjs +2512 -0
  13. package/dist/camera/index.cjs.map +1 -0
  14. package/dist/camera/index.d.cts +1723 -0
  15. package/dist/camera/index.d.ts +1723 -0
  16. package/dist/camera/index.js +2443 -0
  17. package/dist/camera/index.js.map +1 -0
  18. package/dist/chunk-5pTPpv4v.d.cts +897 -0
  19. package/dist/chunk-5pTPpv4v.d.ts +897 -0
  20. package/dist/chunk-6JzFMFHh.d.ts +119 -0
  21. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  22. package/dist/chunk-9fp0lDic.cjs +583 -0
  23. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  24. package/dist/chunk-A48H1rDg.d.cts +73 -0
  25. package/dist/chunk-A48H1rDg.d.ts +73 -0
  26. package/dist/chunk-B-m1AchR.cjs +57 -0
  27. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  28. package/dist/chunk-B-qFTf04.d.ts +216 -0
  29. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  30. package/dist/chunk-B14wgOvH.d.cts +68 -0
  31. package/dist/chunk-B19l3j9r.cjs +150 -0
  32. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  33. package/dist/chunk-B2PtjVKg.cjs +86 -0
  34. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  35. package/dist/chunk-B56Oyb7W.cjs +70 -0
  36. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  37. package/dist/chunk-B5WGMQwK.cjs +113 -0
  38. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  39. package/dist/chunk-B98mKrdu.d.cts +302 -0
  40. package/dist/chunk-BB0PmqIM.d.cts +44 -0
  41. package/dist/chunk-BBikve0Z.cjs +269 -0
  42. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  43. package/dist/chunk-BHeXmM0X.js +37 -0
  44. package/dist/chunk-BHeXmM0X.js.map +1 -0
  45. package/dist/chunk-BI8WZLpU.cjs +281 -0
  46. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  47. package/dist/chunk-BIEc_SkR.cjs +29 -0
  48. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  49. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  50. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  51. package/dist/chunk-BJ91UCbB.js +11 -0
  52. package/dist/chunk-BJ91UCbB.js.map +1 -0
  53. package/dist/chunk-BJEZWTKj.cjs +166 -0
  54. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  55. package/dist/chunk-BJz54mfg.cjs +10 -0
  56. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  57. package/dist/chunk-BNX5LAfN.d.cts +912 -0
  58. package/dist/chunk-BP6KgA86.js +35 -0
  59. package/dist/chunk-BP6KgA86.js.map +1 -0
  60. package/dist/chunk-BRnjQq6K.d.cts +157 -0
  61. package/dist/chunk-BSiMEwPS.js +46 -0
  62. package/dist/chunk-BSiMEwPS.js.map +1 -0
  63. package/dist/chunk-BTPjDw_y.cjs +16 -0
  64. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  65. package/dist/chunk-BTUUABGI.js +17 -0
  66. package/dist/chunk-BTUUABGI.js.map +1 -0
  67. package/dist/chunk-BUeL9y7s.cjs +45 -0
  68. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  69. package/dist/chunk-BWMuCNc9.cjs +172 -0
  70. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  71. package/dist/chunk-BWjRfhpF.js +126 -0
  72. package/dist/chunk-BWjRfhpF.js.map +1 -0
  73. package/dist/chunk-BZ5KyZXI.d.ts +302 -0
  74. package/dist/chunk-B_4SVmvh.js +94 -0
  75. package/dist/chunk-B_4SVmvh.js.map +1 -0
  76. package/dist/chunk-BcTUuZQ3.js +95 -0
  77. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  78. package/dist/chunk-BdkqSsJe.cjs +140 -0
  79. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  80. package/dist/chunk-BfktMVmI.js +70 -0
  81. package/dist/chunk-BfktMVmI.js.map +1 -0
  82. package/dist/chunk-BfzQb0EK.cjs +6 -0
  83. package/dist/chunk-BhWfT-22.d.cts +808 -0
  84. package/dist/chunk-BjJcqX5J.cjs +60 -0
  85. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  86. package/dist/chunk-Bk0L8g5J.d.cts +77 -0
  87. package/dist/chunk-Bk0L8g5J.d.ts +77 -0
  88. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  89. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  90. package/dist/chunk-BlKF4lrp.js +43 -0
  91. package/dist/chunk-BlKF4lrp.js.map +1 -0
  92. package/dist/chunk-Bm1FieGR.js +4 -0
  93. package/dist/chunk-Bm1FieGR.js.map +1 -0
  94. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  95. package/dist/chunk-BpN3hr6a.cjs +541 -0
  96. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  97. package/dist/chunk-Bq_WHTfd.d.cts +119 -0
  98. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  99. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  100. package/dist/chunk-Bqt97zwf.d.cts +54 -0
  101. package/dist/chunk-Bqt97zwf.d.ts +54 -0
  102. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  103. package/dist/chunk-BvTpOUoC.cjs +207 -0
  104. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  105. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  106. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  107. package/dist/chunk-BxDQZDXR.d.cts +76 -0
  108. package/dist/chunk-BxDQZDXR.d.ts +76 -0
  109. package/dist/chunk-BxUio8kX.js +20 -0
  110. package/dist/chunk-BxUio8kX.js.map +1 -0
  111. package/dist/chunk-BxaocpFi.d.cts +1 -0
  112. package/dist/chunk-Bywi0K1N.js +36 -0
  113. package/dist/chunk-Bywi0K1N.js.map +1 -0
  114. package/dist/chunk-C-IlmkDl.js +59 -0
  115. package/dist/chunk-C-IlmkDl.js.map +1 -0
  116. package/dist/chunk-C5PtVewq.d.ts +389 -0
  117. package/dist/chunk-C5dpC7mQ.js +19 -0
  118. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  119. package/dist/chunk-C5q1sgSa.js +46 -0
  120. package/dist/chunk-C5q1sgSa.js.map +1 -0
  121. package/dist/chunk-C6fU9G5I.cjs +221 -0
  122. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  123. package/dist/chunk-C71dpWUK.js +5 -0
  124. package/dist/chunk-C71dpWUK.js.map +1 -0
  125. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  126. package/dist/chunk-C8HdaHpu.js +118 -0
  127. package/dist/chunk-C8HdaHpu.js.map +1 -0
  128. package/dist/chunk-C8ZGryck.js +236 -0
  129. package/dist/chunk-C8ZGryck.js.map +1 -0
  130. package/dist/chunk-C95NG0oD.cjs +43 -0
  131. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  132. package/dist/chunk-C9aR8DXb.js +9 -0
  133. package/dist/chunk-C9aR8DXb.js.map +1 -0
  134. package/dist/chunk-CAUZnoCs.d.ts +525 -0
  135. package/dist/chunk-CBXWWuM9.cjs +82 -0
  136. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  137. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  138. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  139. package/dist/chunk-CCp85vXg.cjs +60 -0
  140. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  141. package/dist/chunk-CEcB1_uK.js +39 -0
  142. package/dist/chunk-CEcB1_uK.js.map +1 -0
  143. package/dist/chunk-CFIo021l.d.cts +216 -0
  144. package/dist/chunk-CH_IZoJE.js +33 -0
  145. package/dist/chunk-CH_IZoJE.js.map +1 -0
  146. package/dist/chunk-CHrasH_g.cjs +25 -0
  147. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  148. package/dist/chunk-CJVoSaAE.cjs +3 -0
  149. package/dist/chunk-CJp8nGcb.js +96 -0
  150. package/dist/chunk-CJp8nGcb.js.map +1 -0
  151. package/dist/chunk-CJwUtkOt.js +112 -0
  152. package/dist/chunk-CJwUtkOt.js.map +1 -0
  153. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  154. package/dist/chunk-CKiVSRYg.js +50 -0
  155. package/dist/chunk-CKiVSRYg.js.map +1 -0
  156. package/dist/chunk-CKtd19eD.cjs +59 -0
  157. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  158. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  159. package/dist/chunk-CLqUlkAe.js +54 -0
  160. package/dist/chunk-CLqUlkAe.js.map +1 -0
  161. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  162. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  163. package/dist/chunk-CN_TKSgm.js +10 -0
  164. package/dist/chunk-CN_TKSgm.js.map +1 -0
  165. package/dist/chunk-CNe6MtqV.cjs +29 -0
  166. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  167. package/dist/chunk-COQkDTC5.js +83 -0
  168. package/dist/chunk-COQkDTC5.js.map +1 -0
  169. package/dist/chunk-CPBl6K4M.cjs +168 -0
  170. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  171. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  172. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  173. package/dist/chunk-CTNoajFh.d.cts +389 -0
  174. package/dist/chunk-CTd-qgJc.cjs +384 -0
  175. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  176. package/dist/chunk-CW80YYtU.cjs +1056 -0
  177. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  178. package/dist/chunk-CWpqBgkF.d.cts +24 -0
  179. package/dist/chunk-CWpqBgkF.d.ts +24 -0
  180. package/dist/chunk-CXjRArgy.d.ts +3 -0
  181. package/dist/chunk-CXonfH3-.cjs +14 -0
  182. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  183. package/dist/chunk-CYcouGXN.d.ts +825 -0
  184. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  185. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  186. package/dist/chunk-C_fQFr70.d.cts +159 -0
  187. package/dist/chunk-C_fQFr70.d.ts +159 -0
  188. package/dist/chunk-CbOtHnnB.cjs +359 -0
  189. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  190. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  191. package/dist/chunk-Ce1_thm7.js +146 -0
  192. package/dist/chunk-Ce1_thm7.js.map +1 -0
  193. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  194. package/dist/chunk-CeiTuMyt.d.cts +525 -0
  195. package/dist/chunk-Ch1OLzLi.js +1 -0
  196. package/dist/chunk-Cizu_j1N.cjs +87 -0
  197. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  198. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  199. package/dist/chunk-Cl1etdlu.js +63 -0
  200. package/dist/chunk-Cl1etdlu.js.map +1 -0
  201. package/dist/chunk-CmoVJDoz.js +4 -0
  202. package/dist/chunk-CmoVJDoz.js.map +1 -0
  203. package/dist/chunk-CnLucxjG.cjs +197 -0
  204. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  205. package/dist/chunk-CsWjBmdi.cjs +56 -0
  206. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  207. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  208. package/dist/chunk-CvMHibbA.d.ts +427 -0
  209. package/dist/chunk-CwDeiN5U.js +870 -0
  210. package/dist/chunk-CwDeiN5U.js.map +1 -0
  211. package/dist/chunk-Cwdmx4tG.js +1 -0
  212. package/dist/chunk-D-4MxHTt.d.cts +105 -0
  213. package/dist/chunk-D-4MxHTt.d.ts +105 -0
  214. package/dist/chunk-D0LF-99V.js +1093 -0
  215. package/dist/chunk-D0LF-99V.js.map +1 -0
  216. package/dist/chunk-D1fe-0c_.js +367 -0
  217. package/dist/chunk-D1fe-0c_.js.map +1 -0
  218. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  219. package/dist/chunk-D39gAxya.cjs +89 -0
  220. package/dist/chunk-D39gAxya.cjs.map +1 -0
  221. package/dist/chunk-D6KdIW5e.cjs +228 -0
  222. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  223. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  224. package/dist/chunk-D89E-w70.d.ts +44 -0
  225. package/dist/chunk-D8bdTysL.js +552 -0
  226. package/dist/chunk-D8bdTysL.js.map +1 -0
  227. package/dist/chunk-D96QJT24.cjs +109 -0
  228. package/dist/chunk-D96QJT24.cjs.map +1 -0
  229. package/dist/chunk-DAmkQl-i.js +119 -0
  230. package/dist/chunk-DAmkQl-i.js.map +1 -0
  231. package/dist/chunk-DEfsb2lc.cjs +10 -0
  232. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  233. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  234. package/dist/chunk-DJpUw8TN.d.ts +912 -0
  235. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  236. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  237. package/dist/chunk-DKqgr31j.cjs +61 -0
  238. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  239. package/dist/chunk-DLZ0QYm9.js +37 -0
  240. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  241. package/dist/chunk-DLjS0uaC.js +4 -0
  242. package/dist/chunk-DLjS0uaC.js.map +1 -0
  243. package/dist/chunk-DMokwmOV.cjs +49 -0
  244. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  245. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  246. package/dist/chunk-DNfGfIF3.js +31 -0
  247. package/dist/chunk-DNfGfIF3.js.map +1 -0
  248. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  249. package/dist/chunk-DSGkP8_y.js +45 -0
  250. package/dist/chunk-DSGkP8_y.js.map +1 -0
  251. package/dist/chunk-DTctvfSd.d.cts +197 -0
  252. package/dist/chunk-DWe7igyw.cjs +206 -0
  253. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  254. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  255. package/dist/chunk-DWsm3HIW.d.cts +120 -0
  256. package/dist/chunk-DWsm3HIW.d.ts +120 -0
  257. package/dist/chunk-DXABHjLa.cjs +3 -0
  258. package/dist/chunk-D_BeqSbc.cjs +42 -0
  259. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  260. package/dist/chunk-D_svQNdW.d.ts +66 -0
  261. package/dist/chunk-Dav4xWrp.js +330 -0
  262. package/dist/chunk-Dav4xWrp.js.map +1 -0
  263. package/dist/chunk-DbCPhepL.js +293 -0
  264. package/dist/chunk-DbCPhepL.js.map +1 -0
  265. package/dist/chunk-DcrTy-y2.cjs +43 -0
  266. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  267. package/dist/chunk-Ddv484ld.js +487 -0
  268. package/dist/chunk-Ddv484ld.js.map +1 -0
  269. package/dist/chunk-De0bjnhY.cjs +88 -0
  270. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  271. package/dist/chunk-De2FmNPu.cjs +32 -0
  272. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  273. package/dist/chunk-DeSjQXiI.d.ts +157 -0
  274. package/dist/chunk-Den0Ta6C.js +132 -0
  275. package/dist/chunk-Den0Ta6C.js.map +1 -0
  276. package/dist/chunk-DiDKEeEa.js +8 -0
  277. package/dist/chunk-DiDKEeEa.js.map +1 -0
  278. package/dist/chunk-Dj60k5PU.js +197 -0
  279. package/dist/chunk-Dj60k5PU.js.map +1 -0
  280. package/dist/chunk-DjnYQBCN.js +4705 -0
  281. package/dist/chunk-DjnYQBCN.js.map +1 -0
  282. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  283. package/dist/chunk-Dor1ERI9.cjs +85 -0
  284. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  285. package/dist/chunk-DpMouOoH.js +451 -0
  286. package/dist/chunk-DpMouOoH.js.map +1 -0
  287. package/dist/chunk-DposgdNL.cjs +52 -0
  288. package/dist/chunk-DposgdNL.cjs.map +1 -0
  289. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  290. package/dist/chunk-Dr5MCIpS.d.cts +63 -0
  291. package/dist/chunk-Dr5MCIpS.d.ts +63 -0
  292. package/dist/chunk-DrudttCC.cjs +4 -0
  293. package/dist/chunk-DsDYVJQC.js +173 -0
  294. package/dist/chunk-DsDYVJQC.js.map +1 -0
  295. package/dist/chunk-Dw8ur6FJ.js +27 -0
  296. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  297. package/dist/chunk-DwG6M_0v.js +64 -0
  298. package/dist/chunk-DwG6M_0v.js.map +1 -0
  299. package/dist/chunk-Dy9a5ibO.js +284 -0
  300. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  301. package/dist/chunk-DyayZlQJ.js +157 -0
  302. package/dist/chunk-DyayZlQJ.js.map +1 -0
  303. package/dist/chunk-DyhJZC2i.js +126 -0
  304. package/dist/chunk-DyhJZC2i.js.map +1 -0
  305. package/dist/chunk-F9zBzmmG.cjs +45 -0
  306. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  307. package/dist/chunk-FyCYofv2.js +116 -0
  308. package/dist/chunk-FyCYofv2.js.map +1 -0
  309. package/dist/chunk-GHJRjAk2.js +1 -0
  310. package/dist/chunk-H14isiSf.d.ts +751 -0
  311. package/dist/chunk-HIJzXoN4.js +7 -0
  312. package/dist/chunk-HIJzXoN4.js.map +1 -0
  313. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  314. package/dist/chunk-KN60yxBQ.js +5 -0
  315. package/dist/chunk-KN60yxBQ.js.map +1 -0
  316. package/dist/chunk-NM5yg6bh.cjs +82 -0
  317. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  318. package/dist/chunk-OXr3zJfM.cjs +119 -0
  319. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  320. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  321. package/dist/chunk-QJBtJrZ0.js +36 -0
  322. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  323. package/dist/chunk-QKWhxfPv.d.cts +361 -0
  324. package/dist/chunk-QKWhxfPv.d.ts +361 -0
  325. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  326. package/dist/chunk-RHZrxUrM.cjs +39 -0
  327. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  328. package/dist/chunk-RTxe2i66.js +91 -0
  329. package/dist/chunk-RTxe2i66.js.map +1 -0
  330. package/dist/chunk-RrKkJb6P.js +16 -0
  331. package/dist/chunk-RrKkJb6P.js.map +1 -0
  332. package/dist/chunk-VOJqpcnM.cjs +181 -0
  333. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  334. package/dist/chunk-VljGTrid.js +1 -0
  335. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  336. package/dist/chunk-X9K2WChn.cjs +28 -0
  337. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  338. package/dist/chunk-YrtOx6oy.js +251 -0
  339. package/dist/chunk-YrtOx6oy.js.map +1 -0
  340. package/dist/chunk-bY7ySujI.d.cts +928 -0
  341. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  342. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  343. package/dist/chunk-blfknWoM.d.cts +1926 -0
  344. package/dist/chunk-blqsohAb.js +113 -0
  345. package/dist/chunk-blqsohAb.js.map +1 -0
  346. package/dist/chunk-cDMCjodI.cjs +58 -0
  347. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  348. package/dist/chunk-cWjE3qd6.cjs +10 -0
  349. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  350. package/dist/chunk-dfOgV3fu.js +26 -0
  351. package/dist/chunk-dfOgV3fu.js.map +1 -0
  352. package/dist/chunk-f9cTwUX1.cjs +125 -0
  353. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  354. package/dist/chunk-fHVYEZs4.cjs +28 -0
  355. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  356. package/dist/chunk-fWRUMgRI.js +22 -0
  357. package/dist/chunk-fWRUMgRI.js.map +1 -0
  358. package/dist/chunk-fozLXfHY.d.cts +55 -0
  359. package/dist/chunk-fozLXfHY.d.ts +55 -0
  360. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  361. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  362. package/dist/chunk-gbj2R-_w.js +58 -0
  363. package/dist/chunk-gbj2R-_w.js.map +1 -0
  364. package/dist/chunk-iIWxsAXd.js +59 -0
  365. package/dist/chunk-iIWxsAXd.js.map +1 -0
  366. package/dist/chunk-lItIuOIS.cjs +137 -0
  367. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  368. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  369. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  370. package/dist/chunk-o3IRANDf.cjs +99 -0
  371. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  372. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  373. package/dist/chunk-ohsf-6Rn.js +600 -0
  374. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  375. package/dist/chunk-pBleU6Nv.js +3061 -0
  376. package/dist/chunk-pBleU6Nv.js.map +1 -0
  377. package/dist/chunk-px4e99cy.js +71 -0
  378. package/dist/chunk-px4e99cy.js.map +1 -0
  379. package/dist/chunk-qwYDLeXc.cjs +99 -0
  380. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  381. package/dist/chunk-rF_859Qk.cjs +101 -0
  382. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  383. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  384. package/dist/chunk-twQItIRg.cjs +338 -0
  385. package/dist/chunk-twQItIRg.cjs.map +1 -0
  386. package/dist/chunk-vnPrMVjY.js +10 -0
  387. package/dist/chunk-vnPrMVjY.js.map +1 -0
  388. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  389. package/dist/chunk-xh3UkuVs.cjs +246 -0
  390. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  391. package/dist/chunk-yMzRr26E.js +153 -0
  392. package/dist/chunk-yMzRr26E.js.map +1 -0
  393. package/dist/collab/index.cjs +831 -0
  394. package/dist/collab/index.cjs.map +1 -0
  395. package/dist/collab/index.d.cts +824 -0
  396. package/dist/collab/index.d.ts +824 -0
  397. package/dist/collab/index.js +819 -0
  398. package/dist/collab/index.js.map +1 -0
  399. package/dist/data/index.cjs +39 -0
  400. package/dist/data/index.d.cts +6 -0
  401. package/dist/data/index.d.ts +6 -0
  402. package/dist/data/index.js +7 -0
  403. package/dist/editor/index.cjs +2713 -0
  404. package/dist/editor/index.cjs.map +1 -0
  405. package/dist/editor/index.d.cts +10 -0
  406. package/dist/editor/index.d.ts +10 -0
  407. package/dist/editor/index.js +2702 -0
  408. package/dist/editor/index.js.map +1 -0
  409. package/dist/errors/index.cjs +11 -0
  410. package/dist/errors/index.d.cts +2 -0
  411. package/dist/errors/index.d.ts +2 -0
  412. package/dist/errors/index.js +1 -0
  413. package/dist/geo/index.cjs +68 -0
  414. package/dist/geo/index.d.cts +6 -0
  415. package/dist/geo/index.d.ts +6 -0
  416. package/dist/geo/index.js +11 -0
  417. package/dist/i18n/fr/index.cjs +333 -0
  418. package/dist/i18n/fr/index.cjs.map +1 -0
  419. package/dist/i18n/fr/index.d.cts +18 -0
  420. package/dist/i18n/fr/index.d.ts +18 -0
  421. package/dist/i18n/fr/index.js +328 -0
  422. package/dist/i18n/fr/index.js.map +1 -0
  423. package/dist/i18n/index.cjs +451 -0
  424. package/dist/i18n/index.cjs.map +1 -0
  425. package/dist/i18n/index.d.cts +268 -0
  426. package/dist/i18n/index.d.ts +268 -0
  427. package/dist/i18n/index.js +430 -0
  428. package/dist/i18n/index.js.map +1 -0
  429. package/dist/icons/index.cjs +37 -0
  430. package/dist/icons/index.d.cts +4 -0
  431. package/dist/icons/index.d.ts +4 -0
  432. package/dist/icons/index.js +8 -0
  433. package/dist/index.cjs +517 -0
  434. package/dist/index.cjs.map +1 -0
  435. package/dist/index.d.cts +174 -0
  436. package/dist/index.d.ts +174 -0
  437. package/dist/index.js +54 -0
  438. package/dist/index.js.map +1 -0
  439. package/dist/layers/index.cjs +83 -0
  440. package/dist/layers/index.d.cts +3 -0
  441. package/dist/layers/index.d.ts +3 -0
  442. package/dist/layers/index.js +5 -0
  443. package/dist/map-client/index.cjs +5 -0
  444. package/dist/map-client/index.d.cts +6 -0
  445. package/dist/map-client/index.d.ts +6 -0
  446. package/dist/map-client/index.js +0 -0
  447. package/dist/maplibre-worker.mjs +12 -0
  448. package/dist/navigation/index.cjs +612 -0
  449. package/dist/navigation/index.cjs.map +1 -0
  450. package/dist/navigation/index.d.cts +551 -0
  451. package/dist/navigation/index.d.ts +551 -0
  452. package/dist/navigation/index.js +599 -0
  453. package/dist/navigation/index.js.map +1 -0
  454. package/dist/profile/index.cjs +177 -0
  455. package/dist/profile/index.d.cts +8 -0
  456. package/dist/profile/index.d.ts +8 -0
  457. package/dist/profile/index.js +10 -0
  458. package/dist/seams/index.cjs +15 -0
  459. package/dist/seams/index.d.cts +4 -0
  460. package/dist/seams/index.d.ts +4 -0
  461. package/dist/seams/index.js +4 -0
  462. package/dist/search/index.cjs +39 -0
  463. package/dist/search/index.d.cts +6 -0
  464. package/dist/search/index.d.ts +6 -0
  465. package/dist/search/index.js +3 -0
  466. package/dist/style/index.cjs +34 -0
  467. package/dist/style/index.d.cts +5 -0
  468. package/dist/style/index.d.ts +5 -0
  469. package/dist/style/index.js +5 -0
  470. package/dist/styles.css +11 -0
  471. package/dist/testing/index.cjs +444 -0
  472. package/dist/testing/index.cjs.map +1 -0
  473. package/dist/testing/index.d.cts +217 -0
  474. package/dist/testing/index.d.ts +217 -0
  475. package/dist/testing/index.js +435 -0
  476. package/dist/testing/index.js.map +1 -0
  477. package/dist/timezone/index.cjs +1953 -0
  478. package/dist/timezone/index.cjs.map +1 -0
  479. package/dist/timezone/index.d.cts +28 -0
  480. package/dist/timezone/index.d.ts +28 -0
  481. package/dist/timezone/index.js +1948 -0
  482. package/dist/timezone/index.js.map +1 -0
  483. package/dist/units/index.cjs +29 -0
  484. package/dist/units/index.d.cts +3 -0
  485. package/dist/units/index.d.ts +3 -0
  486. package/dist/units/index.js +3 -0
  487. package/dist/video/index.cjs +1713 -0
  488. package/dist/video/index.cjs.map +1 -0
  489. package/dist/video/index.d.cts +846 -0
  490. package/dist/video/index.d.ts +846 -0
  491. package/dist/video/index.js +1689 -0
  492. package/dist/video/index.js.map +1 -0
  493. package/dist/view/index.cjs +7 -0
  494. package/dist/view/index.d.cts +3 -0
  495. package/dist/view/index.d.ts +3 -0
  496. package/dist/view/index.js +1 -0
  497. package/package.json +433 -4
  498. package/src/agent/engines/session.ts +2255 -0
  499. package/src/agent/index.ts +109 -0
  500. package/src/agent/rules/agentError.ts +128 -0
  501. package/src/agent/rules/boundedInputJson.ts +53 -0
  502. package/src/agent/rules/conversation.ts +629 -0
  503. package/src/agent/rules/conversationFaults.ts +349 -0
  504. package/src/agent/rules/conversationHost.ts +390 -0
  505. package/src/agent/rules/dispatcher.ts +102 -0
  506. package/src/agent/rules/errorCodes.ts +78 -0
  507. package/src/agent/rules/errorStatus.ts +65 -0
  508. package/src/agent/rules/scriptedTransport.ts +390 -0
  509. package/src/agent/rules/stickToBottom.ts +38 -0
  510. package/src/agent/rules/toolResultPayload.ts +197 -0
  511. package/src/auth/rules/clientHeader.ts +22 -0
  512. package/src/auth/rules/sentCredential.ts +76 -0
  513. package/src/auth/rules/transformRequest.ts +803 -0
  514. package/src/camera/engines/videoFlight.ts +1758 -0
  515. package/src/camera/index.ts +157 -0
  516. package/src/camera/rules/clearance.ts +1099 -0
  517. package/src/camera/rules/fit.ts +132 -0
  518. package/src/camera/rules/modes.ts +1019 -0
  519. package/src/camera/rules/plan.ts +478 -0
  520. package/src/camera/rules/planner.ts +129 -0
  521. package/src/camera/rules/poseRanges.ts +38 -0
  522. package/src/camera/rules/presets.ts +185 -0
  523. package/src/camera/rules/profileSamples.ts +243 -0
  524. package/src/camera/rules/route.ts +596 -0
  525. package/src/camera/rules/routeContent.ts +105 -0
  526. package/src/camera/rules/spline.ts +765 -0
  527. package/src/camera/rules/sweptViewports.ts +39 -0
  528. package/src/camera/rules/track.ts +1412 -0
  529. package/src/camera/rules/vocabulary.ts +130 -0
  530. package/src/camera/rules/zoom.ts +216 -0
  531. package/src/collab/engines/session.ts +1902 -0
  532. package/src/collab/engines/trailingThrottle.ts +151 -0
  533. package/src/collab/index.ts +52 -0
  534. package/src/collab/rules/dispatch.ts +143 -0
  535. package/src/collab/rules/peerNames.ts +51 -0
  536. package/src/collab/rules/scriptedTransport.ts +244 -0
  537. package/src/compose/engines/baseMapSwitch.ts +1136 -0
  538. package/src/compose/engines/events.ts +962 -0
  539. package/src/compose/engines/mountayaMap.ts +5648 -0
  540. package/src/compose/engines/sentCredentials.ts +146 -0
  541. package/src/compose/engines/slotRequests.ts +413 -0
  542. package/src/compose/rules/accessRefusal.ts +109 -0
  543. package/src/compose/rules/accessStanding.ts +75 -0
  544. package/src/compose/rules/analysisKinds.ts +331 -0
  545. package/src/compose/rules/analysisLayers.ts +176 -0
  546. package/src/compose/rules/cameraMoves.ts +38 -0
  547. package/src/compose/rules/carriedLayers.ts +87 -0
  548. package/src/compose/rules/developmentWarnings.ts +167 -0
  549. package/src/compose/rules/fitBox.ts +67 -0
  550. package/src/compose/rules/fitCamera.ts +54 -0
  551. package/src/compose/rules/geoJsonSlot.ts +61 -0
  552. package/src/compose/rules/geometrySlots.ts +155 -0
  553. package/src/compose/rules/glyphNode.ts +62 -0
  554. package/src/compose/rules/layerKeys.ts +92 -0
  555. package/src/compose/rules/layerOrder.ts +85 -0
  556. package/src/compose/rules/layersManifest.ts +26 -0
  557. package/src/compose/rules/mapOptions.ts +300 -0
  558. package/src/compose/rules/maplibreWorkerVersion.gen.ts +8 -0
  559. package/src/compose/rules/markerPin.ts +122 -0
  560. package/src/compose/rules/markerRegistry.ts +85 -0
  561. package/src/compose/rules/markerSprite.ts +382 -0
  562. package/src/compose/rules/maxBounds.ts +120 -0
  563. package/src/compose/rules/overlayLookup.ts +49 -0
  564. package/src/compose/rules/paintDiff.ts +38 -0
  565. package/src/compose/rules/panLock.ts +77 -0
  566. package/src/compose/rules/patch.ts +124 -0
  567. package/src/compose/rules/queriedFeature.ts +55 -0
  568. package/src/compose/rules/queryLayers.ts +46 -0
  569. package/src/compose/rules/searchHighlight.ts +313 -0
  570. package/src/compose/rules/slotNames.ts +19 -0
  571. package/src/compose/rules/stripeImage.ts +253 -0
  572. package/src/compose/rules/swapMarker.ts +66 -0
  573. package/src/compose/rules/terrainVariant.ts +88 -0
  574. package/src/compose/rules/types.ts +559 -0
  575. package/src/compose/rules/urlHash.ts +19 -0
  576. package/src/compose/rules/viewOptions.ts +451 -0
  577. package/src/compose/rules/workerUrl.ts +131 -0
  578. package/src/data/engines/itineraryResource.ts +643 -0
  579. package/src/data/index.ts +78 -0
  580. package/src/data/rules/adapt.ts +473 -0
  581. package/src/data/rules/editModes.ts +51 -0
  582. package/src/data/rules/itinerary.ts +168 -0
  583. package/src/data/rules/nullable.ts +63 -0
  584. package/src/data/rules/roadAccess.ts +169 -0
  585. package/src/data/rules/segmentGroups.ts +309 -0
  586. package/src/data/rules/selectors.ts +95 -0
  587. package/src/data/rules/zones.ts +79 -0
  588. package/src/draw/engines/boundaryEngine.ts +1003 -0
  589. package/src/draw/engines/framedAdapter.ts +198 -0
  590. package/src/draw/engines/pointerCursor.ts +205 -0
  591. package/src/draw/engines/segmentEngine.ts +1405 -0
  592. package/src/draw/engines/snapIndex.ts +254 -0
  593. package/src/draw/engines/waypointEngine.ts +574 -0
  594. package/src/draw/engines/zoneEngine.ts +1137 -0
  595. package/src/draw/rules/drawFrame.ts +123 -0
  596. package/src/draw/rules/insertVertex.ts +226 -0
  597. package/src/draw/rules/screenSpace.ts +62 -0
  598. package/src/draw/rules/seeds.ts +185 -0
  599. package/src/draw/rules/snap.ts +115 -0
  600. package/src/draw/rules/snapCameraKey.ts +50 -0
  601. package/src/draw/rules/terraDrawShared.ts +214 -0
  602. package/src/draw/rules/zoneOutline.ts +213 -0
  603. package/src/editing/engines/cursor.ts +505 -0
  604. package/src/editing/engines/draftMarker.ts +149 -0
  605. package/src/editing/rules/accent.ts +11 -0
  606. package/src/editing/rules/engine.ts +288 -0
  607. package/src/editing/rules/placement.ts +22 -0
  608. package/src/editing/rules/positions.ts +89 -0
  609. package/src/editing/rules/sources.ts +9 -0
  610. package/src/editing/rules/types.ts +457 -0
  611. package/src/editing/rules/vocabulary.ts +10 -0
  612. package/src/editing/rules/waypointCursor.ts +228 -0
  613. package/src/editor/engines/directionArrows.ts +459 -0
  614. package/src/editor/engines/directions.ts +1383 -0
  615. package/src/editor/engines/editorClient.ts +134 -0
  616. package/src/editor/engines/eventScope.ts +59 -0
  617. package/src/editor/engines/frameLoop.ts +159 -0
  618. package/src/editor/engines/itineraryPreview.ts +272 -0
  619. package/src/editor/engines/mapLockGuard.ts +66 -0
  620. package/src/editor/engines/overlayRenderer.ts +2696 -0
  621. package/src/editor/engines/peerDraft.ts +760 -0
  622. package/src/editor/engines/poiPick.ts +305 -0
  623. package/src/editor/engines/pointPick.ts +84 -0
  624. package/src/editor/engines/roadAccessLine.ts +140 -0
  625. package/src/editor/engines/searchHighlight.ts +183 -0
  626. package/src/editor/engines/viewClient.ts +4091 -0
  627. package/src/editor/engines/zoneBadges.ts +503 -0
  628. package/src/editor/index.ts +97 -0
  629. package/src/editor/rules/accentColor.ts +116 -0
  630. package/src/editor/rules/camera.ts +121 -0
  631. package/src/editor/rules/contract.ts +120 -0
  632. package/src/editor/rules/icons.ts +825 -0
  633. package/src/editor/rules/markerElements.ts +244 -0
  634. package/src/editor/rules/style.ts +51 -0
  635. package/src/editor/rules/terrain.ts +98 -0
  636. package/src/editor/rules/tileWarm.ts +191 -0
  637. package/src/editor/rules/tilesReload.ts +158 -0
  638. package/src/editor/rules/zoneBadgePlacement.ts +1832 -0
  639. package/src/editor/rules/zoneTimeStyling.ts +119 -0
  640. package/src/errors/index.ts +25 -0
  641. package/src/errors/rules/errors.ts +158 -0
  642. package/src/errors/rules/print.ts +129 -0
  643. package/src/geo/index.ts +89 -0
  644. package/src/geo/rules/boundaries.ts +105 -0
  645. package/src/geo/rules/camera.ts +496 -0
  646. package/src/geo/rules/corridor.ts +242 -0
  647. package/src/geo/rules/elevationTiles.ts +269 -0
  648. package/src/geo/rules/formatLngLat.ts +63 -0
  649. package/src/geo/rules/geodesy.ts +125 -0
  650. package/src/geo/rules/geometry.ts +362 -0
  651. package/src/geo/rules/lineWalk.ts +77 -0
  652. package/src/geo/rules/longitude.ts +99 -0
  653. package/src/geo/rules/searchLimits.ts +22 -0
  654. package/src/geo/rules/segmentGeometry.ts +80 -0
  655. package/src/geo/rules/terrain.ts +107 -0
  656. package/src/geo/rules/tuples.ts +124 -0
  657. package/src/geo/rules/types.ts +54 -0
  658. package/src/geo/rules/webMercator.ts +57 -0
  659. package/src/i18n/fr/index.ts +17 -0
  660. package/src/i18n/fr/rules/fr.ts +85 -0
  661. package/src/i18n/fr/rules/words.gen.ts +277 -0
  662. package/src/i18n/index.ts +82 -0
  663. package/src/i18n/rules/bundle.ts +378 -0
  664. package/src/i18n/rules/config.ts +71 -0
  665. package/src/i18n/rules/dates.ts +165 -0
  666. package/src/i18n/rules/endonyms.gen.ts +19 -0
  667. package/src/i18n/rules/language.ts +92 -0
  668. package/src/i18n/rules/localizedName.ts +33 -0
  669. package/src/i18n/rules/merge.ts +106 -0
  670. package/src/i18n/rules/scope.ts +127 -0
  671. package/src/i18n/rules/strings.ts +632 -0
  672. package/src/i18n/rules/videoOverlay.ts +121 -0
  673. package/src/i18n/rules/wordForms.ts +95 -0
  674. package/src/i18n/rules/words.gen.ts +277 -0
  675. package/src/icons/index.ts +54 -0
  676. package/src/icons/rules/activities.ts +40 -0
  677. package/src/icons/rules/amenities.ts +250 -0
  678. package/src/icons/rules/artwork.gen.ts +83 -0
  679. package/src/icons/rules/artwork.ts +47 -0
  680. package/src/icons/rules/fallback.ts +21 -0
  681. package/src/icons/rules/lucideMarkers.gen.ts +112 -0
  682. package/src/icons/rules/lucideUi.gen.ts +197 -0
  683. package/src/icons/rules/paint.ts +107 -0
  684. package/src/icons/rules/parse.ts +475 -0
  685. package/src/icons/rules/provider.ts +373 -0
  686. package/src/icons/rules/sprites.ts +54 -0
  687. package/src/icons/rules/ui.ts +348 -0
  688. package/src/icons/rules/waypoints.ts +215 -0
  689. package/src/index.ts +993 -0
  690. package/src/layers/engines/layersSelection.ts +515 -0
  691. package/src/layers/engines/readoutEngine.ts +131 -0
  692. package/src/layers/index.ts +151 -0
  693. package/src/layers/rules/analysis.ts +135 -0
  694. package/src/layers/rules/enrichment.ts +30 -0
  695. package/src/layers/rules/geoJson.ts +270 -0
  696. package/src/layers/rules/hover.ts +67 -0
  697. package/src/layers/rules/itineraries.ts +182 -0
  698. package/src/layers/rules/layersPanel.ts +237 -0
  699. package/src/layers/rules/order.ts +194 -0
  700. package/src/layers/rules/overlayInstant.ts +49 -0
  701. package/src/layers/rules/overlays.ts +52 -0
  702. package/src/layers/rules/poiPanel.ts +119 -0
  703. package/src/layers/rules/pois.ts +114 -0
  704. package/src/layers/rules/readout.ts +340 -0
  705. package/src/layers/rules/streetView.ts +16 -0
  706. package/src/layers/rules/tileTimestamp.ts +146 -0
  707. package/src/layers/rules/timeSlider.ts +192 -0
  708. package/src/layers/rules/timeWindow.ts +123 -0
  709. package/src/layers/rules/zones.ts +43 -0
  710. package/src/layers/rules/zoom.ts +77 -0
  711. package/src/map-client/index.ts +71 -0
  712. package/src/map-client/rules/mapClient.ts +1945 -0
  713. package/src/navigation/engines/navigation.ts +493 -0
  714. package/src/navigation/index.ts +51 -0
  715. package/src/navigation/rules/followedRoute.ts +78 -0
  716. package/src/navigation/rules/instructions.ts +89 -0
  717. package/src/navigation/rules/itineraryRoute.ts +232 -0
  718. package/src/navigation/rules/offRoute.ts +41 -0
  719. package/src/navigation/rules/progress.ts +230 -0
  720. package/src/navigation/rules/prompts.ts +217 -0
  721. package/src/navigation/rules/routeRequest.ts +98 -0
  722. package/src/navigation/rules/status.ts +142 -0
  723. package/src/navigation/rules/steps.ts +234 -0
  724. package/src/navigation/rules/types.ts +83 -0
  725. package/src/profile/index.ts +307 -0
  726. package/src/profile/rules/amenityBadge.ts +35 -0
  727. package/src/profile/rules/amenityFilter.ts +74 -0
  728. package/src/profile/rules/amenityStacks.ts +66 -0
  729. package/src/profile/rules/axis.ts +89 -0
  730. package/src/profile/rules/axisCulling.ts +83 -0
  731. package/src/profile/rules/axisLookup.ts +180 -0
  732. package/src/profile/rules/climbs.ts +292 -0
  733. package/src/profile/rules/cursorMarker.ts +122 -0
  734. package/src/profile/rules/cursorReadout.ts +104 -0
  735. package/src/profile/rules/curvePlacement.ts +216 -0
  736. package/src/profile/rules/dock.ts +293 -0
  737. package/src/profile/rules/elevation.ts +1263 -0
  738. package/src/profile/rules/instant.ts +89 -0
  739. package/src/profile/rules/intl.ts +237 -0
  740. package/src/profile/rules/legEmphasis.ts +53 -0
  741. package/src/profile/rules/profileColors.ts +66 -0
  742. package/src/profile/rules/profileLayout.ts +59 -0
  743. package/src/profile/rules/profileSlices.ts +55 -0
  744. package/src/profile/rules/routeProfile.ts +475 -0
  745. package/src/profile/rules/rowMatch.ts +50 -0
  746. package/src/profile/rules/scale.ts +646 -0
  747. package/src/profile/rules/scaleFrame.ts +171 -0
  748. package/src/profile/rules/sectionChips.ts +83 -0
  749. package/src/profile/rules/sections.ts +923 -0
  750. package/src/profile/rules/slopeRamp.ts +160 -0
  751. package/src/profile/rules/statStrip.ts +103 -0
  752. package/src/profile/rules/steepness.ts +51 -0
  753. package/src/profile/rules/tableCells.ts +269 -0
  754. package/src/profile/rules/tableCursor.ts +87 -0
  755. package/src/profile/rules/unitPatterns.ts +335 -0
  756. package/src/profile/rules/units.ts +1025 -0
  757. package/src/profile/rules/waypointCard.ts +590 -0
  758. package/src/profile/rules/webAddress.ts +130 -0
  759. package/src/profile/rules/windowSpans.ts +65 -0
  760. package/src/rules/asciiFold.ts +17 -0
  761. package/src/rules/inDevelopment.ts +54 -0
  762. package/src/rules/listeners.ts +62 -0
  763. package/src/rules/timers.ts +9 -0
  764. package/src/rules/types.ts +22 -0
  765. package/src/rules/uuid.ts +87 -0
  766. package/src/seams/engines/geolocateControl.ts +286 -0
  767. package/src/seams/index.ts +50 -0
  768. package/src/seams/rules/clock.ts +169 -0
  769. package/src/seams/rules/geolocation.ts +165 -0
  770. package/src/seams/rules/segmentRoute.ts +187 -0
  771. package/src/search/engines/search.ts +1093 -0
  772. package/src/search/index.ts +99 -0
  773. package/src/search/rules/describe.ts +383 -0
  774. package/src/search/rules/filters.ts +195 -0
  775. package/src/search/rules/highlight.ts +270 -0
  776. package/src/search/rules/pick.ts +90 -0
  777. package/src/search/rules/rows.ts +258 -0
  778. package/src/search/rules/searchFocus.ts +27 -0
  779. package/src/search/rules/searchViewport.ts +44 -0
  780. package/src/search/rules/shown.ts +77 -0
  781. package/src/search/rules/types.ts +340 -0
  782. package/src/stream/rules/reconnectSchedule.ts +83 -0
  783. package/src/style/engines/organizationRead.ts +80 -0
  784. package/src/style/index.ts +63 -0
  785. package/src/style/rules/apply.ts +268 -0
  786. package/src/style/rules/attribution.ts +119 -0
  787. package/src/style/rules/itineraryLine.ts +142 -0
  788. package/src/style/rules/language.ts +668 -0
  789. package/src/style/rules/layout.gen.ts +27 -0
  790. package/src/style/rules/organization.ts +96 -0
  791. package/src/style/rules/paint.ts +143 -0
  792. package/src/style/rules/panelLayout.ts +51 -0
  793. package/src/style/rules/roadAccessColors.ts +29 -0
  794. package/src/style/rules/roadAccessLine.ts +267 -0
  795. package/src/style/rules/segmentColors.ts +207 -0
  796. package/src/testing/catalogs.ts +103 -0
  797. package/src/testing/index.ts +30 -0
  798. package/src/testing/mapClient.ts +241 -0
  799. package/src/testing/mountayaMap.ts +741 -0
  800. package/src/timezone/index.ts +14 -0
  801. package/src/timezone/rules/viewport.ts +875 -0
  802. package/src/units/index.ts +55 -0
  803. package/src/units/rules/conversions.ts +620 -0
  804. package/src/units/rules/preferenceChoices.ts +124 -0
  805. package/src/units/rules/preferences.ts +77 -0
  806. package/src/units/rules/rounding.ts +69 -0
  807. package/src/video/engines/videoRun.ts +654 -0
  808. package/src/video/engines/viewClient.ts +6 -0
  809. package/src/video/index.ts +83 -0
  810. package/src/video/profileOverlay/rules/contract.ts +210 -0
  811. package/src/video/profileOverlay/rules/curve.ts +216 -0
  812. package/src/video/profileOverlay/rules/draw.ts +410 -0
  813. package/src/video/profileOverlay/rules/fonts.ts +54 -0
  814. package/src/video/profileOverlay/rules/graphDesign.ts +690 -0
  815. package/src/video/profileOverlay/rules/minimalDesign.ts +144 -0
  816. package/src/video/profileOverlay/rules/registry.ts +23 -0
  817. package/src/video/profileOverlay/rules/staticLayer.ts +582 -0
  818. package/src/video/profileOverlay/rules/stripDesign.ts +327 -0
  819. package/src/video/profileOverlay/rules/types.ts +78 -0
  820. package/src/video/rules/videoConstants.ts +250 -0
  821. package/src/video/rules/videoEncoder.ts +277 -0
  822. package/src/video/rules/videoFrames.ts +99 -0
  823. package/src/video/rules/videoPreview.ts +185 -0
  824. package/src/video/rules/videoRecorder.ts +746 -0
  825. package/src/video/rules/videoWatermark.ts +155 -0
  826. package/src/video/rules/watermarkMark.ts +40 -0
  827. package/src/view/engines/viewClient.ts +6 -0
  828. package/src/view/index.ts +20 -0
@@ -0,0 +1,1263 @@
1
+ /**
2
+ * Turning GeoJSON into a curve of meters-along against meters-up.
3
+ *
4
+ * Elevation is the third coordinate of a position (`[lng, lat, elevation]`), so an itinerary
5
+ * that carries one already carries its own profile, and reading it needs no request. That is
6
+ * the whole premise of this module and of the element built on it: an elevation profile is a
7
+ * projection of geometry a caller already holds, not a resource to fetch.
8
+ *
9
+ * Nothing here touches MapLibre. `@mountaya/elements-react` draws `<ItineraryProfile>` on
10
+ * top of these functions with no map anywhere in the tree.
11
+ */
12
+
13
+ import type { Feature, FeatureCollection, Geometry, LineString, Position } from "geojson";
14
+
15
+ import { haversineMeters, METERS_PER_DEGREE_MEAN_SPHERE } from "../../geo/rules/geodesy.js";
16
+ import { extractLines } from "../../geo/rules/geometry.js";
17
+ import { namesPlace, walkLine } from "../../geo/rules/lineWalk.js";
18
+ import { longitudeDelta, wrapLongitudePastRange } from "../../geo/rules/longitude.js";
19
+ import { convertSlope, DEGREES_TO_RADIANS } from "../../units/rules/conversions.js";
20
+ import { nearestIndexAt } from "./axisLookup.js";
21
+
22
+ /** Every GeoJSON shape a profile accepts. */
23
+ export type ProfileInput = Feature | FeatureCollection | Geometry;
24
+
25
+ /**
26
+ * One sample on the curve.
27
+ *
28
+ * The coordinate rides along with the measurements so a hover can place a map marker without
29
+ * walking the geometry a second time, and `index` is the sample's position in the series it
30
+ * came from, which is what a chart quantizes a pointer position down to.
31
+ */
32
+ export interface ElevationPoint {
33
+ /** Meters from the start of the itinerary, along the ground. */
34
+ readonly distance: number;
35
+ /** Meters above sea level. */
36
+ readonly elevation: number;
37
+ readonly lngLat: readonly [number, number];
38
+ /** Position in the series. Stable for as long as the series is. */
39
+ readonly index: number;
40
+ }
41
+
42
+ /**
43
+ * An itinerary, read for its profile.
44
+ *
45
+ * `totalDistance` is the whole itinerary, whether or not it carried elevation, so a fully 2D
46
+ * itinerary still states how long it is. `points` is only the part that had a third coordinate,
47
+ * which is why the two can disagree and why `hasElevation` is worth asking separately.
48
+ */
49
+ export interface ElevationSeries {
50
+ readonly points: readonly ElevationPoint[];
51
+ /** Meters, over every vertex walked, including ones that carried no elevation. */
52
+ readonly totalDistance: number;
53
+ readonly hasElevation: boolean;
54
+ readonly minElevation: number | null;
55
+ readonly maxElevation: number | null;
56
+ }
57
+
58
+ /**
59
+ * A stretch of the itinerary, in meters from its start.
60
+ *
61
+ * Declared here rather than beside the projections that consume it, because a range is a fact
62
+ * about an itinerary in the same category as an `ElevationPoint`, and because `scale.ts` already
63
+ * imports this module, so declaring it there would make the pair a cycle.
64
+ */
65
+ export interface ProfileRange {
66
+ readonly from: number;
67
+ readonly to: number;
68
+ }
69
+
70
+ /**
71
+ * The narrowest window a chart is drawn over.
72
+ *
73
+ * A window of zero width divides by zero in every projection downstream, and a controlled
74
+ * caller holding one in their own state has no way to see that they do: the chart simply
75
+ * renders nothing. A floor is the only place that can be answered once.
76
+ */
77
+ export const MIN_RANGE_SPAN_METERS = 100;
78
+
79
+ /** A marker projected onto the itinerary, at the distance the itinerary passes closest to it. */
80
+ export interface ProjectedMarker {
81
+ readonly id: string;
82
+ /** Meters from the start. */
83
+ readonly distance: number;
84
+ }
85
+
86
+ /** A marker to project, given as a coordinate. */
87
+ export interface MarkerToProject {
88
+ readonly id: string;
89
+ readonly lngLat: readonly [number, number];
90
+ }
91
+
92
+ /**
93
+ * How many samples a series is thinned to.
94
+ *
95
+ * A recorded track carries tens of thousands of vertices and a chart 800 pixels wide can
96
+ * show a few hundred of them. Beyond that the extra points cost render time and change no
97
+ * pixel, and the thinning is a uniform stride, so it changes the curve's resolution rather
98
+ * than its shape.
99
+ */
100
+ export const MAX_PROFILE_POINTS = 500;
101
+
102
+ /**
103
+ * How close the itinerary must pass to a marker for that approach to count as a PASS.
104
+ *
105
+ * Tight, and tight on purpose: this is what separates one close pass from the next, so a
106
+ * lollipop's junction is marked twice rather than smeared into one long approach. It is not
107
+ * what decides whether a place belongs to the itinerary at all: {@link MARKER_BELONGING_METERS}
108
+ * is.
109
+ */
110
+ export const MARKER_PROXIMITY_METERS = 60;
111
+
112
+ /**
113
+ * How far off the line a place may still be one of the itinerary's own.
114
+ *
115
+ * The two radii answer different questions, and one radius cannot answer both. On the Tour du
116
+ * Mont-Blanc (a real, published itinerary), four of its seventeen aid stations sit 105 to 254
117
+ * meters off the trail, because an aid station is a building in a village and the trail goes
118
+ * past the village. Read at the tight radius alone, they are not "one pass or two", they are
119
+ * *nothing*: no pin on the profile, no name under the axis, no row in the table, on every
120
+ * surface, silently.
121
+ *
122
+ * So the tight radius decides how many passes, and this one decides belonging.
123
+ * {@link resolveWaypoints} falls back to the single nearest point on the line for a place with no
124
+ * pass, which is exactly where a reader looks for a hut beside the path. Two kilometers is well
125
+ * past any plausible aid station and well short of a marker on the other side of the massif.
126
+ */
127
+ export const MARKER_BELONGING_METERS = 2_000;
128
+
129
+ /**
130
+ * The vertical movement a stretch must accumulate before it counts as climb or descent.
131
+ *
132
+ * Ascent summed straight from DEM-sampled coordinates is dominated by sampling noise: every
133
+ * meter of error is counted once going up and once coming back down, so a flat road can
134
+ * report hundreds of meters of climb. A hysteresis of a few meters removes almost all of it
135
+ * at the cost of clipping the last few meters of each genuine climb, which is the better
136
+ * trade in both directions.
137
+ */
138
+ export const ELEVATION_NOISE_THRESHOLD_METERS = 5;
139
+
140
+ /**
141
+ * The run over which a maximum grade is measured.
142
+ *
143
+ * A grade taken between two adjacent vertices is a ratio of two noisy numbers over a very
144
+ * short run, and it reports absurd steepness on flat ground. Measuring over a fixed distance
145
+ * makes the figure mean "the steepest hundred meters of this itinerary", which is a thing a
146
+ * reader can act on.
147
+ */
148
+ export const GRADE_WINDOW_METERS = 100;
149
+
150
+ /**
151
+ * geometriesOf reduces any accepted input to the geometries inside it.
152
+ *
153
+ * `Feature` and `FeatureCollection` are unwrapped rather than rejected because both are what
154
+ * a caller actually holds: an itinerary read from the API is a geometry, a track parsed from
155
+ * a GPX file is usually a feature, and making one of them the caller's problem buys nothing.
156
+ *
157
+ * Exported within the package for `chainGeometry`, which concatenates a chain of these into the
158
+ * one collection a profile walks. Not published: a caller wanting the lines wants
159
+ * {@link profileLines}, which is the same walk carried through to coordinates.
160
+ */
161
+ export const geometriesOf = (input: ProfileInput | null | undefined): Geometry[] => {
162
+ if (!input) {
163
+ return [];
164
+ }
165
+
166
+ if (input.type === "FeatureCollection") {
167
+ return input.features.flatMap((feature) => (feature.geometry ? [feature.geometry] : []));
168
+ }
169
+
170
+ if (input.type === "Feature") {
171
+ return input.geometry ? [input.geometry] : [];
172
+ }
173
+
174
+ return [input];
175
+ };
176
+
177
+ /**
178
+ * profileLines returns every line in the input, in document order, as coordinate arrays.
179
+ *
180
+ * The lines are the ones {@link extractLines} answers for each geometry the input holds: a
181
+ * `LineString` at any depth of a `GeometryCollection` and each line of a `MultiLineString`. An
182
+ * itinerary stored as a `MultiLineString` is what most GPX-to-GeoJSON converters write for a
183
+ * file of several tracks, and profiling it as empty would read as a blank chart.
184
+ *
185
+ * Anything that is no line is ignored, which is what lets a directions segment profile without
186
+ * being unwrapped first: the `MultiPoint` of vias beside its routed line is no part of the
187
+ * itinerary's shape.
188
+ *
189
+ * @param input The itinerary's geometry, or nothing.
190
+ * @returns The lines, each one the input's own array and not a copy: it is typed `readonly`
191
+ * because a position pushed onto it would be pushed onto the itinerary that was profiled. A
192
+ * caller that edits a line copies it first.
193
+ */
194
+ export const profileLines = (input: ProfileInput | null | undefined): (readonly Position[])[] => {
195
+ const lines: (readonly Position[])[] = [];
196
+ for (const geometry of geometriesOf(input)) {
197
+ for (const line of extractLines(geometry)) {
198
+ lines.push(line.coordinates);
199
+ }
200
+ }
201
+
202
+ return lines;
203
+ };
204
+
205
+ // Published from here, where a profile's distances are, and declared in `geo/rules/geodesy.ts`
206
+ // beside the radius it measures with, so an entry that measures without profiling reaches it
207
+ // without this module.
208
+ export { haversineMeters } from "../../geo/rules/geodesy.js";
209
+
210
+ /**
211
+ * downsampleElevation thins a series to at most `maxPoints` with a uniform stride.
212
+ *
213
+ * The last sample is appended explicitly rather than left to the stride, so the curve always
214
+ * reaches the itinerary's true end distance: a profile that stops 200 m short of the summit is
215
+ * wrong in exactly the place a reader is looking.
216
+ *
217
+ * Slot `k` of the others keeps the sample nearest `k × (count − 1) / (maxPoints − 1)`, and of two
218
+ * equally near, the later: a slot standing halfway between two samples keeps the second. The
219
+ * position is computed in whole numbers, so a half is a half: 504 samples thinned to 499 put slot
220
+ * 249 at exactly 251.5, and it keeps sample 252.
221
+ *
222
+ * A cap under two keeps every sample, as `Infinity` does: a curve needs both its ends, so there is
223
+ * no thinner series that still draws the itinerary. A cap that is no whole number is read as the
224
+ * whole number under it, and one that is no number keeps every sample.
225
+ *
226
+ * @param points The series' samples, ascending by distance.
227
+ * @param maxPoints The most samples to keep.
228
+ * @returns A new list of samples, each re-indexed to its place in it.
229
+ */
230
+ export const downsampleElevation = (
231
+ points: readonly ElevationPoint[],
232
+ maxPoints: number,
233
+ ): ElevationPoint[] => {
234
+ const ceiling = Math.floor(maxPoints);
235
+ if (!(ceiling >= 2) || points.length <= ceiling) {
236
+ return points.map((point, index) => ({ ...point, index }));
237
+ }
238
+
239
+ // The nearest whole index to `slot × last / slots`, a half up, is
240
+ // floor((2 × slot × last + slots) / (2 × slots)). Every term is a whole number well under
241
+ // 2^53, so the remainder is exact and the quotient is the floor itself: a stride in floating
242
+ // point reads 249 × 503 / 498, which is 251.5, as 251.49999999999997 and keeps the earlier one.
243
+ const last = points.length - 1;
244
+ const slots = ceiling - 1;
245
+ const denominator = 2 * slots;
246
+ const sampled: ElevationPoint[] = [];
247
+ for (let slot = 0; slot < slots; slot += 1) {
248
+ const numerator = 2 * slot * last + slots;
249
+ const point = points[(numerator - (numerator % denominator)) / denominator];
250
+ if (point) {
251
+ sampled.push({ ...point, index: sampled.length });
252
+ }
253
+ }
254
+
255
+ const lastPoint = points[last];
256
+ if (lastPoint) {
257
+ sampled.push({ ...lastPoint, index: sampled.length });
258
+ }
259
+
260
+ return sampled;
261
+ };
262
+
263
+ /**
264
+ * buildElevationSeries walks every line in the input and reads its third coordinate.
265
+ *
266
+ * Lines are walked head-to-tail in document order and concatenated onto one distance axis,
267
+ * so an itinerary stored as several segments profiles as one curve. **The jump between two lines
268
+ * contributes no distance**: the gap between where one segment ends and the next begins is
269
+ * a seam in the storage, not ground anyone covers.
270
+ *
271
+ * A vertex without a third coordinate advances the distance but emits no sample, so a
272
+ * partially 3D itinerary bridges its gap with a straight line rather than breaking in two: a
273
+ * hole in the DEM is not a hole in the itinerary. A fully 2D itinerary emits no samples at all and
274
+ * still reports its length, which is what lets a caller state the distance beside an empty
275
+ * chart instead of an empty panel.
276
+ *
277
+ * A vertex that names no place, one whose longitude or latitude is missing or no finite number,
278
+ * emits no sample and charges no distance: the line is measured across it, from the last vertex
279
+ * that names a place to the next ({@link walkLine}). Read on, it would turn every later
280
+ * distance, and the total, into `NaN`.
281
+ *
282
+ * **Memoized on the input's identity**, because the same geometry is profiled by more than one
283
+ * surface at a time: an elevation chart, a segment table's sparkline column and a waypoint
284
+ * table all read the same itinerary, each through its own `useMemo`, and a `useMemo` is per
285
+ * component, so three components holding the same object would walk it three times. The walk
286
+ * is a haversine per vertex over a recorded track of tens of thousands of them, so the third
287
+ * walk costs as much as the first.
288
+ *
289
+ * **The input is read as a value that does not change under its identity**, with one exception
290
+ * the memo sees for itself: a geometry that gains or loses a vertex or a line in place, as a
291
+ * live recording does, is walked again. A position rewritten in place is not seen, because
292
+ * comparing positions is the walk the memo exists to skip, so a caller that edits one hands a
293
+ * new object.
294
+ *
295
+ * Safe to share because {@link ElevationSeries} is readonly at every level, which is what makes
296
+ * one result answerable to several callers rather than something each of them can edit under
297
+ * the others.
298
+ *
299
+ * @param input The itinerary's geometry, or nothing, which reads as an itinerary of no length.
300
+ * @param maxPoints The most samples the series keeps ({@link downsampleElevation}).
301
+ * @default maxPoints {@link MAX_PROFILE_POINTS}
302
+ */
303
+ export const buildElevationSeries = (
304
+ input: ProfileInput | null | undefined,
305
+ maxPoints: number = MAX_PROFILE_POINTS,
306
+ ): ElevationSeries => {
307
+ const lines = profileLines(input);
308
+ if (!input) {
309
+ return walkElevationSeries(lines, maxPoints);
310
+ }
311
+
312
+ const shape = lines.map((coordinates) => coordinates.length).join(",");
313
+ const byMaxPoints = elevationSeries.get(input);
314
+ const memoized = byMaxPoints?.get(maxPoints);
315
+ if (memoized !== undefined && memoized.shape === shape) {
316
+ return memoized.series;
317
+ }
318
+
319
+ const series = walkElevationSeries(lines, maxPoints);
320
+
321
+ if (byMaxPoints === undefined) {
322
+ elevationSeries.set(input, new Map([[maxPoints, { series, shape }]]));
323
+ } else {
324
+ byMaxPoints.set(maxPoints, { series, shape });
325
+ }
326
+
327
+ return series;
328
+ };
329
+
330
+ /** A memoized series, with what its geometry held when it was walked. */
331
+ interface MemoizedSeries {
332
+ readonly series: ElevationSeries;
333
+ /** How many positions each line held, in order: what an append or a removal in place changes. */
334
+ readonly shape: string;
335
+ }
336
+
337
+ /**
338
+ * Series by the geometry they were read from, then by the sample cap.
339
+ *
340
+ * Weak on the geometry, which is the object a caller holds (a query cache entry, a store
341
+ * field), so an itinerary that goes out of scope takes its series with it. The inner map is
342
+ * keyed by `maxPoints` because it changes the result: a caller thinning to a sparkline's width
343
+ * and one drawing a full chart ask the same question of the same geometry and must not receive
344
+ * each other's answer.
345
+ */
346
+ const elevationSeries = new WeakMap<ProfileInput, Map<number, MemoizedSeries>>();
347
+
348
+ /** The walk itself, which {@link buildElevationSeries} memoizes. */
349
+ const walkElevationSeries = (
350
+ lines: readonly (readonly Position[])[],
351
+ maxPoints: number,
352
+ ): ElevationSeries => {
353
+ const raw: ElevationPoint[] = [];
354
+ let distance = 0;
355
+ let minElevation: number | null = null;
356
+ let maxElevation: number | null = null;
357
+
358
+ for (const coordinates of lines) {
359
+ distance = walkLine(coordinates, distance, haversineMeters, (at, vertex) => {
360
+ const elevation = vertex?.[2];
361
+ if (vertex === null || elevation === undefined || !Number.isFinite(elevation)) {
362
+ return;
363
+ }
364
+
365
+ const [lng = 0, lat = 0] = vertex;
366
+ raw.push({ distance: at, elevation, index: raw.length, lngLat: [lng, lat] });
367
+ minElevation = minElevation === null ? elevation : Math.min(minElevation, elevation);
368
+ maxElevation = maxElevation === null ? elevation : Math.max(maxElevation, elevation);
369
+ });
370
+ }
371
+
372
+ return {
373
+ hasElevation: raw.length > 0,
374
+ maxElevation,
375
+ minElevation,
376
+ points: downsampleElevation(raw, maxPoints),
377
+ totalDistance: distance,
378
+ };
379
+ };
380
+
381
+ /**
382
+ * profileLength measures what {@link buildElevationSeries} would walk, and nothing else.
383
+ *
384
+ * The rule it has to reproduce exactly is the one the series keeps: distance accumulates WITHIN
385
+ * each line, and the jump from one line's end to the next line's start costs nothing. That is
386
+ * what lets an itinerary stored as twelve legs profile as one curve, and it is also what makes
387
+ * a leg's span on that curve computable from the leg's own geometry alone.
388
+ *
389
+ * Separate from the series because the two answer different questions: the series needs a
390
+ * running distance per vertex, this needs one total. `elevation.test.ts` pins them equal over
391
+ * every input shape, which is the only thing standing between them and a silent drift that
392
+ * would slide every sparkline highlight off the curve it is drawn over.
393
+ *
394
+ * A vertex with no elevation still advances the distance, exactly as it does in the series, and
395
+ * a vertex that names no place is measured across, as the series measures across it.
396
+ *
397
+ * @returns The length in meters, 0 for an input with no line.
398
+ */
399
+ export const profileLength = (input: ProfileInput | null | undefined): number => {
400
+ let distance = 0;
401
+
402
+ for (const coordinates of profileLines(input)) {
403
+ distance = walkLine(coordinates, distance, haversineMeters);
404
+ }
405
+
406
+ return distance;
407
+ };
408
+
409
+ /** Reads the distance a sample stands at, for {@link nearestIndexAt}. */
410
+ const sampleDistance = (point: ElevationPoint): number => point.distance;
411
+
412
+ /**
413
+ * nearestPointIndexAt binary-searches the series for the sample closest to a distance.
414
+ *
415
+ * `-1` for an empty series. Ties favour the lower index, so a scrub that lands exactly
416
+ * between two samples resolves the same way every time rather than flickering between them.
417
+ * A distance before the first or past the last sample clamps to that endpoint.
418
+ */
419
+ export const nearestPointIndexAt = (points: readonly ElevationPoint[], distance: number): number =>
420
+ nearestIndexAt(points, distance, sampleDistance);
421
+
422
+ /** activePointAt returns the sample nearest a distance, or null for an empty series. */
423
+ export const activePointAt = (
424
+ points: readonly ElevationPoint[],
425
+ distance: number,
426
+ ): ElevationPoint | null => {
427
+ const index = nearestPointIndexAt(points, distance);
428
+
429
+ return index < 0 ? null : (points[index] ?? null);
430
+ };
431
+
432
+ /**
433
+ * firstIndexAtOrPast binary-searches the series for the first sample at or past a distance.
434
+ *
435
+ * `points.length` where every sample stands before it.
436
+ */
437
+ const firstIndexAtOrPast = (points: readonly ElevationPoint[], distance: number): number => {
438
+ let low = 0;
439
+ let high = points.length;
440
+ while (low < high) {
441
+ const mid = (low + high) >> 1;
442
+ if ((points[mid]?.distance ?? 0) < distance) {
443
+ low = mid + 1;
444
+ } else {
445
+ high = mid;
446
+ }
447
+ }
448
+
449
+ return low;
450
+ };
451
+
452
+ /** The two samples a distance stands between, and how far from the first to the second. */
453
+ interface SampleBracket {
454
+ readonly before: ElevationPoint;
455
+ readonly after: ElevationPoint;
456
+ /** From 0 at `before` to 1 at `after`. Always 0 where the two are one sample. */
457
+ readonly ratio: number;
458
+ }
459
+
460
+ /**
461
+ * bracketAt finds the two samples either side of a distance.
462
+ *
463
+ * The curve between two samples is the straight line a chart draws between them, so a reading
464
+ * at a distance is a reading on that line. A distance that is a sample's own answers that sample
465
+ * twice, which keeps its figures exact instead of sending them through an interpolation that
466
+ * returns them a digit off. Outside the samples the nearer end answers, the clamp
467
+ * {@link nearestPointIndexAt} keeps.
468
+ *
469
+ * `null` for an empty series and for a distance that is not a number.
470
+ */
471
+ const bracketAt = (points: readonly ElevationPoint[], distance: number): SampleBracket | null => {
472
+ const first = points[0];
473
+ const last = points.at(-1);
474
+ if (first === undefined || last === undefined || Number.isNaN(distance)) {
475
+ return null;
476
+ }
477
+
478
+ if (distance <= first.distance) {
479
+ return { after: first, before: first, ratio: 0 };
480
+ }
481
+
482
+ if (distance >= last.distance) {
483
+ return { after: last, before: last, ratio: 0 };
484
+ }
485
+
486
+ const index = firstIndexAtOrPast(points, distance);
487
+ const after = points[index];
488
+ const before = points[index - 1];
489
+ if (after === undefined || before === undefined) {
490
+ return null;
491
+ }
492
+
493
+ if (after.distance === distance) {
494
+ return { after, before: after, ratio: 0 };
495
+ }
496
+
497
+ const run = after.distance - before.distance;
498
+
499
+ return { after, before, ratio: run > 0 ? (distance - before.distance) / run : 0 };
500
+ };
501
+
502
+ /**
503
+ * elevationAt reads the curve's altitude at a distance, in meters above sea level.
504
+ *
505
+ * Read on the straight line between the two samples either side of the distance, which is the
506
+ * line a chart draws: a pin placed by this reading sits on the curve, where the nearest sample's
507
+ * altitude sets it above or below a curve thinned to a sample every few hundred meters. A
508
+ * distance before the first or past the last sample reads that end's altitude.
509
+ *
510
+ * It is the reading `placeOnCurve` sets a pin by and a waypoint row states its altitude with, so
511
+ * a binding that draws its own mark at a distance reads this to stand it at the same height.
512
+ * {@link activePointAt} answers the nearest sample instead, which is what a scrub resolves to.
513
+ *
514
+ * @param points The series' samples, ascending by distance.
515
+ * @param distance Meters from the start of the itinerary.
516
+ * @returns The altitude, or `null` for an empty series and for a distance that is not a number.
517
+ */
518
+ export const elevationAt = (points: readonly ElevationPoint[], distance: number): number | null => {
519
+ const bracket = bracketAt(points, distance);
520
+
521
+ return bracket === null
522
+ ? null
523
+ : bracket.before.elevation +
524
+ (bracket.after.elevation - bracket.before.elevation) * bracket.ratio;
525
+ };
526
+
527
+ /**
528
+ * positionAt reads where the curve stands on the ground at a distance, as `[lng, lat]`.
529
+ *
530
+ * The same line {@link elevationAt} reads, followed the short way round where two samples stand
531
+ * either side of the antimeridian.
532
+ */
533
+ const positionAt = (points: readonly ElevationPoint[], distance: number): Position | null => {
534
+ const bracket = bracketAt(points, distance);
535
+ if (bracket === null) {
536
+ return null;
537
+ }
538
+
539
+ const [fromLng, fromLat] = bracket.before.lngLat;
540
+ const [toLng, toLat] = bracket.after.lngLat;
541
+ if (bracket.ratio === 0) {
542
+ return [fromLng, fromLat];
543
+ }
544
+
545
+ return [
546
+ wrapLongitudePastRange(fromLng + longitudeDelta(fromLng, toLng) * bracket.ratio),
547
+ fromLat + (toLat - fromLat) * bracket.ratio,
548
+ ];
549
+ };
550
+
551
+ /**
552
+ * startIndexAt finds the sample a stretch that starts at a distance sets out from: the last one
553
+ * standing at that distance, or -1 where none stands there and the start is read between two.
554
+ *
555
+ * The jump between two lines adds no distance, so where two lines meet the earlier line's last
556
+ * sample and the later line's first stand at one distance, at two places and two altitudes. A
557
+ * stretch that ends there is on the earlier line, which is the sample {@link bracketAt} answers,
558
+ * and one that starts there is on the later line.
559
+ */
560
+ const startIndexAt = (points: readonly ElevationPoint[], distance: number): number => {
561
+ let index = firstIndexAtOrPast(points, distance);
562
+ if (points[index]?.distance !== distance) {
563
+ return -1;
564
+ }
565
+
566
+ while (points[index + 1]?.distance === distance) {
567
+ index += 1;
568
+ }
569
+
570
+ return index;
571
+ };
572
+
573
+ /** startElevationAt reads the altitude a stretch that starts at a distance sets out from. */
574
+ const startElevationAt = (points: readonly ElevationPoint[], distance: number): number | null =>
575
+ points[startIndexAt(points, distance)]?.elevation ?? elevationAt(points, distance);
576
+
577
+ /** The lowest and highest altitude of a stretch, in meters above sea level. */
578
+ interface AltitudeBand {
579
+ readonly min: number;
580
+ readonly max: number;
581
+ }
582
+
583
+ /**
584
+ * altitudeBand reads the lowest and highest altitude the curve reaches between two distances.
585
+ *
586
+ * The samples the stretch holds and the curve read at its two ends, so a stretch shorter than the
587
+ * gap between two samples still has a band: the one between its ends. Only the part of the
588
+ * stretch the samples reach is read, and a stretch that lies wholly before the first sample or
589
+ * past the last has no band. Where two lines meet at an end of the stretch, the band holds the
590
+ * sample of the line the stretch is on and not the other's.
591
+ *
592
+ * Folded, never spread into `Math.min` and `Math.max`: a series built with no sample cap keeps
593
+ * every fix of a long recording, more than a call takes arguments.
594
+ *
595
+ * @param points The series' samples, ascending by distance.
596
+ * @param from Where the stretch starts, in meters from the start of the itinerary.
597
+ * @param to Where the stretch ends. At or past `from`.
598
+ * @returns The band, or `null` where the stretch holds none of the curve.
599
+ */
600
+ export const altitudeBand = (
601
+ points: readonly ElevationPoint[],
602
+ from: number,
603
+ to: number,
604
+ ): AltitudeBand | null => {
605
+ const first = points[0];
606
+ const last = points.at(-1);
607
+ if (first === undefined || last === undefined) {
608
+ return null;
609
+ }
610
+
611
+ const low = Math.max(from, first.distance);
612
+ const high = Math.min(to, last.distance);
613
+ const start = startElevationAt(points, low);
614
+ const end = elevationAt(points, high);
615
+ if (!(high >= low) || start === null || end === null) {
616
+ return null;
617
+ }
618
+
619
+ // From the sample the stretch sets out from, or the first past its start, to the first
620
+ // standing at its end: the samples before and after those at the two ends are another line's.
621
+ const setsOutFrom = startIndexAt(points, low);
622
+ const firstHeld = setsOutFrom < 0 ? firstIndexAtOrPast(points, low) : setsOutFrom;
623
+ const lastHeld = firstIndexAtOrPast(points, high);
624
+
625
+ let min = Math.min(start, end);
626
+ let max = Math.max(start, end);
627
+ for (let index = firstHeld; index <= lastHeld; index += 1) {
628
+ const point = points[index];
629
+ if (point === undefined || point.distance > high) {
630
+ break;
631
+ }
632
+
633
+ min = Math.min(min, point.elevation);
634
+ max = Math.max(max, point.elevation);
635
+ }
636
+
637
+ return { max, min };
638
+ };
639
+
640
+ /**
641
+ * lineBetween cuts the stretch of itinerary between two distances out of a series.
642
+ *
643
+ * What a hovered leg is, as a geometry: the same samples the chart drew and the same span the
644
+ * sparkline lights, so a leg emphasised on a map is the leg stated in the row beside it rather
645
+ * than a second answer that usually agrees.
646
+ *
647
+ * Off the SERIES rather than off the leg's own `geojson`, and the difference matters on a
648
+ * collapsed group: a run of legs is one row with one span and no geometry of its own, and a
649
+ * caller reassembling its members' lines would have to know which members it collapsed.
650
+ *
651
+ * The line starts and ends where the stretch does, each end read on the curve between the two
652
+ * samples either side of it, with the samples the stretch holds between them. So a leg shorter
653
+ * than the gap between two samples is still a line, and a longer one is not cut short at the
654
+ * last sample inside it. A stretch that runs past the samples stops at the first or the last.
655
+ * Where two lines meet at an end of the stretch, the line starts on the later of the two and
656
+ * ends on the earlier.
657
+ *
658
+ * @param points The series' samples, ascending by distance.
659
+ * @param from Where the stretch starts, in meters from the start of the itinerary.
660
+ * @param to Where the stretch ends, in meters from the start of the itinerary.
661
+ * @returns The stretch as a `LineString`, or `null` where it holds no length of the curve: an
662
+ * empty series, a span that is inverted or collapsed, or one that lies wholly outside the
663
+ * samples.
664
+ */
665
+ export const lineBetween = (
666
+ points: readonly ElevationPoint[],
667
+ from: number,
668
+ to: number,
669
+ ): LineString | null => {
670
+ const first = points[0];
671
+ const last = points.at(-1);
672
+ if (first === undefined || last === undefined) {
673
+ return null;
674
+ }
675
+
676
+ const low = Math.max(from, first.distance);
677
+ const high = Math.min(to, last.distance);
678
+ const setsOutFrom = points[startIndexAt(points, low)]?.lngLat;
679
+ const start =
680
+ setsOutFrom === undefined ? positionAt(points, low) : [setsOutFrom[0], setsOutFrom[1]];
681
+ const end = positionAt(points, high);
682
+ if (!(high > low) || start === null || end === null) {
683
+ return null;
684
+ }
685
+
686
+ const coordinates: Position[] = [start];
687
+ for (let index = firstIndexAtOrPast(points, low); index < points.length; index += 1) {
688
+ const point = points[index];
689
+ if (point === undefined || point.distance >= high) {
690
+ break;
691
+ }
692
+
693
+ if (point.distance > low) {
694
+ coordinates.push([point.lngLat[0], point.lngLat[1]]);
695
+ }
696
+ }
697
+
698
+ coordinates.push(end);
699
+
700
+ return { coordinates, type: "LineString" };
701
+ };
702
+
703
+ /** One leg of the walked lines: its two ends, and where it stands on the distance axis. */
704
+ interface WalkedLeg {
705
+ readonly previous: Position;
706
+ readonly current: Position;
707
+ /** Meters from the start of the itinerary to the leg's first end. */
708
+ readonly start: number;
709
+ /** The leg's own length. */
710
+ readonly meters: number;
711
+ }
712
+
713
+ /**
714
+ * walkLegs lists every leg of every line on the distance axis {@link buildElevationSeries}
715
+ * draws against.
716
+ *
717
+ * Distance accumulates within a line. The jump from one line's end to the next line's start
718
+ * costs none and is no leg: nothing travels it, so nothing can be near it. A vertex that names
719
+ * no place ({@link namesPlace}) ends no leg: the leg runs from the vertex before it that names
720
+ * one to the next that does.
721
+ */
722
+ const walkLegs = (lines: readonly (readonly Position[])[]): WalkedLeg[] => {
723
+ const legs: WalkedLeg[] = [];
724
+ let distance = 0;
725
+
726
+ for (const coordinates of lines) {
727
+ let previous: Position | null = null;
728
+ for (const current of coordinates) {
729
+ if (!namesPlace(current)) {
730
+ continue;
731
+ }
732
+
733
+ if (previous !== null) {
734
+ const meters = haversineMeters(previous, current);
735
+ legs.push({ current, meters, previous, start: distance });
736
+ distance += meters;
737
+ }
738
+
739
+ previous = current;
740
+ }
741
+ }
742
+
743
+ return legs;
744
+ };
745
+
746
+ /** The closest approach of one leg to a marker: how near it came, and where along the itinerary. */
747
+ interface LegApproach {
748
+ readonly distance: number;
749
+ readonly meters: number;
750
+ }
751
+
752
+ /**
753
+ * legApproach projects a marker onto one leg in a local east/north metric frame.
754
+ *
755
+ * The frame's origin is the leg's start, and longitude is scaled by `cos(latitude)` there so a
756
+ * degree east and a degree north are the same number of meters, which makes the projection
757
+ * ordinary plane geometry. The approximation is exact enough over a leg (tens of meters) and
758
+ * wrong only at a scale no leg reaches.
759
+ *
760
+ * Each longitude is read as the short way from the leg's start, so a marker written a whole
761
+ * turn from the line, or across the antimeridian from it, measures the meters it stands off it.
762
+ */
763
+ const legApproach = (leg: WalkedLeg, marker: Position): LegApproach => {
764
+ const [aLng = 0, aLat = 0] = leg.previous;
765
+ const [bLng = 0, bLat = 0] = leg.current;
766
+ const [wLng = 0, wLat = 0] = marker;
767
+
768
+ const toMeters = METERS_PER_DEGREE_MEAN_SPHERE;
769
+ const lngToMeters = Math.cos(aLat * DEGREES_TO_RADIANS) * toMeters;
770
+ const dx = longitudeDelta(aLng, bLng) * lngToMeters;
771
+ const dy = (bLat - aLat) * toMeters;
772
+ const wx = longitudeDelta(aLng, wLng) * lngToMeters;
773
+ const wy = (wLat - aLat) * toMeters;
774
+
775
+ const lengthSq = dx * dx + dy * dy;
776
+ // A zero-length leg has no direction to project along, so the foot is its start point.
777
+ const t = lengthSq === 0 ? 0 : Math.min(1, Math.max(0, (wx * dx + wy * dy) / lengthSq));
778
+
779
+ return {
780
+ distance: leg.start + leg.meters * t,
781
+ meters: Math.hypot(wx - dx * t, wy - dy * t),
782
+ };
783
+ };
784
+
785
+ /** One close pass of the itinerary by a marker: where its nearest point is, and how far off. */
786
+ export interface MarkerPass extends ProjectedMarker {
787
+ /** Meters between the marker and the itinerary at the pass's nearest point. */
788
+ readonly meters: number;
789
+ }
790
+
791
+ /**
792
+ * markerPasses finds each close pass of the itinerary by each marker, with how near it came.
793
+ *
794
+ * What {@link projectMarkers} publishes without the last figure. Within the package it is how
795
+ * {@link resolveWaypoints} tells a place's nearest pass from an earlier, wider one.
796
+ *
797
+ * @param input The itinerary's geometry.
798
+ * @param markers The markers to place.
799
+ * @param proximityMeters How near the itinerary must pass for the approach to count.
800
+ * @returns One entry per marker per pass, grouped by marker in the order given, each marker's
801
+ * passes in itinerary order.
802
+ */
803
+ export const markerPasses = (
804
+ input: ProfileInput | null | undefined,
805
+ markers: readonly MarkerToProject[],
806
+ proximityMeters: number,
807
+ ): MarkerPass[] => {
808
+ if (markers.length === 0) {
809
+ return [];
810
+ }
811
+
812
+ const legs = walkLegs(profileLines(input));
813
+ const passes: MarkerPass[] = [];
814
+ for (const marker of markers) {
815
+ const coordinate: Position = [marker.lngLat[0], marker.lngLat[1]];
816
+ // The nearest approach seen since the itinerary last came within range. A leg out of range
817
+ // closes the open pass and emits it.
818
+ let best: LegApproach | null = null;
819
+ for (const leg of legs) {
820
+ const approach = legApproach(leg, coordinate);
821
+ if (approach.meters <= proximityMeters) {
822
+ if (!best || approach.meters < best.meters) {
823
+ best = approach;
824
+ }
825
+
826
+ continue;
827
+ }
828
+
829
+ if (best) {
830
+ passes.push({ distance: best.distance, id: marker.id, meters: best.meters });
831
+ best = null;
832
+ }
833
+ }
834
+
835
+ // A pass still open when the itinerary ends emits its closest point too.
836
+ if (best) {
837
+ passes.push({ distance: best.distance, id: marker.id, meters: best.meters });
838
+ }
839
+ }
840
+
841
+ return passes;
842
+ };
843
+
844
+ /**
845
+ * projectMarkers places each marker on the distance axis wherever the itinerary passes near it.
846
+ *
847
+ * A marker can yield **several** projections, and that is the interesting case: each
848
+ * contiguous run of near legs is one close pass, collapsed to its single nearest point, so an
849
+ * itinerary that doubles back past a hut marks it once per pass rather than once per leg, and a
850
+ * lollipop itinerary marks its junction twice, which is what a reader scrubbing the chart
851
+ * expects to find. A marker the itinerary never approaches yields nothing.
852
+ *
853
+ * The lines are walked exactly as {@link buildElevationSeries} walks them, so a projection's
854
+ * distance lands on the same axis the curve was drawn against: the jump between two lines adds
855
+ * no distance, and a marker beside that jump is near no leg of it.
856
+ *
857
+ * @param input The itinerary's geometry.
858
+ * @param markers The markers to place.
859
+ * @param proximityMeters How near the itinerary must pass for the approach to count as a pass.
860
+ * @default proximityMeters {@link MARKER_PROXIMITY_METERS}
861
+ * @returns One projection per marker per pass, grouped by marker in the order given.
862
+ */
863
+ export const projectMarkers = (
864
+ input: ProfileInput | null | undefined,
865
+ markers: readonly MarkerToProject[],
866
+ proximityMeters: number = MARKER_PROXIMITY_METERS,
867
+ ): ProjectedMarker[] =>
868
+ markerPasses(input, markers, proximityMeters).map(({ distance, id }) => ({ distance, id }));
869
+
870
+ /**
871
+ * gradeAt reports how steep the itinerary is at a distance, in degrees.
872
+ *
873
+ * Measured over a {@link GRADE_WINDOW_METERS} run centred on the point rather than between
874
+ * the two samples either side of it, for the same reason {@link profileTotals} measures its
875
+ * maximum that way: a ratio of two noisy elevations over a ten-meter run reports a cliff on
876
+ * flat ground, and a readout that does that is worse than no readout.
877
+ *
878
+ * Each end of the run is read on the curve between the two samples either side of it, so the
879
+ * run is the same width whatever the samples' spacing: a long itinerary thinned to a sample
880
+ * every few hundred meters reads the slope of the line between a sample's neighbours. Near
881
+ * either end of the itinerary the run is the part of the window the curve holds.
882
+ *
883
+ * Signed, so a descent reads negative.
884
+ *
885
+ * @param points The series' samples, ascending by distance.
886
+ * @param distance Meters from the start of the itinerary.
887
+ * @returns The grade, or `null` where the window holds no length of the curve: fewer than two
888
+ * samples, or a distance further from the curve than half the window.
889
+ */
890
+ export const gradeAt = (points: readonly ElevationPoint[], distance: number): number | null => {
891
+ const first = points[0];
892
+ const last = points.at(-1);
893
+ if (first === undefined || last === undefined) {
894
+ return null;
895
+ }
896
+
897
+ const half = GRADE_WINDOW_METERS / 2;
898
+ const from = Math.max(first.distance, distance - half);
899
+ const to = Math.min(last.distance, distance + half);
900
+ const start = elevationAt(points, from);
901
+ const end = elevationAt(points, to);
902
+ if (!(to > from) || start === null || end === null) {
903
+ return null;
904
+ }
905
+
906
+ return convertSlope((end - start) / (to - from), "ratio", "degrees");
907
+ };
908
+
909
+ /** Itinerary figures, in meters and degrees. Every field nullable: a 2D itinerary has no ascent. */
910
+ export interface ProfileTotals {
911
+ readonly distance: number | null;
912
+ readonly ascent: number | null;
913
+ readonly descent: number | null;
914
+ readonly elevationMin: number | null;
915
+ readonly elevationMax: number | null;
916
+ /**
917
+ * The steepest ascending grade over a {@link GRADE_WINDOW_METERS} run, in degrees.
918
+ *
919
+ * Never negative: a stretch on which no run ascends answers 0, as its ascent does.
920
+ */
921
+ readonly gradeMax: number | null;
922
+ }
923
+
924
+ /**
925
+ * profileTotals derives an itinerary's figures from its series.
926
+ *
927
+ * **Treat ascent and descent as estimates.** They are accumulated through a
928
+ * {@link ELEVATION_NOISE_THRESHOLD_METERS} hysteresis, which removes almost all of the
929
+ * double-counting that raw DEM samples produce and, in exchange, clips up to that many meters
930
+ * off the end of each genuine climb. An application holding server-computed metrics should
931
+ * state those instead: the element takes them through its `totals` prop for exactly this
932
+ * reason.
933
+ */
934
+ export const profileTotals = (series: ElevationSeries): ProfileTotals => {
935
+ const { points } = series;
936
+ const first = points[0];
937
+ if (first === undefined) {
938
+ return {
939
+ ascent: null,
940
+ descent: null,
941
+ distance: series.totalDistance,
942
+ elevationMax: null,
943
+ elevationMin: null,
944
+ gradeMax: null,
945
+ };
946
+ }
947
+
948
+ // The one hysteresis scan, read at its last sample: a total summed by a loop of its own
949
+ // would be a second statement of the threshold a stretch's figures are differences of.
950
+ const cumulative = cumulativeElevation(points);
951
+
952
+ return {
953
+ ascent: cumulative.ascent.at(-1) ?? 0,
954
+ descent: cumulative.descent.at(-1) ?? 0,
955
+ distance: series.totalDistance,
956
+ elevationMax: series.maxElevation,
957
+ elevationMin: series.minElevation,
958
+ gradeMax: steepestGrade(points, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY),
959
+ };
960
+ };
961
+
962
+ /**
963
+ * curveCursor reads the curve's altitude at distances asked in ascending order.
964
+ *
965
+ * One pass over the samples for a whole scan, where {@link elevationAt} searches for each
966
+ * reading: the cursor only moves forward, from `startIndex`. A distance before the sample it
967
+ * stands on reads that sample's altitude.
968
+ */
969
+ const curveCursor = (
970
+ points: readonly ElevationPoint[],
971
+ startIndex: number,
972
+ ): ((distance: number) => number) => {
973
+ let index = Math.max(0, startIndex);
974
+
975
+ return (distance) => {
976
+ while (index + 1 < points.length && (points[index + 1]?.distance ?? 0) <= distance) {
977
+ index += 1;
978
+ }
979
+
980
+ const before = points[index];
981
+ const after = points[index + 1];
982
+ if (before === undefined) {
983
+ return 0;
984
+ }
985
+
986
+ if (after === undefined || distance <= before.distance) {
987
+ return before.elevation;
988
+ }
989
+
990
+ return (
991
+ before.elevation +
992
+ ((after.elevation - before.elevation) * (distance - before.distance)) /
993
+ (after.distance - before.distance)
994
+ );
995
+ };
996
+ };
997
+
998
+ /**
999
+ * steepestGrade finds the steepest ascending {@link GRADE_WINDOW_METERS} of a stretch, in
1000
+ * degrees.
1001
+ *
1002
+ * Every run measured is the window's full width, each end read on the curve between the two
1003
+ * samples either side of it, so two samples closer together than the noise they carry never set
1004
+ * the figure. The curve is straight between samples, so the steepest run starts or ends on one,
1005
+ * or at an end of the stretch: those are the runs measured, in two forward passes.
1006
+ *
1007
+ * A stretch shorter than the window is measured end to end, the one run it has. A stretch on
1008
+ * which no run ascends answers 0. Where two lines meet at an end of the stretch, a run that
1009
+ * starts or ends there reads the line the stretch is on, so the step between the two lines is
1010
+ * no part of it.
1011
+ *
1012
+ * @param points The series' samples, ascending by distance.
1013
+ * @param from Where the stretch starts, in meters from the start of the itinerary.
1014
+ * @param to Where the stretch ends. At or past `from`.
1015
+ * @returns The grade, or `null` where the stretch holds no length of the curve.
1016
+ */
1017
+ const steepestGrade = (
1018
+ points: readonly ElevationPoint[],
1019
+ from: number,
1020
+ to: number,
1021
+ ): number | null => {
1022
+ const first = points[0];
1023
+ const last = points.at(-1);
1024
+ if (first === undefined || last === undefined) {
1025
+ return null;
1026
+ }
1027
+
1028
+ const low = Math.max(from, first.distance);
1029
+ const high = Math.min(to, last.distance);
1030
+ const lowest = startElevationAt(points, low);
1031
+ const highest = elevationAt(points, high);
1032
+ if (!(high > low) || lowest === null || highest === null) {
1033
+ return null;
1034
+ }
1035
+
1036
+ const run = Math.min(high - low, GRADE_WINDOW_METERS);
1037
+ const inside = firstIndexAtOrPast(points, low);
1038
+
1039
+ // The runs that start at the stretch's own start and at each sample. One that reaches the
1040
+ // stretch's end reads the end's own altitude: the cursor answers the last sample at a
1041
+ // distance, which is the later line's where two lines meet there.
1042
+ const cursor = curveCursor(points, inside - 1);
1043
+ const ahead = (distance: number): number => (distance >= high ? highest : cursor(distance));
1044
+ let rise = ahead(low + run) - lowest;
1045
+ for (let index = inside; index < points.length; index += 1) {
1046
+ const point = points[index];
1047
+ if (point === undefined || point.distance > high - run) {
1048
+ break;
1049
+ }
1050
+
1051
+ if (point.distance > low) {
1052
+ rise = Math.max(rise, ahead(point.distance + run) - point.elevation);
1053
+ }
1054
+ }
1055
+
1056
+ // The runs that end at each sample and at the stretch's own end.
1057
+ const behind = curveCursor(points, inside - 1);
1058
+ for (let index = inside; index < points.length; index += 1) {
1059
+ const point = points[index];
1060
+ if (point === undefined || point.distance >= high) {
1061
+ break;
1062
+ }
1063
+
1064
+ if (point.distance >= low + run) {
1065
+ rise = Math.max(rise, point.elevation - behind(point.distance - run));
1066
+ }
1067
+ }
1068
+
1069
+ rise = Math.max(rise, highest - behind(high - run));
1070
+
1071
+ return Math.max(0, convertSlope(rise / run, "ratio", "degrees"));
1072
+ };
1073
+
1074
+ /**
1075
+ * clampRange narrows a requested window to one that can be drawn.
1076
+ *
1077
+ * Ordered, held inside the itinerary, and never narrower than {@link MIN_RANGE_SPAN_METERS}. A
1078
+ * caller dragging a handle past its partner gets the two swapped rather than an inverted
1079
+ * window, and a caller who states a range in their own state gets back the one the chart will
1080
+ * actually use, which is what lets a controlled window and an uncontrolled one behave the
1081
+ * same.
1082
+ *
1083
+ * An itinerary shorter than the minimum is its own whole width: the floor exists to stop a window
1084
+ * collapsing, not to invent itinerary that is not there.
1085
+ *
1086
+ * An end that is `NaN` (an unparsed input, a cleared state) is read as the itinerary's own end on
1087
+ * that side, `from` as its start and `to` as its finish, and an infinite end is held to the
1088
+ * itinerary like any other. A `totalDistance` that is `NaN` is an itinerary of no length.
1089
+ */
1090
+ export const clampRange = (range: ProfileRange, totalDistance: number): ProfileRange => {
1091
+ const span = Number.isNaN(totalDistance) ? 0 : Math.max(0, totalDistance);
1092
+ if (span === 0) {
1093
+ return { from: 0, to: 0 };
1094
+ }
1095
+
1096
+ const start = Number.isNaN(range.from) ? 0 : range.from;
1097
+ const end = Number.isNaN(range.to) ? span : range.to;
1098
+ const low = Math.max(0, Math.min(start, end));
1099
+ const high = Math.min(span, Math.max(start, end));
1100
+ const minimum = Math.min(MIN_RANGE_SPAN_METERS, span);
1101
+ if (high - low >= minimum) {
1102
+ return { from: low, to: high };
1103
+ }
1104
+
1105
+ // Widened from whichever end has room. Anchoring on `from` and pushing `to` out would walk
1106
+ // a window dragged to the very end of the itinerary back off it.
1107
+ const from = Math.min(low, span - minimum);
1108
+
1109
+ return { from: Math.max(0, from), to: Math.max(0, from) + minimum };
1110
+ };
1111
+
1112
+ /**
1113
+ * Meters climbed and meters dropped from the itinerary's start to each sample, index-aligned with
1114
+ * the series' own points.
1115
+ */
1116
+ export interface CumulativeElevation {
1117
+ readonly ascent: readonly number[];
1118
+ readonly descent: readonly number[];
1119
+ }
1120
+
1121
+ /**
1122
+ * cumulativeElevation runs the {@link ELEVATION_NOISE_THRESHOLD_METERS} hysteresis once and
1123
+ * records it at every sample. {@link profileTotals} states its last reading.
1124
+ *
1125
+ * **This is the reason a stretch is measured as a DIFFERENCE of two readings rather than by
1126
+ * running the accumulator over that stretch alone.** The
1127
+ * {@link ELEVATION_NOISE_THRESHOLD_METERS} hysteresis carries a reference elevation forward
1128
+ * across samples; restarting it at a boundary resets that reference, so every stretch would
1129
+ * clip up to the threshold off each of its ends and the parts would not sum to the whole. An
1130
+ * itinerary cut into seven sections would report less climb across the seven than the same
1131
+ * itinerary reports as one: a few hundred meters of disagreement between a table and the chart
1132
+ * beside it, with nothing anywhere throwing.
1133
+ *
1134
+ * One scan, and the parts add up by construction.
1135
+ */
1136
+ export const cumulativeElevation = (points: readonly ElevationPoint[]): CumulativeElevation => {
1137
+ const ascent: number[] = [];
1138
+ const descent: number[] = [];
1139
+ const first = points[0];
1140
+ if (first === undefined) {
1141
+ return { ascent, descent };
1142
+ }
1143
+
1144
+ let climbed = 0;
1145
+ let dropped = 0;
1146
+ let reference = first.elevation;
1147
+ for (const point of points) {
1148
+ const delta = point.elevation - reference;
1149
+ if (delta >= ELEVATION_NOISE_THRESHOLD_METERS) {
1150
+ climbed += delta;
1151
+ reference = point.elevation;
1152
+ } else if (delta <= -ELEVATION_NOISE_THRESHOLD_METERS) {
1153
+ dropped -= delta;
1154
+ reference = point.elevation;
1155
+ }
1156
+
1157
+ ascent.push(climbed);
1158
+ descent.push(dropped);
1159
+ }
1160
+
1161
+ return { ascent, descent };
1162
+ };
1163
+
1164
+ /**
1165
+ * readCumulative interpolates a cumulative reading at a distance that falls between samples.
1166
+ *
1167
+ * Linear between the two neighbours rather than snapped to the nearer one: a boundary placed
1168
+ * a few meters from a sample would otherwise attribute that sample's whole step to one side
1169
+ * of it, and two adjacent stretches would disagree with their sum by exactly that step.
1170
+ */
1171
+ const readCumulative = (
1172
+ points: readonly ElevationPoint[],
1173
+ totals: readonly number[],
1174
+ distance: number,
1175
+ ): number => {
1176
+ const first = points[0];
1177
+ const last = points.at(-1);
1178
+ if (first === undefined || last === undefined) {
1179
+ return 0;
1180
+ }
1181
+
1182
+ if (distance <= first.distance) {
1183
+ return totals[0] ?? 0;
1184
+ }
1185
+
1186
+ if (distance >= last.distance) {
1187
+ return totals.at(-1) ?? 0;
1188
+ }
1189
+
1190
+ const after = firstIndexAtOrPast(points, distance);
1191
+ if (after <= 0 || after >= points.length) {
1192
+ return totals.at(-1) ?? 0;
1193
+ }
1194
+
1195
+ const start = points[after - 1];
1196
+ const end = points[after];
1197
+ const low = totals[after - 1] ?? 0;
1198
+ const high = totals[after] ?? low;
1199
+ if (start === undefined || end === undefined) {
1200
+ return high;
1201
+ }
1202
+
1203
+ const run = end.distance - start.distance;
1204
+
1205
+ return run <= 0 ? high : low + ((high - low) * (distance - start.distance)) / run;
1206
+ };
1207
+
1208
+ /**
1209
+ * rangeTotals states one stretch of itinerary, read off the cumulative scan.
1210
+ *
1211
+ * `distance` is the stretch's own length, not the itinerary's: a section states how long it is,
1212
+ * and a caller wanting the itinerary's total already has {@link profileTotals}. Everything else
1213
+ * describes the window: its own lowest and highest point, and its own steepest hundred
1214
+ * meters.
1215
+ *
1216
+ * Every figure is read at the stretch's own two ends, on the curve between the two samples
1217
+ * either side of each, so a stretch shorter than the gap between two samples states a band and
1218
+ * a grade beside its climb. A stretch the samples do not reach states neither.
1219
+ *
1220
+ * Over the whole itinerary it answers exactly what {@link profileTotals} answers, which is the
1221
+ * property that keeps the two from drifting.
1222
+ */
1223
+ export const rangeTotals = (
1224
+ series: ElevationSeries,
1225
+ cumulative: CumulativeElevation,
1226
+ range: ProfileRange,
1227
+ ): ProfileTotals => {
1228
+ const { points } = series;
1229
+ const from = Math.min(range.from, range.to);
1230
+ const to = Math.max(range.from, range.to);
1231
+
1232
+ if (points.length === 0) {
1233
+ return {
1234
+ ascent: null,
1235
+ descent: null,
1236
+ distance: to - from,
1237
+ elevationMax: null,
1238
+ elevationMin: null,
1239
+ gradeMax: null,
1240
+ };
1241
+ }
1242
+
1243
+ const ascent =
1244
+ readCumulative(points, cumulative.ascent, to) - readCumulative(points, cumulative.ascent, from);
1245
+ const descent =
1246
+ readCumulative(points, cumulative.descent, to) -
1247
+ readCumulative(points, cumulative.descent, from);
1248
+
1249
+ // Rounded away from a floating-point tail: a difference of two large accumulations lands a
1250
+ // few billionths below zero often enough that a section would state `-0 m` of climb.
1251
+ const nonNegative = (value: number): number => (Math.abs(value) < 1e-6 ? 0 : Math.max(0, value));
1252
+
1253
+ const band = altitudeBand(points, from, to);
1254
+
1255
+ return {
1256
+ ascent: nonNegative(ascent),
1257
+ descent: nonNegative(descent),
1258
+ distance: to - from,
1259
+ elevationMax: band?.max ?? null,
1260
+ elevationMin: band?.min ?? null,
1261
+ gradeMax: steepestGrade(points, from, to),
1262
+ };
1263
+ };