@mountaya/elements 0.1.0 → 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 (862) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +4 -3
  3. package/THIRD-PARTY-NOTICES.txt +1 -1
  4. package/dist/agent/index.cjs +1152 -1905
  5. package/dist/agent/index.cjs.map +1 -1
  6. package/dist/agent/index.d.cts +1152 -1202
  7. package/dist/agent/index.d.ts +1152 -1202
  8. package/dist/agent/index.js +1147 -1903
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/camera/index.cjs +2470 -3435
  11. package/dist/camera/index.cjs.map +1 -1
  12. package/dist/camera/index.d.cts +716 -744
  13. package/dist/camera/index.d.ts +716 -744
  14. package/dist/camera/index.js +2438 -3323
  15. package/dist/camera/index.js.map +1 -1
  16. package/dist/{units-D9mBrusY.d.cts → chunk-5pTPpv4v.d.cts} +38 -41
  17. package/dist/{units-D9mBrusY.d.ts → chunk-5pTPpv4v.d.ts} +38 -41
  18. package/dist/{order-BLhsGsH8.d.ts → chunk-6JzFMFHh.d.ts} +15 -28
  19. package/dist/chunk-6qyuJVvt.d.ts +513 -0
  20. package/dist/chunk-9fp0lDic.cjs +583 -0
  21. package/dist/chunk-9fp0lDic.cjs.map +1 -0
  22. package/dist/{zones-B05QA8fy.d.ts → chunk-A48H1rDg.d.cts} +2 -4
  23. package/dist/{zones-B05QA8fy.d.cts → chunk-A48H1rDg.d.ts} +2 -4
  24. package/dist/chunk-B-m1AchR.cjs +57 -0
  25. package/dist/chunk-B-m1AchR.cjs.map +1 -0
  26. package/dist/{bundle-xYrrbJTH.d.ts → chunk-B-qFTf04.d.ts} +51 -57
  27. package/dist/chunk-B0YROiZh.d.cts +1475 -0
  28. package/dist/chunk-B14wgOvH.d.cts +68 -0
  29. package/dist/chunk-B19l3j9r.cjs +150 -0
  30. package/dist/chunk-B19l3j9r.cjs.map +1 -0
  31. package/dist/chunk-B2PtjVKg.cjs +86 -0
  32. package/dist/chunk-B2PtjVKg.cjs.map +1 -0
  33. package/dist/chunk-B56Oyb7W.cjs +70 -0
  34. package/dist/chunk-B56Oyb7W.cjs.map +1 -0
  35. package/dist/chunk-B5WGMQwK.cjs +113 -0
  36. package/dist/chunk-B5WGMQwK.cjs.map +1 -0
  37. package/dist/{types-nO2joeRk.d.ts → chunk-B98mKrdu.d.cts} +103 -122
  38. package/dist/{videoOverlay-Dh_D5_Zs.d.ts → chunk-BB0PmqIM.d.cts} +10 -10
  39. package/dist/chunk-BBikve0Z.cjs +269 -0
  40. package/dist/chunk-BBikve0Z.cjs.map +1 -0
  41. package/dist/chunk-BHeXmM0X.js +37 -0
  42. package/dist/chunk-BHeXmM0X.js.map +1 -0
  43. package/dist/chunk-BI8WZLpU.cjs +281 -0
  44. package/dist/chunk-BI8WZLpU.cjs.map +1 -0
  45. package/dist/chunk-BIEc_SkR.cjs +29 -0
  46. package/dist/chunk-BIEc_SkR.cjs.map +1 -0
  47. package/dist/chunk-BJ6L6_W9.cjs +553 -0
  48. package/dist/chunk-BJ6L6_W9.cjs.map +1 -0
  49. package/dist/chunk-BJ91UCbB.js +11 -0
  50. package/dist/chunk-BJ91UCbB.js.map +1 -0
  51. package/dist/chunk-BJEZWTKj.cjs +166 -0
  52. package/dist/chunk-BJEZWTKj.cjs.map +1 -0
  53. package/dist/chunk-BJz54mfg.cjs +10 -0
  54. package/dist/chunk-BJz54mfg.cjs.map +1 -0
  55. package/dist/{sections-CVlc2Inr.d.cts → chunk-BNX5LAfN.d.cts} +289 -330
  56. package/dist/chunk-BP6KgA86.js +35 -0
  57. package/dist/chunk-BP6KgA86.js.map +1 -0
  58. package/dist/{segmentRoute-C5UL_5bp.d.ts → chunk-BRnjQq6K.d.cts} +44 -59
  59. package/dist/chunk-BSiMEwPS.js +46 -0
  60. package/dist/chunk-BSiMEwPS.js.map +1 -0
  61. package/dist/chunk-BTPjDw_y.cjs +16 -0
  62. package/dist/chunk-BTPjDw_y.cjs.map +1 -0
  63. package/dist/chunk-BTUUABGI.js +17 -0
  64. package/dist/chunk-BTUUABGI.js.map +1 -0
  65. package/dist/chunk-BUeL9y7s.cjs +45 -0
  66. package/dist/chunk-BUeL9y7s.cjs.map +1 -0
  67. package/dist/chunk-BWMuCNc9.cjs +172 -0
  68. package/dist/chunk-BWMuCNc9.cjs.map +1 -0
  69. package/dist/chunk-BWjRfhpF.js +126 -0
  70. package/dist/chunk-BWjRfhpF.js.map +1 -0
  71. package/dist/{types-CTQwbSdA.d.cts → chunk-BZ5KyZXI.d.ts} +103 -122
  72. package/dist/chunk-B_4SVmvh.js +94 -0
  73. package/dist/chunk-B_4SVmvh.js.map +1 -0
  74. package/dist/chunk-BcTUuZQ3.js +95 -0
  75. package/dist/chunk-BcTUuZQ3.js.map +1 -0
  76. package/dist/chunk-BdkqSsJe.cjs +140 -0
  77. package/dist/chunk-BdkqSsJe.cjs.map +1 -0
  78. package/dist/chunk-BfktMVmI.js +70 -0
  79. package/dist/chunk-BfktMVmI.js.map +1 -0
  80. package/dist/chunk-BfzQb0EK.cjs +6 -0
  81. package/dist/chunk-BhWfT-22.d.cts +808 -0
  82. package/dist/chunk-BjJcqX5J.cjs +60 -0
  83. package/dist/chunk-BjJcqX5J.cjs.map +1 -0
  84. package/dist/{geodesy-543qXKtI.d.ts → chunk-Bk0L8g5J.d.cts} +3 -4
  85. package/dist/{geodesy-543qXKtI.d.cts → chunk-Bk0L8g5J.d.ts} +3 -4
  86. package/dist/chunk-Bl4_uVa6.cjs +11 -0
  87. package/dist/chunk-Bl4_uVa6.cjs.map +1 -0
  88. package/dist/chunk-BlKF4lrp.js +43 -0
  89. package/dist/chunk-BlKF4lrp.js.map +1 -0
  90. package/dist/chunk-Bm1FieGR.js +4 -0
  91. package/dist/chunk-Bm1FieGR.js.map +1 -0
  92. package/dist/chunk-Bn6ZbxkS.cjs +27 -0
  93. package/dist/chunk-BpN3hr6a.cjs +541 -0
  94. package/dist/chunk-BpN3hr6a.cjs.map +1 -0
  95. package/dist/{order-BZkUwMou.d.cts → chunk-Bq_WHTfd.d.cts} +15 -28
  96. package/dist/chunk-Bqt4LBBz.cjs +648 -0
  97. package/dist/chunk-Bqt4LBBz.cjs.map +1 -0
  98. package/dist/{language-CEWQ5uYw.d.cts → chunk-Bqt97zwf.d.cts} +3 -18
  99. package/dist/{language-CEWQ5uYw.d.ts → chunk-Bqt97zwf.d.ts} +3 -18
  100. package/dist/chunk-BsBiN4w6.d.cts +245 -0
  101. package/dist/chunk-BvTpOUoC.cjs +207 -0
  102. package/dist/chunk-BvTpOUoC.cjs.map +1 -0
  103. package/dist/chunk-BwK6Hl3q.cjs +446 -0
  104. package/dist/chunk-BwK6Hl3q.cjs.map +1 -0
  105. package/dist/{elevationTiles-pmsb9wnU.d.cts → chunk-BxDQZDXR.d.cts} +26 -27
  106. package/dist/{elevationTiles-pmsb9wnU.d.ts → chunk-BxDQZDXR.d.ts} +26 -27
  107. package/dist/chunk-BxUio8kX.js +20 -0
  108. package/dist/chunk-BxUio8kX.js.map +1 -0
  109. package/dist/chunk-BxaocpFi.d.cts +1 -0
  110. package/dist/chunk-Bywi0K1N.js +36 -0
  111. package/dist/chunk-Bywi0K1N.js.map +1 -0
  112. package/dist/chunk-C-IlmkDl.js +59 -0
  113. package/dist/chunk-C-IlmkDl.js.map +1 -0
  114. package/dist/chunk-C5PtVewq.d.ts +389 -0
  115. package/dist/chunk-C5dpC7mQ.js +19 -0
  116. package/dist/chunk-C5dpC7mQ.js.map +1 -0
  117. package/dist/chunk-C5q1sgSa.js +46 -0
  118. package/dist/chunk-C5q1sgSa.js.map +1 -0
  119. package/dist/chunk-C6fU9G5I.cjs +221 -0
  120. package/dist/chunk-C6fU9G5I.cjs.map +1 -0
  121. package/dist/chunk-C71dpWUK.js +5 -0
  122. package/dist/chunk-C71dpWUK.js.map +1 -0
  123. package/dist/chunk-C82N1gQX.d.ts +1831 -0
  124. package/dist/chunk-C8HdaHpu.js +118 -0
  125. package/dist/chunk-C8HdaHpu.js.map +1 -0
  126. package/dist/chunk-C8ZGryck.js +236 -0
  127. package/dist/chunk-C8ZGryck.js.map +1 -0
  128. package/dist/chunk-C95NG0oD.cjs +43 -0
  129. package/dist/chunk-C95NG0oD.cjs.map +1 -0
  130. package/dist/chunk-C9aR8DXb.js +9 -0
  131. package/dist/chunk-C9aR8DXb.js.map +1 -0
  132. package/dist/{camera-C48Ykaxv.d.ts → chunk-CAUZnoCs.d.ts} +135 -159
  133. package/dist/chunk-CBXWWuM9.cjs +82 -0
  134. package/dist/chunk-CBXWWuM9.cjs.map +1 -0
  135. package/dist/chunk-CC_Kquu7.d.cts +125 -0
  136. package/dist/chunk-CC_Kquu7.d.ts +125 -0
  137. package/dist/chunk-CCp85vXg.cjs +60 -0
  138. package/dist/chunk-CCp85vXg.cjs.map +1 -0
  139. package/dist/chunk-CEcB1_uK.js +39 -0
  140. package/dist/chunk-CEcB1_uK.js.map +1 -0
  141. package/dist/{bundle-Je5zsRFg.d.cts → chunk-CFIo021l.d.cts} +51 -57
  142. package/dist/chunk-CH_IZoJE.js +33 -0
  143. package/dist/chunk-CH_IZoJE.js.map +1 -0
  144. package/dist/chunk-CHrasH_g.cjs +25 -0
  145. package/dist/chunk-CHrasH_g.cjs.map +1 -0
  146. package/dist/chunk-CJVoSaAE.cjs +3 -0
  147. package/dist/chunk-CJp8nGcb.js +96 -0
  148. package/dist/chunk-CJp8nGcb.js.map +1 -0
  149. package/dist/chunk-CJwUtkOt.js +112 -0
  150. package/dist/chunk-CJwUtkOt.js.map +1 -0
  151. package/dist/chunk-CKhCOVIf.d.cts +751 -0
  152. package/dist/chunk-CKiVSRYg.js +50 -0
  153. package/dist/chunk-CKiVSRYg.js.map +1 -0
  154. package/dist/chunk-CKtd19eD.cjs +59 -0
  155. package/dist/chunk-CKtd19eD.cjs.map +1 -0
  156. package/dist/chunk-CL92KE3j.d.ts +3188 -0
  157. package/dist/chunk-CLqUlkAe.js +54 -0
  158. package/dist/chunk-CLqUlkAe.js.map +1 -0
  159. package/dist/chunk-CMG5OV0q.cjs +4741 -0
  160. package/dist/chunk-CMG5OV0q.cjs.map +1 -0
  161. package/dist/chunk-CN_TKSgm.js +10 -0
  162. package/dist/chunk-CN_TKSgm.js.map +1 -0
  163. package/dist/chunk-CNe6MtqV.cjs +29 -0
  164. package/dist/chunk-CNe6MtqV.cjs.map +1 -0
  165. package/dist/chunk-COQkDTC5.js +83 -0
  166. package/dist/chunk-COQkDTC5.js.map +1 -0
  167. package/dist/chunk-CPBl6K4M.cjs +168 -0
  168. package/dist/chunk-CPBl6K4M.cjs.map +1 -0
  169. package/dist/chunk-CPx0ZYFB.d.ts +3 -0
  170. package/dist/chunk-CQQhcP_C.d.ts +197 -0
  171. package/dist/chunk-CTNoajFh.d.cts +389 -0
  172. package/dist/chunk-CTd-qgJc.cjs +384 -0
  173. package/dist/chunk-CTd-qgJc.cjs.map +1 -0
  174. package/dist/chunk-CW80YYtU.cjs +1056 -0
  175. package/dist/chunk-CW80YYtU.cjs.map +1 -0
  176. package/dist/{searchLimits-j99-NTXR.d.ts → chunk-CWpqBgkF.d.cts} +2 -2
  177. package/dist/{searchLimits-j99-NTXR.d.cts → chunk-CWpqBgkF.d.ts} +2 -2
  178. package/dist/chunk-CXjRArgy.d.ts +3 -0
  179. package/dist/chunk-CXonfH3-.cjs +14 -0
  180. package/dist/chunk-CXonfH3-.cjs.map +1 -0
  181. package/dist/chunk-CYcouGXN.d.ts +825 -0
  182. package/dist/chunk-CZDAzEBw.cjs +1621 -0
  183. package/dist/chunk-CZDAzEBw.cjs.map +1 -0
  184. package/dist/{amenities-B3-qAjxu.d.cts → chunk-C_fQFr70.d.cts} +40 -41
  185. package/dist/{amenities-B3-qAjxu.d.ts → chunk-C_fQFr70.d.ts} +40 -41
  186. package/dist/chunk-CbOtHnnB.cjs +359 -0
  187. package/dist/chunk-CbOtHnnB.cjs.map +1 -0
  188. package/dist/chunk-CdA6ZMGk.d.cts +825 -0
  189. package/dist/chunk-Ce1_thm7.js +146 -0
  190. package/dist/chunk-Ce1_thm7.js.map +1 -0
  191. package/dist/chunk-CeD8Hw0j.d.cts +3188 -0
  192. package/dist/{camera-BrFLU1DH.d.cts → chunk-CeiTuMyt.d.cts} +135 -159
  193. package/dist/chunk-Ch1OLzLi.js +1 -0
  194. package/dist/chunk-Cizu_j1N.cjs +87 -0
  195. package/dist/chunk-Cizu_j1N.cjs.map +1 -0
  196. package/dist/chunk-CjDe9z6A.d.cts +427 -0
  197. package/dist/chunk-Cl1etdlu.js +63 -0
  198. package/dist/chunk-Cl1etdlu.js.map +1 -0
  199. package/dist/chunk-CmoVJDoz.js +4 -0
  200. package/dist/chunk-CmoVJDoz.js.map +1 -0
  201. package/dist/chunk-CnLucxjG.cjs +197 -0
  202. package/dist/chunk-CnLucxjG.cjs.map +1 -0
  203. package/dist/chunk-CsWjBmdi.cjs +56 -0
  204. package/dist/chunk-CsWjBmdi.cjs.map +1 -0
  205. package/dist/chunk-CuseO5MZ.d.cts +3 -0
  206. package/dist/chunk-CvMHibbA.d.ts +427 -0
  207. package/dist/chunk-CwDeiN5U.js +870 -0
  208. package/dist/chunk-CwDeiN5U.js.map +1 -0
  209. package/dist/chunk-Cwdmx4tG.js +1 -0
  210. package/dist/{geolocation-DDkQdWMN.d.cts → chunk-D-4MxHTt.d.cts} +33 -34
  211. package/dist/{geolocation-DDkQdWMN.d.ts → chunk-D-4MxHTt.d.ts} +33 -34
  212. package/dist/chunk-D0LF-99V.js +1093 -0
  213. package/dist/chunk-D0LF-99V.js.map +1 -0
  214. package/dist/chunk-D1fe-0c_.js +367 -0
  215. package/dist/chunk-D1fe-0c_.js.map +1 -0
  216. package/dist/chunk-D21fEI6A.d.ts +1926 -0
  217. package/dist/chunk-D39gAxya.cjs +89 -0
  218. package/dist/chunk-D39gAxya.cjs.map +1 -0
  219. package/dist/chunk-D6KdIW5e.cjs +228 -0
  220. package/dist/chunk-D6KdIW5e.cjs.map +1 -0
  221. package/dist/chunk-D6qHYbgW.d.cts +36 -0
  222. package/dist/{videoOverlay-Dh_D5_Zs.d.cts → chunk-D89E-w70.d.ts} +10 -10
  223. package/dist/chunk-D8bdTysL.js +552 -0
  224. package/dist/chunk-D8bdTysL.js.map +1 -0
  225. package/dist/chunk-D96QJT24.cjs +109 -0
  226. package/dist/chunk-D96QJT24.cjs.map +1 -0
  227. package/dist/chunk-DAmkQl-i.js +119 -0
  228. package/dist/chunk-DAmkQl-i.js.map +1 -0
  229. package/dist/chunk-DEfsb2lc.cjs +10 -0
  230. package/dist/chunk-DEfsb2lc.cjs.map +1 -0
  231. package/dist/chunk-DIFjT5-V.d.cts +66 -0
  232. package/dist/{sections-CmtaduLc.d.ts → chunk-DJpUw8TN.d.ts} +289 -330
  233. package/dist/chunk-DK6lm2IZ.cjs +11 -0
  234. package/dist/chunk-DK6lm2IZ.cjs.map +1 -0
  235. package/dist/chunk-DKqgr31j.cjs +61 -0
  236. package/dist/chunk-DKqgr31j.cjs.map +1 -0
  237. package/dist/chunk-DLZ0QYm9.js +37 -0
  238. package/dist/chunk-DLZ0QYm9.js.map +1 -0
  239. package/dist/chunk-DLjS0uaC.js +4 -0
  240. package/dist/chunk-DLjS0uaC.js.map +1 -0
  241. package/dist/chunk-DMokwmOV.cjs +49 -0
  242. package/dist/chunk-DMokwmOV.cjs.map +1 -0
  243. package/dist/chunk-DMvWgBZL.d.cts +1831 -0
  244. package/dist/chunk-DNfGfIF3.js +31 -0
  245. package/dist/chunk-DNfGfIF3.js.map +1 -0
  246. package/dist/chunk-DQbSRe8D.d.ts +245 -0
  247. package/dist/chunk-DSGkP8_y.js +45 -0
  248. package/dist/chunk-DSGkP8_y.js.map +1 -0
  249. package/dist/chunk-DTctvfSd.d.cts +197 -0
  250. package/dist/chunk-DWe7igyw.cjs +206 -0
  251. package/dist/chunk-DWe7igyw.cjs.map +1 -0
  252. package/dist/chunk-DWsMP5JR.d.ts +68 -0
  253. package/dist/{provider-DM71XnLX.d.cts → chunk-DWsm3HIW.d.cts} +37 -38
  254. package/dist/{provider-DM71XnLX.d.ts → chunk-DWsm3HIW.d.ts} +37 -38
  255. package/dist/chunk-DXABHjLa.cjs +3 -0
  256. package/dist/chunk-D_BeqSbc.cjs +42 -0
  257. package/dist/chunk-D_BeqSbc.cjs.map +1 -0
  258. package/dist/chunk-D_svQNdW.d.ts +66 -0
  259. package/dist/chunk-Dav4xWrp.js +330 -0
  260. package/dist/chunk-Dav4xWrp.js.map +1 -0
  261. package/dist/chunk-DbCPhepL.js +293 -0
  262. package/dist/chunk-DbCPhepL.js.map +1 -0
  263. package/dist/chunk-DcrTy-y2.cjs +43 -0
  264. package/dist/chunk-DcrTy-y2.cjs.map +1 -0
  265. package/dist/chunk-Ddv484ld.js +487 -0
  266. package/dist/chunk-Ddv484ld.js.map +1 -0
  267. package/dist/chunk-De0bjnhY.cjs +88 -0
  268. package/dist/chunk-De0bjnhY.cjs.map +1 -0
  269. package/dist/chunk-De2FmNPu.cjs +32 -0
  270. package/dist/chunk-De2FmNPu.cjs.map +1 -0
  271. package/dist/{segmentRoute-CIo6dR8Y.d.cts → chunk-DeSjQXiI.d.ts} +44 -59
  272. package/dist/chunk-Den0Ta6C.js +132 -0
  273. package/dist/chunk-Den0Ta6C.js.map +1 -0
  274. package/dist/chunk-DiDKEeEa.js +8 -0
  275. package/dist/chunk-DiDKEeEa.js.map +1 -0
  276. package/dist/chunk-Dj60k5PU.js +197 -0
  277. package/dist/chunk-Dj60k5PU.js.map +1 -0
  278. package/dist/chunk-DjnYQBCN.js +4705 -0
  279. package/dist/chunk-DjnYQBCN.js.map +1 -0
  280. package/dist/chunk-Dk9VKvyq.d.ts +1 -0
  281. package/dist/chunk-Dor1ERI9.cjs +85 -0
  282. package/dist/chunk-Dor1ERI9.cjs.map +1 -0
  283. package/dist/chunk-DpMouOoH.js +451 -0
  284. package/dist/chunk-DpMouOoH.js.map +1 -0
  285. package/dist/chunk-DposgdNL.cjs +52 -0
  286. package/dist/chunk-DposgdNL.cjs.map +1 -0
  287. package/dist/chunk-DqLTG_5Q.d.cts +3 -0
  288. package/dist/{roadAccess-D_rOE4xW.d.cts → chunk-Dr5MCIpS.d.cts} +5 -28
  289. package/dist/{roadAccess-D_rOE4xW.d.ts → chunk-Dr5MCIpS.d.ts} +5 -28
  290. package/dist/chunk-DrudttCC.cjs +4 -0
  291. package/dist/chunk-DsDYVJQC.js +173 -0
  292. package/dist/chunk-DsDYVJQC.js.map +1 -0
  293. package/dist/chunk-Dw8ur6FJ.js +27 -0
  294. package/dist/chunk-Dw8ur6FJ.js.map +1 -0
  295. package/dist/chunk-DwG6M_0v.js +64 -0
  296. package/dist/chunk-DwG6M_0v.js.map +1 -0
  297. package/dist/chunk-Dy9a5ibO.js +284 -0
  298. package/dist/chunk-Dy9a5ibO.js.map +1 -0
  299. package/dist/chunk-DyayZlQJ.js +157 -0
  300. package/dist/chunk-DyayZlQJ.js.map +1 -0
  301. package/dist/chunk-DyhJZC2i.js +126 -0
  302. package/dist/chunk-DyhJZC2i.js.map +1 -0
  303. package/dist/chunk-F9zBzmmG.cjs +45 -0
  304. package/dist/chunk-F9zBzmmG.cjs.map +1 -0
  305. package/dist/chunk-FyCYofv2.js +116 -0
  306. package/dist/chunk-FyCYofv2.js.map +1 -0
  307. package/dist/chunk-GHJRjAk2.js +1 -0
  308. package/dist/chunk-H14isiSf.d.ts +751 -0
  309. package/dist/chunk-HIJzXoN4.js +7 -0
  310. package/dist/chunk-HIJzXoN4.js.map +1 -0
  311. package/dist/chunk-Id_8kRtu.d.ts +36 -0
  312. package/dist/chunk-KN60yxBQ.js +5 -0
  313. package/dist/chunk-KN60yxBQ.js.map +1 -0
  314. package/dist/chunk-NM5yg6bh.cjs +82 -0
  315. package/dist/chunk-NM5yg6bh.cjs.map +1 -0
  316. package/dist/chunk-OXr3zJfM.cjs +119 -0
  317. package/dist/chunk-OXr3zJfM.cjs.map +1 -0
  318. package/dist/chunk-QGqgNC4z.d.ts +928 -0
  319. package/dist/chunk-QJBtJrZ0.js +36 -0
  320. package/dist/chunk-QJBtJrZ0.js.map +1 -0
  321. package/dist/{routeProfile-BsSUABXv.d.cts → chunk-QKWhxfPv.d.cts} +196 -45
  322. package/dist/{routeProfile-BKfSfxx6.d.ts → chunk-QKWhxfPv.d.ts} +196 -45
  323. package/dist/chunk-QXW7b4Ev.d.cts +410 -0
  324. package/dist/chunk-RHZrxUrM.cjs +39 -0
  325. package/dist/chunk-RHZrxUrM.cjs.map +1 -0
  326. package/dist/chunk-RTxe2i66.js +91 -0
  327. package/dist/chunk-RTxe2i66.js.map +1 -0
  328. package/dist/chunk-RrKkJb6P.js +16 -0
  329. package/dist/chunk-RrKkJb6P.js.map +1 -0
  330. package/dist/chunk-VOJqpcnM.cjs +181 -0
  331. package/dist/chunk-VOJqpcnM.cjs.map +1 -0
  332. package/dist/chunk-VljGTrid.js +1 -0
  333. package/dist/chunk-X3UVwUEK.d.cts +513 -0
  334. package/dist/chunk-X9K2WChn.cjs +28 -0
  335. package/dist/chunk-X9K2WChn.cjs.map +1 -0
  336. package/dist/chunk-YrtOx6oy.js +251 -0
  337. package/dist/chunk-YrtOx6oy.js.map +1 -0
  338. package/dist/chunk-bY7ySujI.d.cts +928 -0
  339. package/dist/chunk-bYf1sBz5.d.cts +11 -0
  340. package/dist/chunk-bYf1sBz5.d.ts +11 -0
  341. package/dist/chunk-blfknWoM.d.cts +1926 -0
  342. package/dist/chunk-blqsohAb.js +113 -0
  343. package/dist/chunk-blqsohAb.js.map +1 -0
  344. package/dist/chunk-cDMCjodI.cjs +58 -0
  345. package/dist/chunk-cDMCjodI.cjs.map +1 -0
  346. package/dist/chunk-cWjE3qd6.cjs +10 -0
  347. package/dist/chunk-cWjE3qd6.cjs.map +1 -0
  348. package/dist/chunk-dfOgV3fu.js +26 -0
  349. package/dist/chunk-dfOgV3fu.js.map +1 -0
  350. package/dist/chunk-f9cTwUX1.cjs +125 -0
  351. package/dist/chunk-f9cTwUX1.cjs.map +1 -0
  352. package/dist/chunk-fHVYEZs4.cjs +28 -0
  353. package/dist/chunk-fHVYEZs4.cjs.map +1 -0
  354. package/dist/chunk-fWRUMgRI.js +22 -0
  355. package/dist/chunk-fWRUMgRI.js.map +1 -0
  356. package/dist/{types-BEv8V_8V.d.cts → chunk-fozLXfHY.d.cts} +8 -8
  357. package/dist/{types-BEv8V_8V.d.ts → chunk-fozLXfHY.d.ts} +8 -8
  358. package/dist/chunk-gWmB1l3A.cjs +3122 -0
  359. package/dist/chunk-gWmB1l3A.cjs.map +1 -0
  360. package/dist/chunk-gbj2R-_w.js +58 -0
  361. package/dist/chunk-gbj2R-_w.js.map +1 -0
  362. package/dist/chunk-iIWxsAXd.js +59 -0
  363. package/dist/chunk-iIWxsAXd.js.map +1 -0
  364. package/dist/chunk-lItIuOIS.cjs +137 -0
  365. package/dist/chunk-lItIuOIS.cjs.map +1 -0
  366. package/dist/chunk-m6Rh4PCe.cjs +798 -0
  367. package/dist/chunk-m6Rh4PCe.cjs.map +1 -0
  368. package/dist/chunk-o3IRANDf.cjs +99 -0
  369. package/dist/chunk-o3IRANDf.cjs.map +1 -0
  370. package/dist/chunk-obUcg3Sk.d.ts +808 -0
  371. package/dist/chunk-ohsf-6Rn.js +600 -0
  372. package/dist/chunk-ohsf-6Rn.js.map +1 -0
  373. package/dist/chunk-pBleU6Nv.js +3061 -0
  374. package/dist/chunk-pBleU6Nv.js.map +1 -0
  375. package/dist/chunk-px4e99cy.js +71 -0
  376. package/dist/chunk-px4e99cy.js.map +1 -0
  377. package/dist/chunk-qwYDLeXc.cjs +99 -0
  378. package/dist/chunk-qwYDLeXc.cjs.map +1 -0
  379. package/dist/chunk-rF_859Qk.cjs +101 -0
  380. package/dist/chunk-rF_859Qk.cjs.map +1 -0
  381. package/dist/chunk-rLJkqJ5j.d.ts +1475 -0
  382. package/dist/chunk-twQItIRg.cjs +338 -0
  383. package/dist/chunk-twQItIRg.cjs.map +1 -0
  384. package/dist/chunk-vnPrMVjY.js +10 -0
  385. package/dist/chunk-vnPrMVjY.js.map +1 -0
  386. package/dist/chunk-ws3bVwaS.d.ts +410 -0
  387. package/dist/chunk-xh3UkuVs.cjs +246 -0
  388. package/dist/chunk-xh3UkuVs.cjs.map +1 -0
  389. package/dist/chunk-yMzRr26E.js +153 -0
  390. package/dist/chunk-yMzRr26E.js.map +1 -0
  391. package/dist/collab/index.cjs +802 -1254
  392. package/dist/collab/index.cjs.map +1 -1
  393. package/dist/collab/index.d.cts +518 -544
  394. package/dist/collab/index.d.ts +518 -544
  395. package/dist/collab/index.js +797 -1252
  396. package/dist/collab/index.js.map +1 -1
  397. package/dist/data/index.cjs +39 -132
  398. package/dist/data/index.d.cts +6 -468
  399. package/dist/data/index.d.ts +6 -468
  400. package/dist/data/index.js +7 -15
  401. package/dist/editor/index.cjs +2631 -4424
  402. package/dist/editor/index.cjs.map +1 -1
  403. package/dist/editor/index.d.cts +10 -59
  404. package/dist/editor/index.d.ts +10 -59
  405. package/dist/editor/index.js +2619 -4403
  406. package/dist/editor/index.js.map +1 -1
  407. package/dist/errors/index.cjs +11 -28
  408. package/dist/errors/index.d.cts +2 -125
  409. package/dist/errors/index.d.ts +2 -125
  410. package/dist/errors/index.js +1 -3
  411. package/dist/geo/index.cjs +68 -232
  412. package/dist/geo/index.d.cts +6 -821
  413. package/dist/geo/index.d.ts +6 -821
  414. package/dist/geo/index.js +11 -15
  415. package/dist/i18n/fr/index.cjs +329 -334
  416. package/dist/i18n/fr/index.cjs.map +1 -1
  417. package/dist/i18n/fr/index.d.cts +3 -10
  418. package/dist/i18n/fr/index.d.ts +3 -10
  419. package/dist/i18n/fr/index.js +324 -332
  420. package/dist/i18n/fr/index.js.map +1 -1
  421. package/dist/i18n/index.cjs +434 -447
  422. package/dist/i18n/index.cjs.map +1 -1
  423. package/dist/i18n/index.d.cts +152 -111
  424. package/dist/i18n/index.d.ts +152 -111
  425. package/dist/i18n/index.js +420 -420
  426. package/dist/i18n/index.js.map +1 -1
  427. package/dist/icons/index.cjs +37 -116
  428. package/dist/icons/index.d.cts +4 -457
  429. package/dist/icons/index.d.ts +4 -457
  430. package/dist/icons/index.js +8 -11
  431. package/dist/index.cjs +515 -1867
  432. package/dist/index.cjs.map +1 -1
  433. package/dist/index.d.cts +44 -121
  434. package/dist/index.d.ts +44 -121
  435. package/dist/index.js +52 -65
  436. package/dist/index.js.map +1 -1
  437. package/dist/layers/index.cjs +83 -318
  438. package/dist/layers/index.d.cts +3 -1555
  439. package/dist/layers/index.d.ts +3 -1555
  440. package/dist/layers/index.js +5 -17
  441. package/dist/map-client/index.cjs +5 -4
  442. package/dist/map-client/index.d.cts +6 -1856
  443. package/dist/map-client/index.d.ts +6 -1856
  444. package/dist/map-client/index.js +0 -3
  445. package/dist/maplibre-worker.mjs +4 -4
  446. package/dist/navigation/index.cjs +584 -671
  447. package/dist/navigation/index.cjs.map +1 -1
  448. package/dist/navigation/index.d.cts +191 -272
  449. package/dist/navigation/index.d.ts +191 -272
  450. package/dist/navigation/index.js +579 -669
  451. package/dist/navigation/index.js.map +1 -1
  452. package/dist/profile/index.cjs +177 -675
  453. package/dist/profile/index.d.cts +8 -2086
  454. package/dist/profile/index.d.ts +8 -2086
  455. package/dist/profile/index.js +10 -18
  456. package/dist/seams/index.cjs +15 -39
  457. package/dist/seams/index.d.cts +4 -254
  458. package/dist/seams/index.d.ts +4 -254
  459. package/dist/seams/index.js +4 -6
  460. package/dist/search/index.cjs +39 -147
  461. package/dist/search/index.d.cts +6 -888
  462. package/dist/search/index.d.ts +6 -888
  463. package/dist/search/index.js +3 -14
  464. package/dist/style/index.cjs +34 -116
  465. package/dist/style/index.d.cts +5 -538
  466. package/dist/style/index.d.ts +5 -538
  467. package/dist/style/index.js +5 -11
  468. package/dist/testing/index.cjs +432 -617
  469. package/dist/testing/index.cjs.map +1 -1
  470. package/dist/testing/index.d.cts +61 -109
  471. package/dist/testing/index.d.ts +61 -109
  472. package/dist/testing/index.js +427 -615
  473. package/dist/testing/index.js.map +1 -1
  474. package/dist/timezone/index.cjs +1946 -752
  475. package/dist/timezone/index.cjs.map +1 -1
  476. package/dist/timezone/index.d.cts +4 -29
  477. package/dist/timezone/index.d.ts +4 -29
  478. package/dist/timezone/index.js +1941 -750
  479. package/dist/timezone/index.js.map +1 -1
  480. package/dist/units/index.cjs +29 -99
  481. package/dist/units/index.d.cts +3 -75
  482. package/dist/units/index.d.ts +3 -75
  483. package/dist/units/index.js +3 -6
  484. package/dist/video/index.cjs +1684 -2169
  485. package/dist/video/index.cjs.map +1 -1
  486. package/dist/video/index.d.cts +386 -413
  487. package/dist/video/index.d.ts +386 -413
  488. package/dist/video/index.js +1678 -2162
  489. package/dist/video/index.js.map +1 -1
  490. package/dist/view/index.cjs +6 -42
  491. package/dist/view/index.d.cts +3 -836
  492. package/dist/view/index.d.ts +3 -836
  493. package/dist/view/index.js +1 -34
  494. package/package.json +12 -12
  495. package/src/auth/rules/clientHeader.ts +1 -1
  496. package/src/camera/rules/modes.ts +38 -42
  497. package/src/camera/rules/routeContent.ts +1 -0
  498. package/src/collab/index.ts +1 -5
  499. package/src/compose/engines/mountayaMap.ts +16 -42
  500. package/src/compose/rules/developmentWarnings.ts +4 -3
  501. package/src/compose/rules/fitBox.ts +67 -0
  502. package/src/compose/rules/maplibreWorkerVersion.gen.ts +1 -1
  503. package/src/compose/rules/maxBounds.ts +5 -5
  504. package/src/compose/rules/types.ts +4 -11
  505. package/src/compose/rules/workerUrl.ts +41 -6
  506. package/src/editing/rules/engine.ts +4 -2
  507. package/src/editor/engines/viewClient.ts +8 -0
  508. package/src/editor/rules/contract.ts +1 -6
  509. package/src/errors/rules/errors.ts +1 -0
  510. package/src/geo/index.ts +1 -6
  511. package/src/i18n/index.ts +1 -0
  512. package/src/i18n/rules/dates.ts +165 -0
  513. package/src/index.ts +5 -24
  514. package/src/map-client/rules/mapClient.ts +4 -2
  515. package/src/profile/rules/scale.ts +1 -5
  516. package/src/profile/rules/waypointCard.ts +8 -11
  517. package/src/search/index.ts +3 -18
  518. package/src/video/index.ts +1 -1
  519. package/src/video/profileOverlay/rules/contract.ts +1 -3
  520. package/src/video/rules/videoEncoder.ts +1 -1
  521. package/dist/accentColor-GNKBD2CW.js +0 -4
  522. package/dist/accentColor-GNKBD2CW.js.map +0 -1
  523. package/dist/accentColor-VX2JSMGE.cjs +0 -17
  524. package/dist/accentColor-VX2JSMGE.cjs.map +0 -1
  525. package/dist/chunk-23PFRRB6.js +0 -3
  526. package/dist/chunk-23PFRRB6.js.map +0 -1
  527. package/dist/chunk-2GI5SAH2.js +0 -71
  528. package/dist/chunk-2GI5SAH2.js.map +0 -1
  529. package/dist/chunk-2MQK6A74.js +0 -39
  530. package/dist/chunk-2MQK6A74.js.map +0 -1
  531. package/dist/chunk-2RE7R4LD.js +0 -73
  532. package/dist/chunk-2RE7R4LD.js.map +0 -1
  533. package/dist/chunk-3JZQKN4O.js +0 -6
  534. package/dist/chunk-3JZQKN4O.js.map +0 -1
  535. package/dist/chunk-3NDXVUUI.js +0 -50
  536. package/dist/chunk-3NDXVUUI.js.map +0 -1
  537. package/dist/chunk-3R4GFTUM.cjs +0 -59
  538. package/dist/chunk-3R4GFTUM.cjs.map +0 -1
  539. package/dist/chunk-3RVUQ6JN.cjs +0 -22
  540. package/dist/chunk-3RVUQ6JN.cjs.map +0 -1
  541. package/dist/chunk-4F6BJMJC.cjs +0 -49
  542. package/dist/chunk-4F6BJMJC.cjs.map +0 -1
  543. package/dist/chunk-4NWQD4BX.js +0 -132
  544. package/dist/chunk-4NWQD4BX.js.map +0 -1
  545. package/dist/chunk-5K2MH3R6.js +0 -10
  546. package/dist/chunk-5K2MH3R6.js.map +0 -1
  547. package/dist/chunk-6ACRNQQQ.cjs +0 -8
  548. package/dist/chunk-6ACRNQQQ.cjs.map +0 -1
  549. package/dist/chunk-6D26E3IA.js +0 -66
  550. package/dist/chunk-6D26E3IA.js.map +0 -1
  551. package/dist/chunk-6ESAW35P.cjs +0 -80
  552. package/dist/chunk-6ESAW35P.cjs.map +0 -1
  553. package/dist/chunk-6LIW2A5M.cjs +0 -1176
  554. package/dist/chunk-6LIW2A5M.cjs.map +0 -1
  555. package/dist/chunk-6OTTWVCA.js +0 -57
  556. package/dist/chunk-6OTTWVCA.js.map +0 -1
  557. package/dist/chunk-6VROJ4UG.js +0 -862
  558. package/dist/chunk-6VROJ4UG.js.map +0 -1
  559. package/dist/chunk-6Y7FTGO4.js +0 -23
  560. package/dist/chunk-6Y7FTGO4.js.map +0 -1
  561. package/dist/chunk-75I4CG64.js +0 -104
  562. package/dist/chunk-75I4CG64.js.map +0 -1
  563. package/dist/chunk-7CUBXHAH.cjs +0 -14
  564. package/dist/chunk-7CUBXHAH.cjs.map +0 -1
  565. package/dist/chunk-7GTCURVY.js +0 -52
  566. package/dist/chunk-7GTCURVY.js.map +0 -1
  567. package/dist/chunk-7IWOL6AM.cjs +0 -100
  568. package/dist/chunk-7IWOL6AM.cjs.map +0 -1
  569. package/dist/chunk-7QN7M667.cjs +0 -151
  570. package/dist/chunk-7QN7M667.cjs.map +0 -1
  571. package/dist/chunk-A6KQDKLM.cjs +0 -1197
  572. package/dist/chunk-A6KQDKLM.cjs.map +0 -1
  573. package/dist/chunk-A77EA67G.js +0 -354
  574. package/dist/chunk-A77EA67G.js.map +0 -1
  575. package/dist/chunk-AFKOABJ4.cjs +0 -7194
  576. package/dist/chunk-AFKOABJ4.cjs.map +0 -1
  577. package/dist/chunk-AG6JV5Z2.cjs +0 -183
  578. package/dist/chunk-AG6JV5Z2.cjs.map +0 -1
  579. package/dist/chunk-APBK7NMS.js +0 -30
  580. package/dist/chunk-APBK7NMS.js.map +0 -1
  581. package/dist/chunk-AWO5YA7A.cjs +0 -33
  582. package/dist/chunk-AWO5YA7A.cjs.map +0 -1
  583. package/dist/chunk-AZATU6QW.js +0 -108
  584. package/dist/chunk-AZATU6QW.js.map +0 -1
  585. package/dist/chunk-BD2U3WST.cjs +0 -623
  586. package/dist/chunk-BD2U3WST.cjs.map +0 -1
  587. package/dist/chunk-BHBEOU6L.cjs +0 -65
  588. package/dist/chunk-BHBEOU6L.cjs.map +0 -1
  589. package/dist/chunk-CNOSNYNE.js +0 -8
  590. package/dist/chunk-CNOSNYNE.js.map +0 -1
  591. package/dist/chunk-CW3EFR4O.js +0 -12
  592. package/dist/chunk-CW3EFR4O.js.map +0 -1
  593. package/dist/chunk-DASVRNBK.js +0 -7187
  594. package/dist/chunk-DASVRNBK.js.map +0 -1
  595. package/dist/chunk-DJ6LCKYP.js +0 -42
  596. package/dist/chunk-DJ6LCKYP.js.map +0 -1
  597. package/dist/chunk-E5FHQAIO.cjs +0 -45
  598. package/dist/chunk-E5FHQAIO.cjs.map +0 -1
  599. package/dist/chunk-EOML5OTY.cjs +0 -360
  600. package/dist/chunk-EOML5OTY.cjs.map +0 -1
  601. package/dist/chunk-EP5CASHL.js +0 -613
  602. package/dist/chunk-EP5CASHL.js.map +0 -1
  603. package/dist/chunk-EP5OEEVZ.cjs +0 -14
  604. package/dist/chunk-EP5OEEVZ.cjs.map +0 -1
  605. package/dist/chunk-EUXI3FGQ.js +0 -150
  606. package/dist/chunk-EUXI3FGQ.js.map +0 -1
  607. package/dist/chunk-EWFSHCOS.js +0 -40
  608. package/dist/chunk-EWFSHCOS.js.map +0 -1
  609. package/dist/chunk-EX2C5K2T.cjs +0 -25
  610. package/dist/chunk-EX2C5K2T.cjs.map +0 -1
  611. package/dist/chunk-FEXWDQIZ.cjs +0 -8
  612. package/dist/chunk-FEXWDQIZ.cjs.map +0 -1
  613. package/dist/chunk-FEYBFY7H.cjs +0 -358
  614. package/dist/chunk-FEYBFY7H.cjs.map +0 -1
  615. package/dist/chunk-FRGAV6N6.cjs +0 -34
  616. package/dist/chunk-FRGAV6N6.cjs.map +0 -1
  617. package/dist/chunk-G5DHP5VF.js +0 -6
  618. package/dist/chunk-G5DHP5VF.js.map +0 -1
  619. package/dist/chunk-G5W2UHV2.js +0 -99
  620. package/dist/chunk-G5W2UHV2.js.map +0 -1
  621. package/dist/chunk-G7OP7O2C.cjs +0 -39
  622. package/dist/chunk-G7OP7O2C.cjs.map +0 -1
  623. package/dist/chunk-GE6CFCAM.cjs +0 -25
  624. package/dist/chunk-GE6CFCAM.cjs.map +0 -1
  625. package/dist/chunk-GIFALLHI.cjs +0 -111
  626. package/dist/chunk-GIFALLHI.cjs.map +0 -1
  627. package/dist/chunk-GLFET5GM.js +0 -129
  628. package/dist/chunk-GLFET5GM.js.map +0 -1
  629. package/dist/chunk-GQ6UFPFM.js +0 -22
  630. package/dist/chunk-GQ6UFPFM.js.map +0 -1
  631. package/dist/chunk-GQJWVMXS.js +0 -129
  632. package/dist/chunk-GQJWVMXS.js.map +0 -1
  633. package/dist/chunk-GVVJPUKC.js +0 -80
  634. package/dist/chunk-GVVJPUKC.js.map +0 -1
  635. package/dist/chunk-GZ2HOCQ2.cjs +0 -134
  636. package/dist/chunk-GZ2HOCQ2.cjs.map +0 -1
  637. package/dist/chunk-HCBOHXWP.js +0 -37
  638. package/dist/chunk-HCBOHXWP.js.map +0 -1
  639. package/dist/chunk-IBQJDVHF.cjs +0 -281
  640. package/dist/chunk-IBQJDVHF.cjs.map +0 -1
  641. package/dist/chunk-ISLB6Y5Q.cjs +0 -106
  642. package/dist/chunk-ISLB6Y5Q.cjs.map +0 -1
  643. package/dist/chunk-J55CRR4F.js +0 -105
  644. package/dist/chunk-J55CRR4F.js.map +0 -1
  645. package/dist/chunk-JBG6Z6MQ.cjs +0 -28
  646. package/dist/chunk-JBG6Z6MQ.cjs.map +0 -1
  647. package/dist/chunk-K3RQOZRU.js +0 -61
  648. package/dist/chunk-K3RQOZRU.js.map +0 -1
  649. package/dist/chunk-KDJYS4GB.cjs +0 -703
  650. package/dist/chunk-KDJYS4GB.cjs.map +0 -1
  651. package/dist/chunk-KMCAHUZM.cjs +0 -4
  652. package/dist/chunk-KMCAHUZM.cjs.map +0 -1
  653. package/dist/chunk-KUCBNPC6.js +0 -87
  654. package/dist/chunk-KUCBNPC6.js.map +0 -1
  655. package/dist/chunk-KV6UE5A4.js +0 -50
  656. package/dist/chunk-KV6UE5A4.js.map +0 -1
  657. package/dist/chunk-L6TZ2HQR.cjs +0 -18
  658. package/dist/chunk-L6TZ2HQR.cjs.map +0 -1
  659. package/dist/chunk-L7QHHGG2.cjs +0 -141
  660. package/dist/chunk-L7QHHGG2.cjs.map +0 -1
  661. package/dist/chunk-LHK3Y2AL.js +0 -271
  662. package/dist/chunk-LHK3Y2AL.js.map +0 -1
  663. package/dist/chunk-LO5RYRBH.cjs +0 -6317
  664. package/dist/chunk-LO5RYRBH.cjs.map +0 -1
  665. package/dist/chunk-LS5SJMUO.cjs +0 -194
  666. package/dist/chunk-LS5SJMUO.cjs.map +0 -1
  667. package/dist/chunk-LUGTMZFN.cjs +0 -42
  668. package/dist/chunk-LUGTMZFN.cjs.map +0 -1
  669. package/dist/chunk-LVUQU6D5.js +0 -32
  670. package/dist/chunk-LVUQU6D5.js.map +0 -1
  671. package/dist/chunk-M2QRC2GZ.js +0 -166
  672. package/dist/chunk-M2QRC2GZ.js.map +0 -1
  673. package/dist/chunk-M6QJYQIM.cjs +0 -53
  674. package/dist/chunk-M6QJYQIM.cjs.map +0 -1
  675. package/dist/chunk-MGCPH5EO.js +0 -12
  676. package/dist/chunk-MGCPH5EO.js.map +0 -1
  677. package/dist/chunk-MLVUWEZR.cjs +0 -474
  678. package/dist/chunk-MLVUWEZR.cjs.map +0 -1
  679. package/dist/chunk-MTAMJMZL.cjs +0 -707
  680. package/dist/chunk-MTAMJMZL.cjs.map +0 -1
  681. package/dist/chunk-MXL5AT3N.js +0 -48
  682. package/dist/chunk-MXL5AT3N.js.map +0 -1
  683. package/dist/chunk-MYEQSESM.cjs +0 -75
  684. package/dist/chunk-MYEQSESM.cjs.map +0 -1
  685. package/dist/chunk-N3VPF6ZD.js +0 -427
  686. package/dist/chunk-N3VPF6ZD.js.map +0 -1
  687. package/dist/chunk-N6VUAIGI.js +0 -7
  688. package/dist/chunk-N6VUAIGI.js.map +0 -1
  689. package/dist/chunk-N6XRLUN6.js +0 -6286
  690. package/dist/chunk-N6XRLUN6.js.map +0 -1
  691. package/dist/chunk-NOGDOZIT.cjs +0 -114
  692. package/dist/chunk-NOGDOZIT.cjs.map +0 -1
  693. package/dist/chunk-NUWXEISH.cjs +0 -10
  694. package/dist/chunk-NUWXEISH.cjs.map +0 -1
  695. package/dist/chunk-NZCZHXYN.cjs +0 -161
  696. package/dist/chunk-NZCZHXYN.cjs.map +0 -1
  697. package/dist/chunk-ODROSWQX.cjs +0 -53
  698. package/dist/chunk-ODROSWQX.cjs.map +0 -1
  699. package/dist/chunk-OE36AYKG.cjs +0 -82
  700. package/dist/chunk-OE36AYKG.cjs.map +0 -1
  701. package/dist/chunk-OLON7MO6.cjs +0 -437
  702. package/dist/chunk-OLON7MO6.cjs.map +0 -1
  703. package/dist/chunk-PBUOR2IT.js +0 -277
  704. package/dist/chunk-PBUOR2IT.js.map +0 -1
  705. package/dist/chunk-PC2ELXFF.cjs +0 -225
  706. package/dist/chunk-PC2ELXFF.cjs.map +0 -1
  707. package/dist/chunk-PCSGXLOC.js +0 -71
  708. package/dist/chunk-PCSGXLOC.js.map +0 -1
  709. package/dist/chunk-PFNMP6FQ.js +0 -56
  710. package/dist/chunk-PFNMP6FQ.js.map +0 -1
  711. package/dist/chunk-PIWSZTIP.js +0 -690
  712. package/dist/chunk-PIWSZTIP.js.map +0 -1
  713. package/dist/chunk-PKWHJ2GI.js +0 -136
  714. package/dist/chunk-PKWHJ2GI.js.map +0 -1
  715. package/dist/chunk-PLMVBX2A.cjs +0 -76
  716. package/dist/chunk-PLMVBX2A.cjs.map +0 -1
  717. package/dist/chunk-PM3XCD2G.cjs +0 -113
  718. package/dist/chunk-PM3XCD2G.cjs.map +0 -1
  719. package/dist/chunk-QAL4GZO7.cjs +0 -143
  720. package/dist/chunk-QAL4GZO7.cjs.map +0 -1
  721. package/dist/chunk-QDB2SEA2.js +0 -74
  722. package/dist/chunk-QDB2SEA2.js.map +0 -1
  723. package/dist/chunk-QOV7UNUN.js +0 -25
  724. package/dist/chunk-QOV7UNUN.js.map +0 -1
  725. package/dist/chunk-QQUWYLSF.cjs +0 -50
  726. package/dist/chunk-QQUWYLSF.cjs.map +0 -1
  727. package/dist/chunk-QUMBH3U4.cjs +0 -9
  728. package/dist/chunk-QUMBH3U4.cjs.map +0 -1
  729. package/dist/chunk-R4KA7OFQ.js +0 -12
  730. package/dist/chunk-R4KA7OFQ.js.map +0 -1
  731. package/dist/chunk-RBSGAZQQ.js +0 -17
  732. package/dist/chunk-RBSGAZQQ.js.map +0 -1
  733. package/dist/chunk-RM5YJWZI.js +0 -46
  734. package/dist/chunk-RM5YJWZI.js.map +0 -1
  735. package/dist/chunk-ROKNKXA4.cjs +0 -8
  736. package/dist/chunk-ROKNKXA4.cjs.map +0 -1
  737. package/dist/chunk-RQG6D546.cjs +0 -75
  738. package/dist/chunk-RQG6D546.cjs.map +0 -1
  739. package/dist/chunk-SG4YDD5L.cjs +0 -74
  740. package/dist/chunk-SG4YDD5L.cjs.map +0 -1
  741. package/dist/chunk-SNRCA7EO.js +0 -56
  742. package/dist/chunk-SNRCA7EO.js.map +0 -1
  743. package/dist/chunk-SO75R4WW.cjs +0 -22
  744. package/dist/chunk-SO75R4WW.cjs.map +0 -1
  745. package/dist/chunk-SP34NHFI.js +0 -45
  746. package/dist/chunk-SP34NHFI.js.map +0 -1
  747. package/dist/chunk-SSKSSBWJ.cjs +0 -179
  748. package/dist/chunk-SSKSSBWJ.cjs.map +0 -1
  749. package/dist/chunk-TB5663C2.js +0 -1108
  750. package/dist/chunk-TB5663C2.js.map +0 -1
  751. package/dist/chunk-TGH4NRES.js +0 -220
  752. package/dist/chunk-TGH4NRES.js.map +0 -1
  753. package/dist/chunk-TJ6ZPNID.js +0 -189
  754. package/dist/chunk-TJ6ZPNID.js.map +0 -1
  755. package/dist/chunk-U45T35N2.cjs +0 -90
  756. package/dist/chunk-U45T35N2.cjs.map +0 -1
  757. package/dist/chunk-UKVOPEZ2.js +0 -442
  758. package/dist/chunk-UKVOPEZ2.js.map +0 -1
  759. package/dist/chunk-UTB4NROA.cjs +0 -887
  760. package/dist/chunk-UTB4NROA.cjs.map +0 -1
  761. package/dist/chunk-UTW33B5V.js +0 -6
  762. package/dist/chunk-UTW33B5V.js.map +0 -1
  763. package/dist/chunk-UYUBSD2V.cjs +0 -33
  764. package/dist/chunk-UYUBSD2V.cjs.map +0 -1
  765. package/dist/chunk-V3JEP5AG.cjs +0 -59
  766. package/dist/chunk-V3JEP5AG.cjs.map +0 -1
  767. package/dist/chunk-VFAGJXHR.js +0 -18
  768. package/dist/chunk-VFAGJXHR.js.map +0 -1
  769. package/dist/chunk-VMEE57E5.cjs +0 -58
  770. package/dist/chunk-VMEE57E5.cjs.map +0 -1
  771. package/dist/chunk-VQVBEX3Y.cjs +0 -113
  772. package/dist/chunk-VQVBEX3Y.cjs.map +0 -1
  773. package/dist/chunk-VZDXX7TT.cjs +0 -64
  774. package/dist/chunk-VZDXX7TT.cjs.map +0 -1
  775. package/dist/chunk-WE5ZTI4D.js +0 -346
  776. package/dist/chunk-WE5ZTI4D.js.map +0 -1
  777. package/dist/chunk-WEFUVABP.js +0 -19
  778. package/dist/chunk-WEFUVABP.js.map +0 -1
  779. package/dist/chunk-WMU4LRKC.js +0 -28
  780. package/dist/chunk-WMU4LRKC.js.map +0 -1
  781. package/dist/chunk-WQ24RRHL.cjs +0 -354
  782. package/dist/chunk-WQ24RRHL.cjs.map +0 -1
  783. package/dist/chunk-WW4CGS7G.cjs +0 -26
  784. package/dist/chunk-WW4CGS7G.cjs.map +0 -1
  785. package/dist/chunk-WXE5WCTM.js +0 -1144
  786. package/dist/chunk-WXE5WCTM.js.map +0 -1
  787. package/dist/chunk-X23BGIYA.cjs +0 -37
  788. package/dist/chunk-X23BGIYA.cjs.map +0 -1
  789. package/dist/chunk-XEW4FTR2.js +0 -98
  790. package/dist/chunk-XEW4FTR2.js.map +0 -1
  791. package/dist/chunk-XIOI4IYW.js +0 -167
  792. package/dist/chunk-XIOI4IYW.js.map +0 -1
  793. package/dist/chunk-XLVPJ37V.cjs +0 -44
  794. package/dist/chunk-XLVPJ37V.cjs.map +0 -1
  795. package/dist/chunk-XOHAXXZA.cjs +0 -51
  796. package/dist/chunk-XOHAXXZA.cjs.map +0 -1
  797. package/dist/chunk-Y4NRIHK6.cjs +0 -313
  798. package/dist/chunk-Y4NRIHK6.cjs.map +0 -1
  799. package/dist/chunk-Y4YMMKL3.js +0 -23
  800. package/dist/chunk-Y4YMMKL3.js.map +0 -1
  801. package/dist/chunk-YJNYBVE3.cjs +0 -14
  802. package/dist/chunk-YJNYBVE3.cjs.map +0 -1
  803. package/dist/chunk-Z762QNQP.cjs +0 -60
  804. package/dist/chunk-Z762QNQP.cjs.map +0 -1
  805. package/dist/chunk-ZG5KMBOF.js +0 -669
  806. package/dist/chunk-ZG5KMBOF.js.map +0 -1
  807. package/dist/chunk-ZKONQEFA.js +0 -344
  808. package/dist/chunk-ZKONQEFA.js.map +0 -1
  809. package/dist/chunk-ZR5X7QMH.js +0 -39
  810. package/dist/chunk-ZR5X7QMH.js.map +0 -1
  811. package/dist/chunk-ZW4BJQ26.js +0 -84
  812. package/dist/chunk-ZW4BJQ26.js.map +0 -1
  813. package/dist/climbs-BhlWuu0x.d.ts +0 -70
  814. package/dist/climbs-DgBFwySV.d.cts +0 -70
  815. package/dist/data/index.cjs.map +0 -1
  816. package/dist/data/index.js.map +0 -1
  817. package/dist/errors/index.cjs.map +0 -1
  818. package/dist/errors/index.js.map +0 -1
  819. package/dist/geo/index.cjs.map +0 -1
  820. package/dist/geo/index.js.map +0 -1
  821. package/dist/icons/index.cjs.map +0 -1
  822. package/dist/icons/index.js.map +0 -1
  823. package/dist/itinerary-Dp2ZnqgD.d.cts +0 -178
  824. package/dist/itinerary-Dp2ZnqgD.d.ts +0 -178
  825. package/dist/layers/index.cjs.map +0 -1
  826. package/dist/layers/index.js.map +0 -1
  827. package/dist/map-client/index.cjs.map +0 -1
  828. package/dist/map-client/index.js.map +0 -1
  829. package/dist/markerSprite-DGBQF6PO.cjs +0 -49
  830. package/dist/markerSprite-DGBQF6PO.cjs.map +0 -1
  831. package/dist/markerSprite-DZLTR6F6.js +0 -8
  832. package/dist/markerSprite-DZLTR6F6.js.map +0 -1
  833. package/dist/mountayaMap-C9mxRFib.d.cts +0 -3277
  834. package/dist/mountayaMap-DgnlQ2fE.d.ts +0 -3277
  835. package/dist/paint-BgUcj8l7.d.cts +0 -118
  836. package/dist/paint-Dx_qGNE_.d.ts +0 -118
  837. package/dist/profile/index.cjs.map +0 -1
  838. package/dist/profile/index.js.map +0 -1
  839. package/dist/seams/index.cjs.map +0 -1
  840. package/dist/seams/index.js.map +0 -1
  841. package/dist/search/index.cjs.map +0 -1
  842. package/dist/search/index.js.map +0 -1
  843. package/dist/searchHighlight-DFE7LVIL.cjs +0 -33
  844. package/dist/searchHighlight-DFE7LVIL.cjs.map +0 -1
  845. package/dist/searchHighlight-MHAQZVWG.js +0 -12
  846. package/dist/searchHighlight-MHAQZVWG.js.map +0 -1
  847. package/dist/strings-30RSdIat.d.cts +0 -552
  848. package/dist/strings-DPTIbzT5.d.ts +0 -552
  849. package/dist/stripeImage-CQUXM2YI.js +0 -14
  850. package/dist/stripeImage-CQUXM2YI.js.map +0 -1
  851. package/dist/stripeImage-R43OPA6U.cjs +0 -39
  852. package/dist/stripeImage-R43OPA6U.cjs.map +0 -1
  853. package/dist/style/index.cjs.map +0 -1
  854. package/dist/style/index.js.map +0 -1
  855. package/dist/types-B034JMjl.d.ts +0 -973
  856. package/dist/types-B2NDLxQA.d.cts +0 -21
  857. package/dist/types-B2NDLxQA.d.ts +0 -21
  858. package/dist/types-C8aX5KMU.d.cts +0 -973
  859. package/dist/units/index.cjs.map +0 -1
  860. package/dist/units/index.js.map +0 -1
  861. package/dist/view/index.cjs.map +0 -1
  862. package/dist/view/index.js.map +0 -1
@@ -0,0 +1,4741 @@
1
+ "use strict";
2
+ const require_presets = require("./chunk-BJEZWTKj.cjs");
3
+ const require_slotNames = require("./chunk-9fp0lDic.cjs");
4
+ const require_markerSprite = require("./chunk-DWe7igyw.cjs");
5
+ const require_roadAccess = require("./chunk-CBXWWuM9.cjs");
6
+ const require_cursor = require("./chunk-BvTpOUoC.cjs");
7
+ const require_accent = require("./chunk-DEfsb2lc.cjs");
8
+ const require_errors = require("./chunk-o3IRANDf.cjs");
9
+ const require_camera = require("./chunk-D6KdIW5e.cjs");
10
+ const require_geometry = require("./chunk-BWMuCNc9.cjs");
11
+ const require_longitude = require("./chunk-RHZrxUrM.cjs");
12
+ const require_webMercator = require("./chunk-fHVYEZs4.cjs");
13
+ const require_order = require("./chunk-xh3UkuVs.cjs");
14
+ const require_listeners = require("./chunk-BIEc_SkR.cjs");
15
+ const require_conversions = require("./chunk-BBikve0Z.cjs");
16
+ const require_accentColor = require("./chunk-cDMCjodI.cjs");
17
+ const require_stripeImage = require("./chunk-B5WGMQwK.cjs");
18
+ const require_zones = require("./chunk-X9K2WChn.cjs");
19
+ const require_paint = require("./chunk-twQItIRg.cjs");
20
+ const require_sprites = require("./chunk-CHrasH_g.cjs");
21
+ const require_waypoints = require("./chunk-CPBl6K4M.cjs");
22
+ const require_pois = require("./chunk-f9cTwUX1.cjs");
23
+ const require_roadAccessColors = require("./chunk-CnLucxjG.cjs");
24
+ const require_roadAccessLine = require("./chunk-lItIuOIS.cjs");
25
+ const require_glyphNode = require("./chunk-De2FmNPu.cjs");
26
+ const require_terrain = require("./chunk-DMokwmOV.cjs");
27
+ const require_searchHighlight = require("./chunk-C6fU9G5I.cjs");
28
+ let maplibre_gl = require("maplibre-gl");
29
+ const isGeoJsonSource = (source) => source?.type === "geojson";
30
+ const ZONE_FILL_OPACITY = .3;
31
+ const ZONE_INACTIVE_FILL_OPACITY = .55;
32
+ const ZONE_OPEN_END_EPOCH = 1e11;
33
+ const zoneActiveExpression = (referenceEpoch) => [
34
+ "all",
35
+ [
36
+ "<=",
37
+ [
38
+ "coalesce",
39
+ ["get", "start_at"],
40
+ 0
41
+ ],
42
+ referenceEpoch
43
+ ],
44
+ [
45
+ "<=",
46
+ referenceEpoch,
47
+ [
48
+ "coalesce",
49
+ ["get", "end_at"],
50
+ ZONE_OPEN_END_EPOCH
51
+ ]
52
+ ]
53
+ ];
54
+ const ZONE_STRIPE_IMAGE_PREFIX = "zone-stripe-";
55
+ const zoneStripeFillPattern = () => [
56
+ "concat",
57
+ ZONE_STRIPE_IMAGE_PREFIX,
58
+ ["get", "level"]
59
+ ];
60
+ const zoneClockVisibilityFilter = (referenceEpoch) => {
61
+ return ["!", zoneActiveExpression(referenceEpoch)];
62
+ };
63
+ const refuseUndrawableProvider = (subject, icons) => {
64
+ const { paint, strokeWidth, viewBox } = icons;
65
+ if (!require_paint.isDrawableViewBox(viewBox)) throw new require_errors.MountayaElementsError(`${subject}: icons.viewBox is ${String(viewBox)}; pass a glyph set whose viewBox is the side of the square its markup is drawn in, a finite number above 0. createIconProvider builds such a set.`);
66
+ if (!require_paint.isDrawableStrokeWidth(strokeWidth, paint)) throw new require_errors.MountayaElementsError(`${subject}: icons.strokeWidth is ${String(strokeWidth)}; pass a glyph set whose strokeWidth is a finite number of viewBox units, ${require_paint.strokeWidthRange(paint)}. createIconProvider builds such a set.`);
67
+ };
68
+ const loadMarkerIcon = async (map, imageId, glyph, color, icons) => {
69
+ try {
70
+ if (map.hasImage(imageId)) return imageId;
71
+ const svg = require_markerSprite.markerSvg(glyph, color, icons);
72
+ if (svg === null) return imageId;
73
+ await require_markerSprite.addMarkerIcon(map, imageId, svg);
74
+ } catch {}
75
+ return imageId;
76
+ };
77
+ const loadPoiIcon = async (map, icon, color, icons) => loadMarkerIcon(map, require_markerSprite.poiIconImageId(icon, color), icon, color, icons);
78
+ const hasMarkerIconPath = (icon, icons) => icons.has(icon);
79
+ const loadWaypointIcon = async (map, icon, color, icons) => loadMarkerIcon(map, require_sprites.waypointIconImageId(icon, color), icon, color, icons);
80
+ const loadMissingIcon = async (map, imageId, icons) => {
81
+ try {
82
+ if (imageId === "zone-clock") {
83
+ const svg = require_markerSprite.markerSvg(ZONE_CLOCK_GLYPH, ZONE_CLOCK_COLOR, icons);
84
+ if (svg === null) return;
85
+ await require_markerSprite.addMarkerIcon(map, ZONE_CLOCK_IMAGE_ID, svg);
86
+ map.triggerRepaint();
87
+ return;
88
+ }
89
+ if (imageId === "itinerary-direction") {
90
+ addDirectionArrowImage(map);
91
+ map.triggerRepaint();
92
+ return;
93
+ }
94
+ if (imageId.startsWith("zone-stripe-")) {
95
+ const level = imageId.slice(12);
96
+ if (isZoneStripeLevel(level)) {
97
+ addZoneStripeImage(map, level);
98
+ map.triggerRepaint();
99
+ }
100
+ return;
101
+ }
102
+ if (require_stripeImage.answerRoadAccessStripe(map, imageId)) return;
103
+ await require_markerSprite.answerMarkerImage(map, imageId, icons);
104
+ } catch {}
105
+ };
106
+ const ZONE_CLOCK_IMAGE_ID = "zone-clock";
107
+ const ZONE_CLOCK_COLOR = "#495057";
108
+ const ZONE_CLOCK_GLYPH = "clock";
109
+ const loadZoneClockIcon = async (map, icons) => loadMarkerIcon(map, ZONE_CLOCK_IMAGE_ID, ZONE_CLOCK_GLYPH, ZONE_CLOCK_COLOR, icons);
110
+ const ZONE_STRIPE_WIDTH = 4;
111
+ const zoneStripeImageId = (level) => `${ZONE_STRIPE_IMAGE_PREFIX}${level}`;
112
+ const addZoneStripeImage = (map, level) => {
113
+ require_stripeImage.addStripeImage(map, zoneStripeImageId(level), require_stripeImage.describeStripePattern({
114
+ color: require_order.zoneLevelColors[level],
115
+ width: ZONE_STRIPE_WIDTH
116
+ }));
117
+ };
118
+ const loadZoneStripeIcons = (map) => {
119
+ const ids = [];
120
+ for (const level of require_zones.ZONE_LEVELS) {
121
+ try {
122
+ addZoneStripeImage(map, level);
123
+ } catch {}
124
+ ids.push(zoneStripeImageId(level));
125
+ }
126
+ return ids;
127
+ };
128
+ const isZoneStripeLevel = (value) => require_zones.ZONE_LEVELS.some((level) => level === value);
129
+ const loadRoadAccessIcons = async (map, icons) => {
130
+ const stripes = require_roadAccess.ROAD_ACCESS_KINDS.map((kind) => {
131
+ try {
132
+ require_stripeImage.addRoadAccessStripeImage(map, kind);
133
+ } catch {}
134
+ return require_roadAccessLine.roadAccessStripeImageId(kind);
135
+ });
136
+ const sprites = await Promise.all(require_roadAccess.ROAD_ACCESS_KINDS.map((kind) => loadMarkerIcon(map, require_roadAccessLine.roadAccessIconImageId(kind), require_roadAccessColors.roadAccessGlyph(kind), require_roadAccessColors.roadAccessColors[kind], icons)));
137
+ return [...stripes, ...sprites];
138
+ };
139
+ const DIRECTION_ARROW_IMAGE_ID = "itinerary-direction";
140
+ const DIRECTION_ARROW_TILE_SIZE = 28;
141
+ const rasterizeDirectionArrow = () => {
142
+ const size = DIRECTION_ARROW_TILE_SIZE;
143
+ const tip = size * .72;
144
+ const back = size * .28;
145
+ const midY = size / 2;
146
+ try {
147
+ const canvas = document.createElement("canvas");
148
+ canvas.width = size;
149
+ canvas.height = size;
150
+ const context = canvas.getContext("2d");
151
+ if (!context) return null;
152
+ context.lineJoin = "round";
153
+ context.lineCap = "round";
154
+ context.strokeStyle = "rgba(0, 0, 0, 0.55)";
155
+ context.lineWidth = 7;
156
+ context.beginPath();
157
+ context.moveTo(back, 6.72);
158
+ context.lineTo(tip, midY);
159
+ context.lineTo(back, 21.28);
160
+ context.stroke();
161
+ context.strokeStyle = "#ffffff";
162
+ context.lineWidth = 3.5;
163
+ context.beginPath();
164
+ context.moveTo(back, 6.72);
165
+ context.lineTo(tip, midY);
166
+ context.lineTo(back, 21.28);
167
+ context.stroke();
168
+ return context.getImageData(0, 0, size, size);
169
+ } catch {
170
+ return null;
171
+ }
172
+ };
173
+ const directionArrowBitmapCache = /* @__PURE__ */ new Map();
174
+ const addDirectionArrowImage = (map) => {
175
+ if (map.hasImage("itinerary-direction")) return;
176
+ const cached = directionArrowBitmapCache.get(DIRECTION_ARROW_IMAGE_ID);
177
+ if (cached) {
178
+ map.addImage(DIRECTION_ARROW_IMAGE_ID, cached, { pixelRatio: 1 });
179
+ return;
180
+ }
181
+ const raster = rasterizeDirectionArrow();
182
+ if (!raster) return;
183
+ directionArrowBitmapCache.set(DIRECTION_ARROW_IMAGE_ID, raster);
184
+ if (!map.hasImage("itinerary-direction")) map.addImage(DIRECTION_ARROW_IMAGE_ID, raster, { pixelRatio: 1 });
185
+ };
186
+ const loadDirectionArrowIcon = (map) => {
187
+ try {
188
+ addDirectionArrowImage(map);
189
+ } catch {}
190
+ return DIRECTION_ARROW_IMAGE_ID;
191
+ };
192
+ const WAYPOINT_ICONS = require_waypoints.WAYPOINT_GLYPHS;
193
+ const DEFAULT_WAYPOINT_PALETTE = [...require_roadAccessColors.LIVELY_PALETTE, require_waypoints.DEFAULT_WAYPOINT_COLOR];
194
+ const collectPrebakeSprites = (icons) => {
195
+ const sprites = [];
196
+ for (const icon of WAYPOINT_ICONS) for (const color of DEFAULT_WAYPOINT_PALETTE) {
197
+ const svg = require_markerSprite.markerSvg(icon, color, icons);
198
+ if (svg === null) break;
199
+ sprites.push({
200
+ imageId: require_sprites.waypointIconImageId(icon, color),
201
+ svg
202
+ });
203
+ }
204
+ for (const style of Object.values(require_pois.poiCategoryStyles)) {
205
+ const svg = require_markerSprite.markerSvg(style.icon, style.color, icons);
206
+ if (svg === null) continue;
207
+ sprites.push({
208
+ imageId: require_markerSprite.poiIconImageId(style.icon, style.color),
209
+ svg
210
+ });
211
+ }
212
+ return sprites;
213
+ };
214
+ const registerRasterizedSprite = (map, sprite) => {
215
+ const bitmap = require_markerSprite.cachedMarkerBitmap(sprite.svg);
216
+ if (!bitmap) return;
217
+ try {
218
+ if (!map.hasImage(sprite.imageId)) map.addImage(sprite.imageId, bitmap, { pixelRatio: 1 });
219
+ } catch {}
220
+ };
221
+ const prebakeMarkerIcons = (map, icons) => warmMarkerIcons(map, icons, () => false);
222
+ const warmMarkerIcons = async (map, icons, isCancelled) => {
223
+ try {
224
+ if (isCancelled()) return;
225
+ const sprites = collectPrebakeSprites(icons);
226
+ await Promise.allSettled(sprites.map((sprite) => require_markerSprite.ensureBitmap(sprite.svg)));
227
+ for (const sprite of sprites) {
228
+ if (isCancelled()) return;
229
+ registerRasterizedSprite(map, sprite);
230
+ }
231
+ if (isCancelled()) return;
232
+ addDirectionArrowImage(map);
233
+ } catch {}
234
+ };
235
+ const PREBAKE_IDLE_TIMEOUT_MS = 2e3;
236
+ const schedulePrebakeMarkerIcons = (map, icons) => {
237
+ let cancelled = false;
238
+ const warm = () => {
239
+ warmMarkerIcons(map, icons, () => cancelled);
240
+ };
241
+ if (typeof requestIdleCallback === "function") {
242
+ const handle = requestIdleCallback(warm, { timeout: PREBAKE_IDLE_TIMEOUT_MS });
243
+ return () => {
244
+ cancelled = true;
245
+ cancelIdleCallback(handle);
246
+ };
247
+ }
248
+ const timer = setTimeout(warm, 0);
249
+ return () => {
250
+ cancelled = true;
251
+ clearTimeout(timer);
252
+ };
253
+ };
254
+ const MINI_BEARING_MARKER_SIZE_PX = 28;
255
+ const MINI_BEARING_ROTATOR_DATA = "data-mountaya-mini-bearing-rotator";
256
+ const buildMiniBearingMarkerElement = () => {
257
+ const root = document.createElement("div");
258
+ root.setAttribute("data-mountaya-mini-bearing-marker", "");
259
+ root.setAttribute("aria-hidden", "true");
260
+ root.style.height = `${MINI_BEARING_MARKER_SIZE_PX}px`;
261
+ root.style.pointerEvents = "none";
262
+ root.style.width = `${MINI_BEARING_MARKER_SIZE_PX}px`;
263
+ const rotator = document.createElement("div");
264
+ rotator.setAttribute(MINI_BEARING_ROTATOR_DATA, "");
265
+ rotator.style.alignItems = "center";
266
+ rotator.style.backgroundColor = `var(--mtya-accent, ${require_accent.DEFAULT_ACCENT})`;
267
+ rotator.style.borderRadius = "50%";
268
+ rotator.style.boxShadow = "0 1px 3px rgba(0, 0, 0, 0.35)";
269
+ rotator.style.color = "#fff";
270
+ rotator.style.display = "flex";
271
+ rotator.style.height = "100%";
272
+ rotator.style.justifyContent = "center";
273
+ rotator.style.transformOrigin = "center center";
274
+ rotator.style.transition = "transform 0.2s ease";
275
+ rotator.style.width = "100%";
276
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
277
+ svg.setAttribute("fill", "currentColor");
278
+ svg.setAttribute("height", "16");
279
+ svg.setAttribute("stroke", "currentColor");
280
+ svg.setAttribute("stroke-linecap", "round");
281
+ svg.setAttribute("stroke-linejoin", "round");
282
+ svg.setAttribute("stroke-width", "2");
283
+ svg.setAttribute("viewBox", "0 0 24 24");
284
+ svg.setAttribute("width", "16");
285
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "polygon");
286
+ path.setAttribute("points", "12,3 19,21 12,17 5,21");
287
+ svg.appendChild(path);
288
+ rotator.appendChild(svg);
289
+ root.appendChild(rotator);
290
+ return root;
291
+ };
292
+ const PROFILE_MARKER_WIDTH_PX = 32;
293
+ const PROFILE_MARKER_HEIGHT_PX = 44;
294
+ const buildProfileMarkerElement = (icon, icons) => {
295
+ const root = document.createElement("div");
296
+ root.setAttribute("data-mountaya-profile-marker", "");
297
+ root.setAttribute("aria-hidden", "true");
298
+ root.style.height = `${PROFILE_MARKER_HEIGHT_PX}px`;
299
+ root.style.pointerEvents = "none";
300
+ root.style.position = "relative";
301
+ root.style.width = `${PROFILE_MARKER_WIDTH_PX}px`;
302
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
303
+ svg.setAttribute("viewBox", "0 0 24 33");
304
+ svg.setAttribute("width", `${PROFILE_MARKER_WIDTH_PX}px`);
305
+ svg.setAttribute("height", `${PROFILE_MARKER_HEIGHT_PX}px`);
306
+ svg.style.display = "block";
307
+ svg.style.filter = "drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35))";
308
+ const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
309
+ path.setAttribute("d", "M12 1C6.2 1 1.5 5.7 1.5 11.5c0 7.9 9 19.4 10.5 21.5 1.5-2.1 10.5-13.6 10.5-21.5C22.5 5.7 17.8 1 12 1z");
310
+ path.setAttribute("fill", "#fff");
311
+ path.setAttribute("stroke", "rgba(0, 0, 0, 0.25)");
312
+ path.setAttribute("stroke-width", "1");
313
+ svg.appendChild(path);
314
+ root.appendChild(svg);
315
+ if (icon) {
316
+ const headDiameter = 26;
317
+ const head = document.createElement("div");
318
+ head.style.position = "absolute";
319
+ head.style.top = "4px";
320
+ head.style.left = "50%";
321
+ head.style.width = `${headDiameter}px`;
322
+ head.style.height = `${headDiameter}px`;
323
+ head.style.transform = "translateX(-50%)";
324
+ head.style.borderRadius = "50%";
325
+ head.style.backgroundColor = icon.background;
326
+ head.style.display = "flex";
327
+ head.style.alignItems = "center";
328
+ head.style.justifyContent = "center";
329
+ const glyphSize = Math.round(headDiameter * .62);
330
+ if ("glyph" in icon) {
331
+ const svgGlyph = document.createElementNS("http://www.w3.org/2000/svg", "svg");
332
+ svgGlyph.setAttribute("viewBox", `0 0 ${icons.viewBox} ${icons.viewBox}`);
333
+ svgGlyph.setAttribute("width", `${glyphSize}px`);
334
+ svgGlyph.setAttribute("height", `${glyphSize}px`);
335
+ for (const [name, value] of Object.entries(require_glyphNode.paintAttributes(require_paint.glyphPaint(icons), icon.color))) svgGlyph.setAttribute(name, value);
336
+ svgGlyph.setAttribute("color", icon.color);
337
+ const markup = icons.markup(icon.glyph);
338
+ if (markup !== void 0) require_glyphNode.appendGlyph(svgGlyph, markup);
339
+ if (icon.rotate) svgGlyph.style.transform = `rotate(${icon.rotate}deg)`;
340
+ head.appendChild(svgGlyph);
341
+ } else {
342
+ const glyph = document.createElement("div");
343
+ glyph.style.width = `${glyphSize}px`;
344
+ glyph.style.height = `${glyphSize}px`;
345
+ glyph.style.backgroundColor = icon.color;
346
+ const maskUrl = `url("${icon.url}")`;
347
+ glyph.style.maskImage = maskUrl;
348
+ glyph.style.webkitMaskImage = maskUrl;
349
+ glyph.style.maskRepeat = "no-repeat";
350
+ glyph.style.webkitMaskRepeat = "no-repeat";
351
+ glyph.style.maskPosition = "center";
352
+ glyph.style.webkitMaskPosition = "center";
353
+ glyph.style.maskSize = "contain";
354
+ glyph.style.webkitMaskSize = "contain";
355
+ head.appendChild(glyph);
356
+ }
357
+ root.appendChild(head);
358
+ }
359
+ return root;
360
+ };
361
+ const profileMarkerIconKey = (icon) => {
362
+ if (!icon) return "plain";
363
+ return `${"glyph" in icon ? `glyph:${icon.glyph}@${icon.rotate ?? 0}` : `url:${icon.url}`}|${icon.background}|${icon.color}`;
364
+ };
365
+ const DEM_SOURCE_ID = "dem";
366
+ const blankStyle = () => ({
367
+ layers: [],
368
+ sources: {},
369
+ version: 8
370
+ });
371
+ const bakeTerrain = (style, demUrl) => {
372
+ if (!demUrl) return style;
373
+ return {
374
+ ...style,
375
+ sources: {
376
+ ...style.sources,
377
+ [DEM_SOURCE_ID]: {
378
+ tileSize: 512,
379
+ type: "raster-dem",
380
+ url: demUrl
381
+ }
382
+ },
383
+ terrain: {
384
+ exaggeration: 1,
385
+ source: DEM_SOURCE_ID
386
+ }
387
+ };
388
+ };
389
+ const NEIGHBOUR_DELTA_DEG = 1e-4;
390
+ const queryTerrainElevation = (map, lngLat) => {
391
+ const elevation = map.queryTerrainElevation(lngLat);
392
+ if (elevation === null || elevation === void 0) return null;
393
+ return elevation;
394
+ };
395
+ const sampleTerrainAt = (map, lngLat) => {
396
+ const elevation = map.queryTerrainElevation(lngLat);
397
+ if (elevation === null || elevation === void 0) return null;
398
+ const [lng, lat] = lngLat;
399
+ const north = map.queryTerrainElevation([lng, lat + NEIGHBOUR_DELTA_DEG]);
400
+ const south = map.queryTerrainElevation([lng, lat - NEIGHBOUR_DELTA_DEG]);
401
+ const east = map.queryTerrainElevation([lng + NEIGHBOUR_DELTA_DEG, lat]);
402
+ const west = map.queryTerrainElevation([lng - NEIGHBOUR_DELTA_DEG, lat]);
403
+ if (north === null || north === void 0 || south === null || south === void 0 || east === null || east === void 0 || west === null || west === void 0) return null;
404
+ return {
405
+ elevation,
406
+ ...require_terrain.slopeAspectFromNeighbours({
407
+ east,
408
+ north,
409
+ south,
410
+ west
411
+ }, lat, NEIGHBOUR_DELTA_DEG)
412
+ };
413
+ };
414
+ const FRAME_RENDER_TIMEOUT_MS = 1200;
415
+ const TILE_SETTLE_TIMEOUT_MS = FRAME_RENDER_TIMEOUT_MS * 2;
416
+ const PER_FRAME_IDLE_TIMEOUT_MS = FRAME_RENDER_TIMEOUT_MS;
417
+ const waitForTilesSettled = (map, events, signal) => new Promise((resolve) => {
418
+ if (map.loaded()) {
419
+ resolve();
420
+ return;
421
+ }
422
+ if (signal?.aborted === true) {
423
+ resolve();
424
+ return;
425
+ }
426
+ let settled = false;
427
+ let detachIdle = () => {};
428
+ const finish = () => {
429
+ if (settled) return;
430
+ settled = true;
431
+ clearTimeout(timeout);
432
+ detachIdle();
433
+ signal?.removeEventListener("abort", finish);
434
+ resolve();
435
+ };
436
+ const timeout = setTimeout(finish, TILE_SETTLE_TIMEOUT_MS);
437
+ detachIdle = events.on("idle", finish);
438
+ if (signal) signal.addEventListener("abort", finish, { once: true });
439
+ });
440
+ const warmPosesThrough = async (map, events, poses, signal) => {
441
+ if (poses.length === 0 || signal?.aborted) return;
442
+ const stride = Math.max(12, Math.ceil(poses.length / 80));
443
+ for (let index = 0; index < poses.length; index += stride) {
444
+ if (signal?.aborted) return;
445
+ const pose = poses[index];
446
+ if (!pose) continue;
447
+ map.jumpTo(pose);
448
+ await waitForTilesSettled(map, events, signal);
449
+ }
450
+ };
451
+ const browserFrames = {
452
+ cancelFrame: (handle) => cancelAnimationFrame(handle),
453
+ requestFrame: (callback) => requestAnimationFrame(callback)
454
+ };
455
+ const prefersReducedMotion = () => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
456
+ var FrameLoopEngine = class {
457
+ step;
458
+ wanted;
459
+ frameHandle = null;
460
+ lastStepMs = null;
461
+ disposed = false;
462
+ scheduler;
463
+ reducedMotion;
464
+ intervalMs;
465
+ onFrame = (timeMs) => {
466
+ this.tick(timeMs);
467
+ };
468
+ handleVisibilityChange = () => {
469
+ if (isHidden()) {
470
+ this.stop();
471
+ return;
472
+ }
473
+ this.ensure();
474
+ };
475
+ constructor(step, wanted, options) {
476
+ this.step = step;
477
+ this.wanted = wanted;
478
+ this.scheduler = options.scheduler ?? browserFrames;
479
+ this.reducedMotion = options.prefersReducedMotion ?? prefersReducedMotion;
480
+ this.intervalMs = require_conversions.MILLISECONDS_PER_SECOND / options.fps;
481
+ if (canListenToVisibility()) document.addEventListener("visibilitychange", this.handleVisibilityChange);
482
+ }
483
+ ensure() {
484
+ if (this.disposed || this.frameHandle !== null || !this.wanted() || isHidden() || this.reducedMotion()) return;
485
+ this.frameHandle = this.scheduler.requestFrame(this.onFrame);
486
+ }
487
+ stop() {
488
+ if (this.frameHandle !== null) {
489
+ this.scheduler.cancelFrame(this.frameHandle);
490
+ this.frameHandle = null;
491
+ }
492
+ this.lastStepMs = null;
493
+ }
494
+ dispose() {
495
+ this.disposed = true;
496
+ this.stop();
497
+ if (canListenToVisibility()) document.removeEventListener("visibilitychange", this.handleVisibilityChange);
498
+ }
499
+ tick(timeMs) {
500
+ this.frameHandle = null;
501
+ if (this.disposed || !this.wanted() || isHidden()) return;
502
+ if (this.lastStepMs === null || timeMs - this.lastStepMs >= this.intervalMs) {
503
+ this.lastStepMs = timeMs;
504
+ this.step(timeMs);
505
+ }
506
+ this.frameHandle = this.scheduler.requestFrame(this.onFrame);
507
+ }
508
+ };
509
+ const canListenToVisibility = () => typeof document !== "undefined" && typeof document.addEventListener === "function" && typeof document.removeEventListener === "function";
510
+ const isHidden = () => typeof document !== "undefined" && document.hidden === true;
511
+ const DIRECTION_CHEVRON_SPACING = 160;
512
+ const DIRECTION_CHEVRON_ICON_SIZE = .55;
513
+ const DIRECTION_CHEVRON_OPACITY = .8;
514
+ const DIRECTION_FLOW_WIDTH = 2;
515
+ const DIRECTION_FLOW_OPACITY = .6;
516
+ const DIRECTION_FLOW_STEPS = 8;
517
+ const DIRECTION_FLOW_DASH = .6;
518
+ const DIRECTION_FLOW_GAP = 5;
519
+ const DIRECTION_SOURCE = "itinerary-direction-source";
520
+ const DIRECTION_FLOW_LAYER = "itinerary-direction-flow";
521
+ const DIRECTION_CHEVRON_LAYER = "itinerary-direction-chevron";
522
+ const LINE_GEOMETRY_FILTER = [
523
+ "==",
524
+ ["geometry-type"],
525
+ "LineString"
526
+ ];
527
+ const directionChevronLayout = () => ({
528
+ "icon-allow-overlap": false,
529
+ "icon-ignore-placement": false,
530
+ "icon-image": DIRECTION_ARROW_IMAGE_ID,
531
+ "icon-keep-upright": false,
532
+ "icon-rotation-alignment": "map",
533
+ "icon-size": DIRECTION_CHEVRON_ICON_SIZE,
534
+ "symbol-placement": "line",
535
+ "symbol-spacing": DIRECTION_CHEVRON_SPACING
536
+ });
537
+ const flowDashSequence = () => {
538
+ const cycle = 5.6;
539
+ const steps = [];
540
+ for (let step = 0; step < DIRECTION_FLOW_STEPS; step += 1) {
541
+ const lead = cycle * step / DIRECTION_FLOW_STEPS;
542
+ if (lead <= DIRECTION_FLOW_GAP) {
543
+ steps.push([
544
+ 0,
545
+ lead,
546
+ DIRECTION_FLOW_DASH,
547
+ DIRECTION_FLOW_GAP - lead
548
+ ]);
549
+ continue;
550
+ }
551
+ steps.push([
552
+ lead - DIRECTION_FLOW_GAP,
553
+ DIRECTION_FLOW_GAP,
554
+ cycle - lead,
555
+ 0
556
+ ]);
557
+ }
558
+ return steps;
559
+ };
560
+ const FLOW_SEED_DASH = [...flowDashSequence()[0] ?? []];
561
+ const flowLineBasePaint = () => ({
562
+ "line-color": "#ffffff",
563
+ "line-dasharray": [...FLOW_SEED_DASH],
564
+ "line-opacity": DIRECTION_FLOW_OPACITY,
565
+ "line-width": DIRECTION_FLOW_WIDTH
566
+ });
567
+ const lineFromSegmentDraft = (draft) => {
568
+ const coords = draft.route?.geometry.coordinates ?? draft.vias;
569
+ if (coords.length < 2) return [];
570
+ return coords;
571
+ };
572
+ const lineFeatureCollection = (coordinates) => ({
573
+ features: [{
574
+ geometry: {
575
+ coordinates,
576
+ type: "LineString"
577
+ },
578
+ properties: {},
579
+ type: "Feature"
580
+ }],
581
+ type: "FeatureCollection"
582
+ });
583
+ var DirectionArrowLayer = class {
584
+ map;
585
+ placement;
586
+ lastLine = null;
587
+ constructor(map, placement) {
588
+ this.map = map;
589
+ this.placement = placement;
590
+ }
591
+ apply(coordinates) {
592
+ this.lastLine = coordinates;
593
+ const data = lineFeatureCollection(coordinates);
594
+ const existing = this.map.getSource(DIRECTION_SOURCE);
595
+ if (isGeoJsonSource(existing)) {
596
+ existing.setData(data);
597
+ return;
598
+ }
599
+ this.map.addSource(DIRECTION_SOURCE, {
600
+ data,
601
+ type: "geojson"
602
+ });
603
+ this.placement.addLayerOrdered({
604
+ filter: LINE_GEOMETRY_FILTER,
605
+ id: DIRECTION_FLOW_LAYER,
606
+ paint: { ...flowLineBasePaint() },
607
+ source: DIRECTION_SOURCE,
608
+ type: "line"
609
+ }, 100);
610
+ this.placement.addLayerOrdered({
611
+ filter: LINE_GEOMETRY_FILTER,
612
+ id: DIRECTION_CHEVRON_LAYER,
613
+ layout: { ...directionChevronLayout() },
614
+ paint: { "icon-opacity": DIRECTION_CHEVRON_OPACITY },
615
+ source: DIRECTION_SOURCE,
616
+ type: "symbol"
617
+ }, 100);
618
+ }
619
+ clear() {
620
+ for (const layerId of [DIRECTION_FLOW_LAYER, DIRECTION_CHEVRON_LAYER]) this.placement.forgetLayerRank(layerId);
621
+ if (this.map.getSource(DIRECTION_SOURCE)) this.map.removeSource(DIRECTION_SOURCE);
622
+ this.lastLine = null;
623
+ }
624
+ replay() {
625
+ if (!this.lastLine) return;
626
+ const line = this.lastLine;
627
+ this.lastLine = null;
628
+ this.apply(line);
629
+ }
630
+ forgetLine() {
631
+ this.lastLine = null;
632
+ }
633
+ flowLayerId() {
634
+ return DIRECTION_FLOW_LAYER;
635
+ }
636
+ };
637
+ var DirectionFlowAnimator = class {
638
+ map;
639
+ layerIds = /* @__PURE__ */ new Set();
640
+ sequence = flowDashSequence();
641
+ step = 0;
642
+ loop;
643
+ constructor(map, scheduler, prefersReducedMotion) {
644
+ this.map = map;
645
+ this.loop = new FrameLoopEngine(() => this.advance(), () => this.layerIds.size > 0, {
646
+ fps: 12,
647
+ prefersReducedMotion,
648
+ scheduler
649
+ });
650
+ }
651
+ register(layerId) {
652
+ this.layerIds.add(layerId);
653
+ this.loop.ensure();
654
+ }
655
+ unregister(layerId) {
656
+ this.layerIds.delete(layerId);
657
+ if (this.layerIds.size === 0) this.loop.stop();
658
+ }
659
+ dispose() {
660
+ this.loop.dispose();
661
+ this.layerIds.clear();
662
+ }
663
+ advance() {
664
+ this.step = (this.step + 1) % this.sequence.length;
665
+ const dash = this.sequence[this.step];
666
+ for (const layerId of this.layerIds) {
667
+ const layer = this.map.getLayer(layerId);
668
+ if (!layer) continue;
669
+ const zoom = this.map.getZoom();
670
+ const minzoom = layer.minzoom ?? 0;
671
+ const maxzoom = layer.maxzoom ?? 24;
672
+ if (zoom < minzoom || zoom > maxzoom) continue;
673
+ this.map.setPaintProperty(layerId, "line-dasharray", dash);
674
+ }
675
+ }
676
+ };
677
+ var MapEventScopeEngine = class extends require_slotNames.MapEventEngine {
678
+ mapEvents;
679
+ constructor(map, mapEvents) {
680
+ super(map);
681
+ this.mapEvents = mapEvents;
682
+ }
683
+ get disposed() {
684
+ return super.disposed || this.mapEvents.disposed;
685
+ }
686
+ afterStyleLoad(fn) {
687
+ if (this.disposed) return;
688
+ this.mapEvents.afterStyleLoad(() => {
689
+ if (!this.disposed) fn();
690
+ });
691
+ }
692
+ isStyleReloading() {
693
+ return this.mapEvents.isStyleReloading();
694
+ }
695
+ };
696
+ const FEATURE_COLOR = ["get", "color"];
697
+ const FEATURE_ICON_IMAGE = ["get", "iconImage"];
698
+ const POINT_FEATURES = [
699
+ "==",
700
+ ["geometry-type"],
701
+ "Point"
702
+ ];
703
+ const PREVIEW_SOURCE = "itinerary-preview-source";
704
+ const PREVIEW_CASING_LAYER = "itinerary-preview-line-casing";
705
+ const PREVIEW_SOLID_LAYER = "itinerary-preview-line-solid";
706
+ const PREVIEW_DASHED_LAYER = "itinerary-preview-line-dashed";
707
+ const PREVIEW_SYMBOL_LAYER = "itinerary-preview-symbol";
708
+ const PREVIEW_ICON_SIZE = .7;
709
+ const draftIconImageId = require_sprites.waypointIconImageId;
710
+ const previewToFeatureCollection = (preview) => {
711
+ const features = [];
712
+ for (const line of preview.lines) features.push({
713
+ geometry: {
714
+ coordinates: line.coordinates,
715
+ type: "LineString"
716
+ },
717
+ properties: {
718
+ color: line.color,
719
+ dashed: line.dashed
720
+ },
721
+ type: "Feature"
722
+ });
723
+ for (const waypoint of preview.waypoints) features.push({
724
+ geometry: {
725
+ coordinates: waypoint.lngLat,
726
+ type: "Point"
727
+ },
728
+ properties: { iconImage: draftIconImageId(waypoint.icon, waypoint.color) },
729
+ type: "Feature"
730
+ });
731
+ return {
732
+ features,
733
+ type: "FeatureCollection"
734
+ };
735
+ };
736
+ var ItineraryPreviewLayer = class {
737
+ map;
738
+ placement;
739
+ lastPreview = null;
740
+ constructor(map, placement) {
741
+ this.map = map;
742
+ this.placement = placement;
743
+ }
744
+ apply(preview) {
745
+ this.lastPreview = preview;
746
+ const data = previewToFeatureCollection(preview);
747
+ const existing = this.map.getSource(PREVIEW_SOURCE);
748
+ if (isGeoJsonSource(existing)) {
749
+ existing.setData(data);
750
+ return;
751
+ }
752
+ this.map.addSource(PREVIEW_SOURCE, {
753
+ data,
754
+ type: "geojson"
755
+ });
756
+ this.placement.addLayerOrdered(require_roadAccessColors.itineraryCasingSpec({
757
+ filter: this.lineFilter(false),
758
+ id: PREVIEW_CASING_LAYER,
759
+ source: PREVIEW_SOURCE
760
+ }), 50);
761
+ this.placement.addLayerOrdered(require_roadAccessColors.itineraryDashedLineSpec({
762
+ color: FEATURE_COLOR,
763
+ filter: this.lineFilter(true),
764
+ id: PREVIEW_DASHED_LAYER,
765
+ source: PREVIEW_SOURCE
766
+ }), 50);
767
+ this.placement.addLayerOrdered(require_roadAccessColors.itineraryLineSpec({
768
+ color: FEATURE_COLOR,
769
+ filter: this.lineFilter(false),
770
+ id: PREVIEW_SOLID_LAYER,
771
+ source: PREVIEW_SOURCE
772
+ }), 50);
773
+ this.placement.addLayerOrdered({
774
+ filter: POINT_FEATURES,
775
+ id: PREVIEW_SYMBOL_LAYER,
776
+ layout: {
777
+ "icon-allow-overlap": true,
778
+ "icon-ignore-placement": true,
779
+ "icon-image": FEATURE_ICON_IMAGE,
780
+ "icon-size": PREVIEW_ICON_SIZE
781
+ },
782
+ source: PREVIEW_SOURCE,
783
+ type: "symbol"
784
+ }, 90);
785
+ }
786
+ clear() {
787
+ for (const layerId of [
788
+ PREVIEW_CASING_LAYER,
789
+ PREVIEW_SOLID_LAYER,
790
+ PREVIEW_DASHED_LAYER,
791
+ PREVIEW_SYMBOL_LAYER
792
+ ]) {
793
+ if (this.map.getLayer(layerId)) this.map.removeLayer(layerId);
794
+ this.placement.forgetLayerRank(layerId);
795
+ }
796
+ if (this.map.getSource(PREVIEW_SOURCE)) this.map.removeSource(PREVIEW_SOURCE);
797
+ this.lastPreview = null;
798
+ }
799
+ replay() {
800
+ if (!this.lastPreview) return;
801
+ const preview = this.lastPreview;
802
+ this.lastPreview = null;
803
+ this.apply(preview);
804
+ }
805
+ read() {
806
+ return this.lastPreview;
807
+ }
808
+ lineFilter(dashed) {
809
+ return [
810
+ "all",
811
+ [
812
+ "==",
813
+ ["geometry-type"],
814
+ "LineString"
815
+ ],
816
+ [
817
+ "==",
818
+ ["get", "dashed"],
819
+ dashed
820
+ ]
821
+ ];
822
+ }
823
+ };
824
+ var MapLockGuard = class {
825
+ holders = /* @__PURE__ */ new Set();
826
+ acquire(holder) {
827
+ this.holders.add(holder);
828
+ }
829
+ release(holder) {
830
+ this.holders.delete(holder);
831
+ }
832
+ isLocked() {
833
+ return this.holders.size > 0;
834
+ }
835
+ };
836
+ const BUST_TOKEN_PARAM = "_t";
837
+ const REVISION_PARAM = "revision";
838
+ const BUST_PARAMS = [BUST_TOKEN_PARAM, REVISION_PARAM];
839
+ const appendBustParam = (url, param, token) => {
840
+ const encoded = encodeURIComponent(token);
841
+ const queryStart = url.indexOf("?");
842
+ if (queryStart === -1) return `${url}?${param}=${encoded}`;
843
+ const base = url.slice(0, queryStart);
844
+ const kept = url.slice(queryStart + 1).split("&").filter((entry) => entry.length > 0).filter((entry) => {
845
+ const equals = entry.indexOf("=");
846
+ const key = equals === -1 ? entry : entry.slice(0, equals);
847
+ return !BUST_PARAMS.includes(key);
848
+ });
849
+ kept.push(`${param}=${encoded}`);
850
+ return `${base}?${kept.join("&")}`;
851
+ };
852
+ const bustItineraryTileCache = (map, sources, bustToken, now = Date.now) => {
853
+ const [param, token] = bustToken === void 0 ? [BUST_TOKEN_PARAM, now().toString()] : [REVISION_PARAM, bustToken];
854
+ for (const source of sources) {
855
+ const live = map.getSource(source.id);
856
+ if (!live || typeof live.setTiles !== "function") continue;
857
+ const next = source.tiles.map((url) => appendBustParam(url, param, token));
858
+ live.setTiles(next);
859
+ }
860
+ };
861
+ const ZONE_BADGE_ICON_SIZE = .9;
862
+ const ZONE_BADGE_ROOM_PX = 44.2;
863
+ const ZONE_BADGE_SEARCH_VISITS = 2e5;
864
+ const FRONT_DEPTH = .001;
865
+ const VISIBLE_AREA_MIN = 1e-9;
866
+ const INTERIOR_PRECISION_SHARE = .01;
867
+ const INTERIOR_PRECISION_MAX = 1;
868
+ const INTERIOR_CELLS_ALONG = 64;
869
+ const SCANLINE_HEIGHTS = [
870
+ .5,
871
+ .25,
872
+ .75,
873
+ .125,
874
+ .375,
875
+ .625,
876
+ .875
877
+ ];
878
+ const EDGE_POINT_TRIES = 16;
879
+ const COVER_SLACK_PX = 1;
880
+ const DRAPE_STEP_PX = 32;
881
+ const SHOWN_SLACK_PX = 12;
882
+ const SHOWN_CANDIDATES = 128;
883
+ const SHOWN_SPACING_MIN_PX = 4;
884
+ const gridOver = (bounds, from) => {
885
+ const width = bounds.maxX - bounds.minX;
886
+ const height = bounds.maxY - bounds.minY;
887
+ const spacing = Math.max(SHOWN_SPACING_MIN_PX, Math.sqrt(width * height / SHOWN_CANDIDATES));
888
+ const points = [];
889
+ for (let x = bounds.minX + spacing / 2; x < bounds.maxX; x += spacing) for (let y = bounds.minY + spacing / 2; y < bounds.maxY; y += spacing) points.push({
890
+ distance: Math.hypot(x - from[0], y - from[1]),
891
+ point: [x, y]
892
+ });
893
+ return points.sort((left, right) => left.distance - right.distance).map(({ point }) => point);
894
+ };
895
+ const clipRing = (ring, a, b, c) => {
896
+ const kept = [];
897
+ let previous = ring[ring.length - 1];
898
+ if (previous === void 0) return kept;
899
+ let previousSide = a * previous[0] + b * previous[1] + c;
900
+ for (const current of ring) {
901
+ const side = a * current[0] + b * current[1] + c;
902
+ if (side >= 0 !== previousSide >= 0) {
903
+ const along = previousSide / (previousSide - side);
904
+ kept.push([previous[0] + (current[0] - previous[0]) * along, previous[1] + (current[1] - previous[1]) * along]);
905
+ }
906
+ if (side >= 0) kept.push(current);
907
+ previous = current;
908
+ previousSide = side;
909
+ }
910
+ return kept;
911
+ };
912
+ const ringArea = (ring) => {
913
+ let doubled = 0;
914
+ let previous = ring[ring.length - 1];
915
+ for (const current of ring) {
916
+ if (previous !== void 0) doubled += previous[0] * current[1] - current[0] * previous[1];
917
+ previous = current;
918
+ }
919
+ return doubled / 2;
920
+ };
921
+ const polygonArea = (polygon) => polygon.reduce((area, ring, index) => area + (index === 0 ? 1 : -1) * Math.abs(ringArea(ring)), 0);
922
+ const clipPolygon = (polygon, lines) => {
923
+ const rings = [];
924
+ for (const [index, ring] of polygon.entries()) {
925
+ let kept = ring;
926
+ for (const [a, b, c] of lines) kept = clipRing(kept, a, b, c);
927
+ if (kept.length >= 3) rings.push([...kept]);
928
+ else if (index === 0) return null;
929
+ }
930
+ return rings.length > 0 ? rings : null;
931
+ };
932
+ const clipPolygonToRectangle = (polygon, rectangle) => {
933
+ const clipped = clipPolygon(polygon, [
934
+ [
935
+ 1,
936
+ 0,
937
+ -rectangle.minX
938
+ ],
939
+ [
940
+ -1,
941
+ 0,
942
+ rectangle.maxX
943
+ ],
944
+ [
945
+ 0,
946
+ 1,
947
+ -rectangle.minY
948
+ ],
949
+ [
950
+ 0,
951
+ -1,
952
+ rectangle.maxY
953
+ ]
954
+ ]);
955
+ return clipped !== null && polygonArea(clipped) > VISIBLE_AREA_MIN ? clipped : null;
956
+ };
957
+ const polygonContains = (polygon, [x, y]) => {
958
+ let inside = false;
959
+ for (const ring of polygon) {
960
+ let previous = ring[ring.length - 1];
961
+ for (const current of ring) {
962
+ if (previous !== void 0 && current[1] > y !== previous[1] > y && x < (previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]) inside = !inside;
963
+ previous = current;
964
+ }
965
+ }
966
+ return inside;
967
+ };
968
+ const segmentDistanceSquared = (x, y, a, b) => {
969
+ let nearestX = a[0];
970
+ let nearestY = a[1];
971
+ const alongX = b[0] - nearestX;
972
+ const alongY = b[1] - nearestY;
973
+ if (alongX !== 0 || alongY !== 0) {
974
+ const share = ((x - nearestX) * alongX + (y - nearestY) * alongY) / (alongX ** 2 + alongY ** 2);
975
+ if (share > 1) {
976
+ nearestX = b[0];
977
+ nearestY = b[1];
978
+ } else if (share > 0) {
979
+ nearestX += alongX * share;
980
+ nearestY += alongY * share;
981
+ }
982
+ }
983
+ return (x - nearestX) ** 2 + (y - nearestY) ** 2;
984
+ };
985
+ const clearanceAt = (polygon, x, y) => {
986
+ let nearest = Number.POSITIVE_INFINITY;
987
+ let inside = false;
988
+ for (let ringIndex = 0; ringIndex < polygon.length; ringIndex += 1) {
989
+ const ring = polygon[ringIndex] ?? [];
990
+ let previous = ring[ring.length - 1];
991
+ for (let index = 0; index < ring.length; index += 1) {
992
+ const current = ring[index];
993
+ if (previous !== void 0 && current !== void 0) {
994
+ nearest = Math.min(nearest, segmentDistanceSquared(x, y, previous, current));
995
+ if (current[1] > y !== previous[1] > y && x < (previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]) inside = !inside;
996
+ }
997
+ previous = current;
998
+ }
999
+ }
1000
+ return (inside ? 1 : -1) * Math.sqrt(nearest);
1001
+ };
1002
+ const edgeCount = (polygon) => polygon.reduce((count, ring) => count + ring.length, 0);
1003
+ const searchCell = (polygon, x, y, half, avoid, room) => {
1004
+ const edge = clearanceAt(polygon, x, y);
1005
+ let clearance = edge;
1006
+ for (const [avoidX, avoidY] of avoid) clearance = Math.min(clearance, Math.hypot(x - avoidX, y - avoidY) - room);
1007
+ return {
1008
+ clearance,
1009
+ edge,
1010
+ half,
1011
+ reach: clearance + half * Math.SQRT2,
1012
+ x,
1013
+ y
1014
+ };
1015
+ };
1016
+ const pushCell = (heap, cell) => {
1017
+ let index = heap.push(cell) - 1;
1018
+ while (index > 0) {
1019
+ const parentIndex = index - 1 >> 1;
1020
+ const parent = heap[parentIndex];
1021
+ if (parent === void 0 || parent.reach >= cell.reach) break;
1022
+ heap[index] = parent;
1023
+ index = parentIndex;
1024
+ }
1025
+ heap[index] = cell;
1026
+ };
1027
+ const popCell = (heap) => {
1028
+ const [top] = heap;
1029
+ const last = heap.pop();
1030
+ if (top === void 0 || last === void 0 || heap.length === 0) return top;
1031
+ let index = 0;
1032
+ for (;;) {
1033
+ let childIndex = index * 2 + 1;
1034
+ const left = heap[childIndex];
1035
+ const right = heap[childIndex + 1];
1036
+ let child = left;
1037
+ if (left !== void 0 && right !== void 0 && right.reach > left.reach) {
1038
+ child = right;
1039
+ childIndex += 1;
1040
+ }
1041
+ if (child === void 0 || child.reach <= last.reach) break;
1042
+ heap[index] = child;
1043
+ index = childIndex;
1044
+ }
1045
+ heap[index] = last;
1046
+ return top;
1047
+ };
1048
+ const boundsOf = (polygon) => {
1049
+ const [outline] = polygon;
1050
+ if (outline === void 0 || outline.length === 0) return null;
1051
+ let minX = Number.POSITIVE_INFINITY;
1052
+ let minY = Number.POSITIVE_INFINITY;
1053
+ let maxX = Number.NEGATIVE_INFINITY;
1054
+ let maxY = Number.NEGATIVE_INFINITY;
1055
+ for (const [x, y] of outline) {
1056
+ minX = Math.min(minX, x);
1057
+ minY = Math.min(minY, y);
1058
+ maxX = Math.max(maxX, x);
1059
+ maxY = Math.max(maxY, y);
1060
+ }
1061
+ return {
1062
+ maxX,
1063
+ maxY,
1064
+ minX,
1065
+ minY
1066
+ };
1067
+ };
1068
+ const scanlinePoint = (polygon, bounds) => {
1069
+ for (const share of SCANLINE_HEIGHTS) {
1070
+ const point = scanlineAt(polygon, bounds.minY + (bounds.maxY - bounds.minY) * share);
1071
+ if (point !== null) return point;
1072
+ }
1073
+ return null;
1074
+ };
1075
+ const scanlineAt = (polygon, y) => {
1076
+ const crossings = [];
1077
+ for (const ring of polygon) {
1078
+ let previous = ring[ring.length - 1];
1079
+ for (const current of ring) {
1080
+ if (previous !== void 0 && current[1] > y !== previous[1] > y) crossings.push((previous[0] - current[0]) * (y - current[1]) / (previous[1] - current[1]) + current[0]);
1081
+ previous = current;
1082
+ }
1083
+ }
1084
+ crossings.sort((left, right) => left - right);
1085
+ let widest = 0;
1086
+ let middle = null;
1087
+ for (let index = 0; index + 1 < crossings.length; index += 2) {
1088
+ const enter = crossings[index];
1089
+ const leave = crossings[index + 1];
1090
+ if (enter !== void 0 && leave !== void 0 && leave - enter > widest) {
1091
+ widest = leave - enter;
1092
+ middle = (enter + leave) / 2;
1093
+ }
1094
+ }
1095
+ return middle !== null && polygonContains(polygon, [middle, y]) ? [middle, y] : null;
1096
+ };
1097
+ function* shownCandidates(part, from, budget, reserve) {
1098
+ const walk = edgeCount(part);
1099
+ const pays = (cost) => {
1100
+ if (budget.visits < cost + reserve) return false;
1101
+ budget.visits -= cost;
1102
+ return true;
1103
+ };
1104
+ const bounds = pays(walk) ? boundsOf(part) : null;
1105
+ if (bounds === null) return;
1106
+ for (const share of SCANLINE_HEIGHTS) {
1107
+ if (!pays(walk * 2)) return;
1108
+ const point = scanlineAt(part, bounds.minY + (bounds.maxY - bounds.minY) * share);
1109
+ if (point !== null) yield point;
1110
+ }
1111
+ let held = 0;
1112
+ for (const point of gridOver(bounds, from)) {
1113
+ if (held >= SHOWN_CANDIDATES || !pays(walk)) return;
1114
+ if (polygonContains(part, point)) {
1115
+ held += 1;
1116
+ yield point;
1117
+ }
1118
+ }
1119
+ }
1120
+ const edgePoint = (polygon) => {
1121
+ const edges = [];
1122
+ for (const ring of polygon) {
1123
+ let previous = ring[ring.length - 1];
1124
+ for (const current of ring) {
1125
+ if (previous !== void 0) {
1126
+ const length = Math.hypot(current[0] - previous[0], current[1] - previous[1]);
1127
+ if (length > 0) edges.push({
1128
+ from: previous,
1129
+ length,
1130
+ to: current
1131
+ });
1132
+ }
1133
+ previous = current;
1134
+ }
1135
+ }
1136
+ edges.sort((left, right) => right.length - left.length);
1137
+ for (const edge of edges.slice(0, EDGE_POINT_TRIES)) {
1138
+ const middleX = (edge.from[0] + edge.to[0]) / 2;
1139
+ const middleY = (edge.from[1] + edge.to[1]) / 2;
1140
+ let nearest = Number.POSITIVE_INFINITY;
1141
+ for (const other of edges) if (other !== edge) nearest = Math.min(nearest, segmentDistanceSquared(middleX, middleY, other.from, other.to));
1142
+ const offset = Math.sqrt(nearest) / 2;
1143
+ if (!(offset > 0) || !Number.isFinite(offset)) continue;
1144
+ const normalX = -(edge.to[1] - edge.from[1]) / edge.length * offset;
1145
+ const normalY = (edge.to[0] - edge.from[0]) / edge.length * offset;
1146
+ for (const side of [1, -1]) {
1147
+ const point = [middleX + side * normalX, middleY + side * normalY];
1148
+ if (polygonContains(polygon, point)) return point;
1149
+ }
1150
+ }
1151
+ return null;
1152
+ };
1153
+ const interiorPoint = (polygon, budget = { visits: ZONE_BADGE_SEARCH_VISITS }, avoid = [], room = 0) => {
1154
+ const bounds = boundsOf(polygon);
1155
+ if (bounds === null) return null;
1156
+ const width = bounds.maxX - bounds.minX;
1157
+ const height = bounds.maxY - bounds.minY;
1158
+ const shorter = Math.min(width, height);
1159
+ const longer = Math.max(width, height);
1160
+ if (!(longer > 0) || !Number.isFinite(longer)) return null;
1161
+ const precision = Math.min(INTERIOR_PRECISION_MAX, shorter * INTERIOR_PRECISION_SHARE);
1162
+ const cost = edgeCount(polygon) + avoid.length;
1163
+ const read = (x, y, half) => {
1164
+ if (budget.visits < cost) return null;
1165
+ budget.visits -= cost;
1166
+ return searchCell(polygon, x, y, half, avoid, room);
1167
+ };
1168
+ const chosen = {
1169
+ best: null,
1170
+ inside: null
1171
+ };
1172
+ const consider = (cell) => {
1173
+ const { best, inside } = chosen;
1174
+ if (best === null || !(best.clearance > 0) && cell.clearance > best.clearance || cell.clearance > best.clearance + precision / 2) chosen.best = cell;
1175
+ if (cell.edge > 0 && (inside === null || cell.edge > inside.edge)) chosen.inside = cell;
1176
+ };
1177
+ const middle = read(bounds.minX + width / 2, bounds.minY + height / 2, 0);
1178
+ if (middle !== null) consider(middle);
1179
+ let scanned;
1180
+ if (chosen.inside === null) {
1181
+ scanned = scanlinePoint(polygon, bounds);
1182
+ const seed = scanned === null ? null : read(scanned[0], scanned[1], 0);
1183
+ if (seed !== null) consider(seed);
1184
+ }
1185
+ const size = Math.max(shorter, longer / INTERIOR_CELLS_ALONG);
1186
+ const heap = [];
1187
+ let paid = true;
1188
+ for (let x = bounds.minX; paid && x < bounds.maxX; x += size) for (let y = bounds.minY; paid && y < bounds.maxY; y += size) {
1189
+ const cell = read(x + size / 2, y + size / 2, size / 2);
1190
+ if (cell === null) paid = false;
1191
+ else {
1192
+ consider(cell);
1193
+ pushCell(heap, cell);
1194
+ }
1195
+ }
1196
+ for (let cell = popCell(heap); paid && cell !== void 0; cell = popCell(heap)) {
1197
+ if (chosen.best !== null && cell.reach - chosen.best.clearance <= precision) break;
1198
+ const half = cell.half / 2;
1199
+ for (const [dx, dy] of QUARTERS) {
1200
+ const quarter = read(cell.x + dx * half, cell.y + dy * half, half);
1201
+ if (quarter === null) {
1202
+ paid = false;
1203
+ break;
1204
+ }
1205
+ consider(quarter);
1206
+ pushCell(heap, quarter);
1207
+ }
1208
+ }
1209
+ if (chosen.best !== null && chosen.best.clearance > 0) return [chosen.best.x, chosen.best.y];
1210
+ if (chosen.inside !== null) return [chosen.inside.x, chosen.inside.y];
1211
+ if (scanned === void 0) scanned = scanlinePoint(polygon, bounds);
1212
+ return scanned ?? edgePoint(polygon);
1213
+ };
1214
+ const QUARTERS = [
1215
+ [-1, -1],
1216
+ [1, -1],
1217
+ [-1, 1],
1218
+ [1, 1]
1219
+ ];
1220
+ const solveLinear = (rows) => {
1221
+ const size = rows.length;
1222
+ for (let column = 0; column < size; column += 1) {
1223
+ let pivot = column;
1224
+ for (let row = column + 1; row < size; row += 1) if (Math.abs(rows[row]?.[column] ?? 0) > Math.abs(rows[pivot]?.[column] ?? 0)) pivot = row;
1225
+ const pivotRow = rows[pivot];
1226
+ const displaced = rows[column];
1227
+ if (pivotRow === void 0 || displaced === void 0) return null;
1228
+ const lead = pivotRow[column] ?? 0;
1229
+ if (Math.abs(lead) < 1e-12) return null;
1230
+ rows[pivot] = displaced;
1231
+ rows[column] = pivotRow;
1232
+ for (let row = column + 1; row < size; row += 1) {
1233
+ const target = rows[row];
1234
+ if (target === void 0) continue;
1235
+ const factor = (target[column] ?? 0) / lead;
1236
+ for (let index = column; index <= size; index += 1) target[index] = (target[index] ?? 0) - factor * (pivotRow[index] ?? 0);
1237
+ }
1238
+ }
1239
+ const solution = new Array(size).fill(0);
1240
+ for (let row = size - 1; row >= 0; row -= 1) {
1241
+ const current = rows[row];
1242
+ if (current === void 0) return null;
1243
+ let rest = current[size] ?? 0;
1244
+ for (let index = row + 1; index < size; index += 1) rest -= (current[index] ?? 0) * (solution[index] ?? 0);
1245
+ solution[row] = rest / (current[row] ?? 1);
1246
+ }
1247
+ return solution;
1248
+ };
1249
+ const frameOf = (quad) => {
1250
+ const centerX = (quad[0][0] + quad[1][0] + quad[2][0] + quad[3][0]) / 4;
1251
+ const centerY = (quad[0][1] + quad[1][1] + quad[2][1] + quad[3][1]) / 4;
1252
+ const spread = quad.reduce((sum, [x, y]) => sum + Math.hypot(x - centerX, y - centerY), 0) / quad.length;
1253
+ return spread > 0 && Number.isFinite(spread) ? {
1254
+ centerX,
1255
+ centerY,
1256
+ scale: 1 / spread
1257
+ } : null;
1258
+ };
1259
+ const planeProjection = (ground, screen) => {
1260
+ const from = frameOf(ground);
1261
+ const to = frameOf(screen);
1262
+ if (from === null || to === null) return null;
1263
+ const rows = [];
1264
+ for (const [index, [groundX, groundY]] of ground.entries()) {
1265
+ const [screenX, screenY] = screen[index] ?? [0, 0];
1266
+ const x = (groundX - from.centerX) * from.scale;
1267
+ const y = (groundY - from.centerY) * from.scale;
1268
+ const u = (screenX - to.centerX) * to.scale;
1269
+ const v = (screenY - to.centerY) * to.scale;
1270
+ rows.push([
1271
+ x,
1272
+ y,
1273
+ 1,
1274
+ 0,
1275
+ 0,
1276
+ 0,
1277
+ -u * x,
1278
+ -u * y,
1279
+ u
1280
+ ], [
1281
+ 0,
1282
+ 0,
1283
+ 0,
1284
+ x,
1285
+ y,
1286
+ 1,
1287
+ -v * x,
1288
+ -v * y,
1289
+ v
1290
+ ]);
1291
+ }
1292
+ const solved = solveLinear(rows);
1293
+ if (solved === null) return null;
1294
+ const [a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0] = solved;
1295
+ const depthAt = (x, y) => g * x + h * y + 1;
1296
+ for (const [groundX, groundY] of ground) if (!(depthAt((groundX - from.centerX) * from.scale, (groundY - from.centerY) * from.scale) > FRONT_DEPTH)) return null;
1297
+ const determinant = a * (e - f * h) - b * (d - f * g) + c * (d * h - e * g);
1298
+ if (!(Math.abs(determinant) > 1e-12) || !Number.isFinite(determinant)) return null;
1299
+ const inverse = [
1300
+ e - f * h,
1301
+ c * h - b,
1302
+ b * f - c * e,
1303
+ f * g - d,
1304
+ a - c * g,
1305
+ c * d - a * f,
1306
+ d * h - e * g,
1307
+ b * g - a * h,
1308
+ a * e - b * d
1309
+ ];
1310
+ const drawAt = (x, y, depth) => [(a * x + b * y + c) / depth / to.scale + to.centerX, (d * x + e * y + f) / depth / to.scale + to.centerY];
1311
+ const toScreen = ([groundX, groundY]) => {
1312
+ const x = (groundX - from.centerX) * from.scale;
1313
+ const y = (groundY - from.centerY) * from.scale;
1314
+ const depth = depthAt(x, y);
1315
+ return depth >= FRONT_DEPTH ? drawAt(x, y, depth) : null;
1316
+ };
1317
+ const toGround = ([screenX, screenY]) => {
1318
+ const u = (screenX - to.centerX) * to.scale;
1319
+ const v = (screenY - to.centerY) * to.scale;
1320
+ const weight = inverse[6] * u + inverse[7] * v + inverse[8];
1321
+ return [(inverse[0] * u + inverse[1] * v + inverse[2]) / weight / from.scale + from.centerX, (inverse[3] * u + inverse[4] * v + inverse[5]) / weight / from.scale + from.centerY];
1322
+ };
1323
+ const front = [
1324
+ g * from.scale,
1325
+ h * from.scale,
1326
+ .999 - (g * from.centerX + h * from.centerY) * from.scale
1327
+ ];
1328
+ const ahead = (polygon) => clipPolygon(polygon, [front]);
1329
+ const project = (polygon) => {
1330
+ const kept = ahead(polygon);
1331
+ if (kept === null) return null;
1332
+ return kept.map((ring) => ring.map(([groundX, groundY]) => {
1333
+ const x = (groundX - from.centerX) * from.scale;
1334
+ const y = (groundY - from.centerY) * from.scale;
1335
+ return drawAt(x, y, Math.max(depthAt(x, y), FRONT_DEPTH));
1336
+ }));
1337
+ };
1338
+ return {
1339
+ ahead,
1340
+ project,
1341
+ toGround,
1342
+ toScreen
1343
+ };
1344
+ };
1345
+ const groundOf = ([lng = 0, lat = 0]) => {
1346
+ const latitude = Math.max(-require_camera.WEB_MERCATOR_MAX_LAT, Math.min(require_camera.WEB_MERCATOR_MAX_LAT, lat));
1347
+ const sine = Math.sin(latitude * require_conversions.DEGREES_TO_RADIANS);
1348
+ return [lng / 360 + .5, .5 - Math.log((1 + sine) / (1 - sine)) / (4 * Math.PI)];
1349
+ };
1350
+ const lngLatOf = ([x, y]) => [require_longitude.wrapLongitude((x - .5) * 360), Math.asin(Math.tanh((.5 - y) * 2 * Math.PI)) / require_conversions.DEGREES_TO_RADIANS];
1351
+ const groundRing = (ring, worlds) => {
1352
+ const points = [];
1353
+ for (const position of ring) {
1354
+ const [x, y] = groundOf(position);
1355
+ points.push([x + worlds, y]);
1356
+ }
1357
+ const first = points[0];
1358
+ const last = points[points.length - 1];
1359
+ if (points.length > 1 && first !== void 0 && last !== void 0) {
1360
+ if (first[0] === last[0] && first[1] === last[1]) points.pop();
1361
+ }
1362
+ return points;
1363
+ };
1364
+ const zonePolygons = (geometry, aroundX) => {
1365
+ const written = geometry.type === "Polygon" ? [geometry.coordinates] : geometry.type === "MultiPolygon" ? geometry.coordinates : [];
1366
+ const polygons = [];
1367
+ for (const rings of written) {
1368
+ const [outline] = rings;
1369
+ if (outline === void 0 || outline.length < 3) continue;
1370
+ let west = Number.POSITIVE_INFINITY;
1371
+ let east = Number.NEGATIVE_INFINITY;
1372
+ let south = Number.POSITIVE_INFINITY;
1373
+ let north = Number.NEGATIVE_INFINITY;
1374
+ for (const [lng = 0, lat = 0] of outline) {
1375
+ west = Math.min(west, lng);
1376
+ east = Math.max(east, lng);
1377
+ south = Math.min(south, lat);
1378
+ north = Math.max(north, lat);
1379
+ }
1380
+ const worlds = Math.round(aroundX - ((west + east) / 2 / 360 + .5));
1381
+ const [minX, minY] = groundOf([west, north]);
1382
+ const [maxX, maxY] = groundOf([east, south]);
1383
+ let ground = null;
1384
+ polygons.push({
1385
+ box: {
1386
+ maxX: maxX + worlds,
1387
+ maxY,
1388
+ minX: minX + worlds,
1389
+ minY
1390
+ },
1391
+ edges: rings.reduce((count, ring) => count + ring.length, 0),
1392
+ written: () => {
1393
+ ground ??= rings.map((ring) => groundRing(ring, worlds));
1394
+ return ground;
1395
+ }
1396
+ });
1397
+ }
1398
+ return polygons;
1399
+ };
1400
+ const zoneIdOf = (feature) => {
1401
+ const id = feature.properties?.id;
1402
+ return typeof id === "string" || typeof id === "number" ? String(id) : null;
1403
+ };
1404
+ const insetOf = (viewport, margin) => viewport.width > margin * 2 && viewport.height > margin * 2 ? {
1405
+ maxX: viewport.width - margin,
1406
+ maxY: viewport.height - margin,
1407
+ minX: margin,
1408
+ minY: margin
1409
+ } : null;
1410
+ const takenRoom = (room) => {
1411
+ const squares = /* @__PURE__ */ new Map();
1412
+ const square = (value) => Math.floor(value / room);
1413
+ const within = (rectangle) => {
1414
+ const found = [];
1415
+ for (let x = square(rectangle.minX - room); x <= square(rectangle.maxX + room); x += 1) for (let y = square(rectangle.minY - room); y <= square(rectangle.maxY + room); y += 1) found.push(...squares.get(`${x},${y}`) ?? []);
1416
+ return found;
1417
+ };
1418
+ return {
1419
+ add: (point) => {
1420
+ const key = `${square(point[0])},${square(point[1])}`;
1421
+ squares.set(key, [...squares.get(key) ?? [], point]);
1422
+ },
1423
+ covers: ([x, y]) => within({
1424
+ maxX: x,
1425
+ maxY: y,
1426
+ minX: x,
1427
+ minY: y
1428
+ }).some(([otherX, otherY]) => Math.hypot(x - otherX, y - otherY) < room - COVER_SLACK_PX),
1429
+ near: within
1430
+ };
1431
+ };
1432
+ const placeOn = (drawn, rectangle, budget, taken) => {
1433
+ if (rectangle === null) return null;
1434
+ const parts = [];
1435
+ for (const polygon of drawn) {
1436
+ const part = clipPolygonToRectangle(polygon, rectangle);
1437
+ if (part !== null) parts.push({
1438
+ area: polygonArea(part),
1439
+ polygon: part
1440
+ });
1441
+ }
1442
+ parts.sort((left, right) => right.area - left.area);
1443
+ for (const { polygon } of parts) {
1444
+ const bounds = boundsOf(polygon);
1445
+ const avoid = bounds === null ? [] : taken.near(bounds);
1446
+ const point = interiorPoint(polygon, budget, avoid, ZONE_BADGE_ROOM_PX);
1447
+ if (point !== null) return {
1448
+ part: polygon,
1449
+ point
1450
+ };
1451
+ }
1452
+ return null;
1453
+ };
1454
+ const boxContains = (box, [x, y]) => x >= box.minX && x <= box.maxX && y >= box.minY && y <= box.maxY;
1455
+ function* placeZoneBadgesStepwise(features, previous, viewport) {
1456
+ if (!(viewport.width > 0) || !(viewport.height > 0)) return null;
1457
+ const [topLeft, topRight, bottomRight, bottomLeft] = viewport.corners;
1458
+ const ground = [
1459
+ groundOf(topLeft),
1460
+ groundOf(topRight),
1461
+ groundOf(bottomRight),
1462
+ groundOf(bottomLeft)
1463
+ ];
1464
+ const projection = planeProjection(ground, [
1465
+ [0, 0],
1466
+ [viewport.width, 0],
1467
+ [viewport.width, viewport.height],
1468
+ [0, viewport.height]
1469
+ ]);
1470
+ if (projection === null) return null;
1471
+ const aroundX = (ground[0][0] + ground[1][0] + ground[2][0] + ground[3][0]) / 4;
1472
+ const keepWithin = insetOf(viewport, 24);
1473
+ const placeWithin = [
1474
+ insetOf(viewport, 48),
1475
+ keepWithin,
1476
+ insetOf(viewport, 0)
1477
+ ];
1478
+ const surface = viewport.surface;
1479
+ const counted = ([x, y]) => [(x - .5) * 360, lngLatOf([x, y])[1]];
1480
+ const nearView = (lngLat) => {
1481
+ const [x, y] = groundOf(lngLat);
1482
+ return [x + Math.round(aroundX - x), y];
1483
+ };
1484
+ const around = {
1485
+ maxX: viewport.width * 2,
1486
+ maxY: viewport.height * 2,
1487
+ minX: -viewport.width,
1488
+ minY: -viewport.height
1489
+ };
1490
+ const draw = (polygon, budget) => {
1491
+ const flat = projection.project(polygon);
1492
+ if (surface === void 0 || flat === null) return flat;
1493
+ const near = clipPolygonToRectangle(flat, around);
1494
+ if (near === null) return null;
1495
+ const stepsOf = (from, to) => Math.max(1, Math.ceil(Math.hypot(to[0] - from[0], to[1] - from[1]) / DRAPE_STEP_PX));
1496
+ let places = 0;
1497
+ for (const ring of near) for (const [index, current] of ring.entries()) places += stepsOf(current, ring[(index + 1) % ring.length] ?? current);
1498
+ const cost = places * 64;
1499
+ if (cost > budget.visits / 2) return flat;
1500
+ budget.visits -= cost;
1501
+ return near.map((ring) => ring.flatMap((current, index) => {
1502
+ const next = ring[(index + 1) % ring.length] ?? current;
1503
+ const steps = stepsOf(current, next);
1504
+ return Array.from({ length: steps }, (_, step) => {
1505
+ const share = step / steps;
1506
+ return surface.project(counted(projection.toGround([current[0] + (next[0] - current[0]) * share, current[1] + (next[1] - current[1]) * share])));
1507
+ });
1508
+ }));
1509
+ };
1510
+ const holds = (zone, lngLat, budget) => {
1511
+ const at = nearView(lngLat);
1512
+ return zone.polygons.some((polygon) => {
1513
+ if (!boxContains(polygon.box, at)) return false;
1514
+ budget.visits -= polygon.edges;
1515
+ return polygonContains(polygon.written(), at);
1516
+ });
1517
+ };
1518
+ const edgesOf = (zone) => zone.polygons.reduce((count, polygon) => count + polygon.edges, 0);
1519
+ const readingOf = (zone) => 256 + edgesOf(zone);
1520
+ const shows = (lngLat, drawnAt, budget) => {
1521
+ if (surface === void 0) return true;
1522
+ budget.visits -= 256;
1523
+ const seen = projection.toScreen(nearView(surface.unproject(drawnAt)));
1524
+ const own = projection.toScreen(nearView(lngLat));
1525
+ return seen !== null && own !== null && Math.hypot(seen[0] - own[0], seen[1] - own[1]) <= SHOWN_SLACK_PX;
1526
+ };
1527
+ const placeAt = (zone, found, budget) => {
1528
+ if (surface === void 0) return {
1529
+ lngLat: lngLatOf(projection.toGround(found.point)),
1530
+ point: found.point
1531
+ };
1532
+ const reading = readingOf(zone);
1533
+ const shown = (candidate) => {
1534
+ budget.visits -= 256;
1535
+ const seen = surface.unproject(candidate);
1536
+ return holds(zone, seen, budget) ? {
1537
+ lngLat: [require_longitude.wrapLongitude(seen[0]), seen[1]],
1538
+ point: candidate
1539
+ } : null;
1540
+ };
1541
+ if (budget.visits < reading) return null;
1542
+ const own = shown(found.point);
1543
+ if (own !== null) return own;
1544
+ for (const candidate of shownCandidates(found.part, found.point, budget, reading)) {
1545
+ const spot = shown(candidate);
1546
+ if (spot !== null) return spot;
1547
+ }
1548
+ return null;
1549
+ };
1550
+ const grouped = /* @__PURE__ */ new Map();
1551
+ for (const feature of features) {
1552
+ const id = zoneIdOf(feature);
1553
+ if (id === null) continue;
1554
+ const pieces = grouped.get(id);
1555
+ if (pieces) pieces.push(feature);
1556
+ else grouped.set(id, [feature]);
1557
+ }
1558
+ const badges = /* @__PURE__ */ new Map();
1559
+ const taken = takenRoom(ZONE_BADGE_ROOM_PX);
1560
+ const unbadged = [];
1561
+ const standingZones = [];
1562
+ for (const id of [...grouped.keys()].sort()) {
1563
+ const pieces = grouped.get(id) ?? [];
1564
+ const zone = {
1565
+ id,
1566
+ polygons: pieces.flatMap((piece) => zonePolygons(piece.geometry, aroundX)),
1567
+ properties: pieces[0]?.properties ?? {}
1568
+ };
1569
+ const kept = previous.get(id);
1570
+ if (kept === void 0) unbadged.push(zone);
1571
+ else {
1572
+ badges.set(id, {
1573
+ lngLat: kept.lngLat,
1574
+ properties: zone.properties
1575
+ });
1576
+ standingZones.push({
1577
+ kept,
1578
+ zone
1579
+ });
1580
+ }
1581
+ }
1582
+ const moved = [];
1583
+ let step = { visits: ZONE_BADGE_SEARCH_VISITS };
1584
+ for (const { kept, zone } of standingZones) {
1585
+ const most = edgesOf(zone) + (surface === void 0 ? 0 : 320);
1586
+ if (step.visits < 2e5 && step.visits < most) {
1587
+ yield badges;
1588
+ step = { visits: ZONE_BADGE_SEARCH_VISITS };
1589
+ }
1590
+ const standing = nearView(kept.lngLat);
1591
+ if (surface !== void 0) step.visits -= 64;
1592
+ const onScreen = surface === void 0 ? projection.toScreen(standing) : surface.project(counted(standing));
1593
+ if (keepWithin !== null && onScreen !== null && onScreen[0] >= keepWithin.minX && onScreen[0] <= keepWithin.maxX && onScreen[1] >= keepWithin.minY && onScreen[1] <= keepWithin.maxY && !taken.covers(onScreen) && holds(zone, kept.lngLat, step) && shows(kept.lngLat, onScreen, step)) taken.add(onScreen);
1594
+ else moved.push(zone);
1595
+ }
1596
+ const screen = insetOf(viewport, 0);
1597
+ const cover = (box) => {
1598
+ const drawn = projection.project([[
1599
+ [box.minX, box.minY],
1600
+ [box.maxX, box.minY],
1601
+ [box.maxX, box.maxY],
1602
+ [box.minX, box.maxY]
1603
+ ]]);
1604
+ const shown = drawn === null || screen === null ? null : clipPolygonToRectangle(drawn, screen);
1605
+ return shown === null ? 0 : polygonArea(shown);
1606
+ };
1607
+ const queue = [...unbadged, ...moved];
1608
+ if (queue.length > 0 && step.visits < 2e5) yield badges;
1609
+ for (const [index, zone] of queue.entries()) {
1610
+ const ranked = zone.polygons.map((polygon) => ({
1611
+ cover: cover(polygon.box),
1612
+ polygon
1613
+ })).filter((entry) => entry.cover > 0).sort((left, right) => right.cover - left.cover);
1614
+ const budget = { visits: ZONE_BADGE_SEARCH_VISITS };
1615
+ let placed = null;
1616
+ for (const [tried, { polygon }] of ranked.entries()) {
1617
+ const drawn = draw(polygon.written(), budget);
1618
+ if (drawn !== null) for (const rectangle of placeWithin) {
1619
+ if (surface !== void 0 && budget.visits < readingOf(zone)) break;
1620
+ const search = surface === void 0 ? budget : { visits: Math.floor(budget.visits / 2) };
1621
+ const allotted = search.visits;
1622
+ const found = placeOn([drawn], rectangle, search, taken);
1623
+ if (search !== budget) budget.visits -= allotted - search.visits;
1624
+ placed = found === null ? null : placeAt(zone, found, budget);
1625
+ if (placed !== null) break;
1626
+ }
1627
+ if (placed === null && surface !== void 0) {
1628
+ const flat = projection.project(polygon.written());
1629
+ const found = flat === null ? null : placeOn([flat], placeWithin[2] ?? null, budget, taken);
1630
+ if (found !== null) placed = {
1631
+ lngLat: lngLatOf(projection.toGround(found.point)),
1632
+ point: found.point
1633
+ };
1634
+ }
1635
+ if (placed !== null) break;
1636
+ if (tried < ranked.length - 1) yield badges;
1637
+ }
1638
+ if (placed === null) badges.delete(zone.id);
1639
+ else {
1640
+ badges.set(zone.id, {
1641
+ lngLat: placed.lngLat,
1642
+ properties: zone.properties
1643
+ });
1644
+ taken.add(placed.point);
1645
+ }
1646
+ if (index < queue.length - 1) yield badges;
1647
+ }
1648
+ return badges;
1649
+ }
1650
+ const sameProperties = (left, right) => {
1651
+ const names = Object.keys(left);
1652
+ return names.length === Object.keys(right).length && names.every((name) => Object.hasOwn(right, name) && left[name] === right[name]);
1653
+ };
1654
+ const sameZoneBadges = (left, right) => {
1655
+ if (left.size !== right.size) return false;
1656
+ for (const [id, badge] of left) {
1657
+ const other = right.get(id);
1658
+ if (other === void 0 || other.lngLat[0] !== badge.lngLat[0] || other.lngLat[1] !== badge.lngLat[1] || !sameProperties(badge.properties, other.properties)) return false;
1659
+ }
1660
+ return true;
1661
+ };
1662
+ const zoneBadgeCollection = (badges) => {
1663
+ const features = [];
1664
+ for (const id of [...badges.keys()].sort()) {
1665
+ const badge = badges.get(id);
1666
+ if (badge !== void 0) features.push({
1667
+ geometry: {
1668
+ coordinates: [badge.lngLat[0], badge.lngLat[1]],
1669
+ type: "Point"
1670
+ },
1671
+ properties: { ...badge.properties },
1672
+ type: "Feature"
1673
+ });
1674
+ }
1675
+ return {
1676
+ features,
1677
+ type: "FeatureCollection"
1678
+ };
1679
+ };
1680
+ const ZONE_BADGE_SOURCE_ID = "zone-clock-badges";
1681
+ const ZONE_BADGE_LAYER_ID = "zone-clock-badges-icon";
1682
+ const ZONE_BADGE_FRAME_BUDGET_MS = 4;
1683
+ const ZONE_BADGE_RANK = 45;
1684
+ var ZoneBadgeEngine = class {
1685
+ map;
1686
+ placement;
1687
+ events;
1688
+ badges = /* @__PURE__ */ new Map();
1689
+ remembered = /* @__PURE__ */ new Map();
1690
+ target = null;
1691
+ pending = false;
1692
+ pass = null;
1693
+ shown = "";
1694
+ detachers = [];
1695
+ disposed = false;
1696
+ constructor(map, placement, events) {
1697
+ this.map = map;
1698
+ this.placement = placement;
1699
+ this.events = events;
1700
+ }
1701
+ draw(target) {
1702
+ if (this.disposed) return;
1703
+ if (target.layerIds.length === 0) {
1704
+ this.clear();
1705
+ return;
1706
+ }
1707
+ this.target = target;
1708
+ this.events.afterStyleLoad(() => {
1709
+ this.mount();
1710
+ });
1711
+ }
1712
+ mount() {
1713
+ if (this.disposed || this.target === null) return;
1714
+ if (this.map.getSource(ZONE_BADGE_SOURCE_ID) === void 0) this.map.addSource(ZONE_BADGE_SOURCE_ID, {
1715
+ data: zoneBadgeCollection(this.badges),
1716
+ type: "geojson"
1717
+ });
1718
+ if (this.map.getLayer(ZONE_BADGE_LAYER_ID) === void 0) this.placement.addLayerOrdered({
1719
+ id: ZONE_BADGE_LAYER_ID,
1720
+ layout: {
1721
+ "icon-allow-overlap": true,
1722
+ "icon-image": ZONE_CLOCK_IMAGE_ID,
1723
+ "icon-size": ZONE_BADGE_ICON_SIZE
1724
+ },
1725
+ source: ZONE_BADGE_SOURCE_ID,
1726
+ type: "symbol"
1727
+ }, ZONE_BADGE_RANK);
1728
+ this.listen();
1729
+ this.request();
1730
+ }
1731
+ dispose() {
1732
+ this.clear();
1733
+ this.disposed = true;
1734
+ }
1735
+ clear() {
1736
+ if (this.target === null) return;
1737
+ this.target = null;
1738
+ this.pending = false;
1739
+ this.pass = null;
1740
+ this.shown = "";
1741
+ this.badges = /* @__PURE__ */ new Map();
1742
+ this.remembered = /* @__PURE__ */ new Map();
1743
+ for (const detach of this.detachers.splice(0)) detach();
1744
+ this.placement.forgetLayerRank(ZONE_BADGE_LAYER_ID);
1745
+ const removeSource = () => {
1746
+ if (this.target === null && this.map.getSource(ZONE_BADGE_SOURCE_ID) !== void 0) this.map.removeSource(ZONE_BADGE_SOURCE_ID);
1747
+ };
1748
+ if (this.events.isStyleReloading()) this.events.afterStyleLoad(removeSource);
1749
+ else removeSource();
1750
+ }
1751
+ listen() {
1752
+ if (this.detachers.length > 0) return;
1753
+ this.detachers = [
1754
+ this.events.on("render", () => {
1755
+ this.frame();
1756
+ }),
1757
+ this.events.on("moveend", () => {
1758
+ this.request();
1759
+ }),
1760
+ this.events.on("sourcedata", (event) => {
1761
+ if (this.target?.sourceIds.includes(event.sourceId) === true || event.sourceId === this.map.getTerrain()?.source) this.request();
1762
+ })
1763
+ ];
1764
+ }
1765
+ request() {
1766
+ this.pending = true;
1767
+ this.map.triggerRepaint();
1768
+ }
1769
+ shownState() {
1770
+ return `${(this.target?.layerIds ?? []).map((id) => {
1771
+ const layer = this.map.getLayer(id);
1772
+ return layer === void 0 ? "-" : JSON.stringify(layer.visibility ?? "visible");
1773
+ }).join("|")}#${JSON.stringify(this.map.getTerrain())}`;
1774
+ }
1775
+ frame() {
1776
+ if (this.events.isStyleReloading()) return;
1777
+ const shown = this.shownState();
1778
+ if (shown !== this.shown) {
1779
+ this.shown = shown;
1780
+ this.pending = true;
1781
+ }
1782
+ if (!this.pending && this.pass === null) return;
1783
+ const started = performance.now();
1784
+ let step = this.pending ? this.begin() : this.pass?.steps.next() ?? null;
1785
+ const pass = this.pass;
1786
+ if (step === null || pass === null) return;
1787
+ while (step.done !== true && performance.now() - started < ZONE_BADGE_FRAME_BUDGET_MS) step = pass.steps.next();
1788
+ if (step.done === true) {
1789
+ this.pass = null;
1790
+ this.finish(step.value, pass.loaded);
1791
+ } else this.carry(step.value);
1792
+ }
1793
+ begin() {
1794
+ this.pending = false;
1795
+ this.pass = null;
1796
+ const target = this.target;
1797
+ const viewport = this.viewport();
1798
+ if (target === null || this.map.getSource(ZONE_BADGE_SOURCE_ID) === void 0) return null;
1799
+ if (viewport === null) return null;
1800
+ const layers = target.layerIds.filter((id) => this.map.getLayer(id) !== void 0);
1801
+ const loaded = target.sourceIds.every((id) => this.map.getSource(id) !== void 0 && this.map.isSourceLoaded(id) === true);
1802
+ const features = layers.length > 0 ? this.map.queryRenderedFeatures({
1803
+ filter: target.filter,
1804
+ layers,
1805
+ validate: false
1806
+ }) : [];
1807
+ const previous = new Map([...this.remembered, ...this.badges]);
1808
+ let steps = placeZoneBadgesStepwise(features, previous, viewport);
1809
+ let step = steps.next();
1810
+ if (step.done === true && step.value === null) {
1811
+ steps = placeZoneBadgesStepwise(features, previous, this.boundsOf(viewport));
1812
+ step = steps.next();
1813
+ }
1814
+ if (step.done === true && step.value === null) return null;
1815
+ this.pass = {
1816
+ loaded,
1817
+ steps
1818
+ };
1819
+ return step;
1820
+ }
1821
+ carry(placed) {
1822
+ this.badges = new Map(placed);
1823
+ this.write();
1824
+ this.map.triggerRepaint();
1825
+ }
1826
+ finish(placed, loaded) {
1827
+ if (placed === null) return;
1828
+ if (loaded) this.remembered = placed;
1829
+ else {
1830
+ const remembered = new Map(placed);
1831
+ for (const [id, badge] of this.remembered) if (!remembered.has(id)) remembered.set(id, badge);
1832
+ this.remembered = remembered;
1833
+ }
1834
+ if (sameZoneBadges(placed, this.badges)) return;
1835
+ this.badges = placed;
1836
+ this.write();
1837
+ }
1838
+ write() {
1839
+ const source = this.map.getSource(ZONE_BADGE_SOURCE_ID);
1840
+ if (source !== void 0) source.setData(zoneBadgeCollection(this.badges));
1841
+ }
1842
+ viewport() {
1843
+ const { clientHeight: height, clientWidth: width } = this.map.getCanvas();
1844
+ if (!(width > 0) || !(height > 0)) return null;
1845
+ const corner = (x, y) => {
1846
+ const { lat, lng } = this.map.unproject([x, y]);
1847
+ return [lng, lat];
1848
+ };
1849
+ const surface = this.map.getTerrain() === null ? void 0 : {
1850
+ project: (lngLat) => {
1851
+ const { x, y } = this.map.project(lngLat);
1852
+ return [x, y];
1853
+ },
1854
+ unproject: ([x, y]) => {
1855
+ const { lat, lng } = this.map.unproject([x, y]);
1856
+ return [lng, lat];
1857
+ }
1858
+ };
1859
+ return {
1860
+ corners: [
1861
+ corner(0, 0),
1862
+ corner(width, 0),
1863
+ corner(width, height),
1864
+ corner(0, height)
1865
+ ],
1866
+ height,
1867
+ surface,
1868
+ width
1869
+ };
1870
+ }
1871
+ boundsOf(viewport) {
1872
+ const bounds = this.map.getBounds();
1873
+ const [west, south, east, north] = [
1874
+ bounds.getWest(),
1875
+ bounds.getSouth(),
1876
+ bounds.getEast(),
1877
+ bounds.getNorth()
1878
+ ];
1879
+ return {
1880
+ ...viewport,
1881
+ corners: [
1882
+ [west, north],
1883
+ [east, north],
1884
+ [east, south],
1885
+ [west, south]
1886
+ ]
1887
+ };
1888
+ }
1889
+ };
1890
+ const ITINERARY_DIM_OPACITY = .25;
1891
+ const noTransition = {
1892
+ delay: 0,
1893
+ duration: 0
1894
+ };
1895
+ const transitionOf = {
1896
+ "circle-opacity": "circle-opacity-transition",
1897
+ "fill-opacity": "fill-opacity-transition",
1898
+ "icon-opacity": "icon-opacity-transition",
1899
+ "line-color": "line-color-transition",
1900
+ "line-opacity": "line-opacity-transition",
1901
+ "line-width": "line-width-transition"
1902
+ };
1903
+ const ITINERARY_EDIT_OPACITY = .75;
1904
+ const ITINERARY_EDIT_DASHARRAY = [2, 2];
1905
+ const ITINERARY_EDIT_GHOST_LAYER_SUFFIX = "__edit-ghost";
1906
+ const HOVER_WIDTH_MULTIPLIER = 1.75;
1907
+ const DEFAULT_LINE_WIDTH = 1;
1908
+ const REPAINT_JOG_MS = 200;
1909
+ const ZONE_STRIPE_LAYER_SUFFIX = "__zone-stripe";
1910
+ const DIRECTION_CHEVRON_LAYER_SUFFIX = "__direction-chevron";
1911
+ const editGhostLayerId = (lineLayerId) => `${lineLayerId}${ITINERARY_EDIT_GHOST_LAYER_SUFFIX}`;
1912
+ const isZoneSourceLayer = (sourceLayer) => sourceLayer === require_order.ZONE_FILL_SOURCE_LAYER;
1913
+ const hasZoneLayer = (source) => source.layers.some((layer) => isZoneSourceLayer(layer.source_layer));
1914
+ const itineraryOpacityProperty = (type) => {
1915
+ switch (type) {
1916
+ case "line": return "line-opacity";
1917
+ case "symbol": return "icon-opacity";
1918
+ case "circle": return "circle-opacity";
1919
+ default: return null;
1920
+ }
1921
+ };
1922
+ const itineraryOpacity = (emphasis, isLine) => {
1923
+ switch (emphasis.mode) {
1924
+ case "none": return 1;
1925
+ case "dimAll": return ITINERARY_DIM_OPACITY;
1926
+ case "itinerary": return [
1927
+ "case",
1928
+ [
1929
+ "==",
1930
+ ["get", "itinerary_id"],
1931
+ emphasis.id
1932
+ ],
1933
+ 1,
1934
+ ITINERARY_DIM_OPACITY
1935
+ ];
1936
+ case "segment": return isLine ? [
1937
+ "case",
1938
+ [
1939
+ "==",
1940
+ ["get", "segment_id"],
1941
+ emphasis.id
1942
+ ],
1943
+ 1,
1944
+ ITINERARY_DIM_OPACITY
1945
+ ] : ITINERARY_DIM_OPACITY;
1946
+ case "segments": return isLine ? [
1947
+ "case",
1948
+ [
1949
+ "in",
1950
+ ["get", "segment_id"],
1951
+ ["literal", emphasis.ids]
1952
+ ],
1953
+ 1,
1954
+ ITINERARY_DIM_OPACITY
1955
+ ] : ITINERARY_DIM_OPACITY;
1956
+ case "waypoint": return isLine ? 1 : [
1957
+ "case",
1958
+ [
1959
+ "==",
1960
+ ["get", "waypoint_id"],
1961
+ emphasis.id
1962
+ ],
1963
+ 1,
1964
+ ITINERARY_DIM_OPACITY
1965
+ ];
1966
+ }
1967
+ };
1968
+ const scaleLineWidth = (base, factor) => {
1969
+ if (typeof base === "number") return [
1970
+ "*",
1971
+ base,
1972
+ factor
1973
+ ];
1974
+ const [op, ...rest] = base;
1975
+ if (op === "interpolate" || op === "interpolate-hcl" || op === "interpolate-lab") {
1976
+ const [interpolation, input, ...stops] = rest;
1977
+ return [
1978
+ op,
1979
+ interpolation,
1980
+ input,
1981
+ ...stops.map((value, index) => index % 2 === 1 ? [
1982
+ "*",
1983
+ value,
1984
+ factor
1985
+ ] : value)
1986
+ ];
1987
+ }
1988
+ if (op === "step") {
1989
+ const [input, firstOutput, ...stops] = rest;
1990
+ const scaled = stops.map((value, index) => index % 2 === 1 ? [
1991
+ "*",
1992
+ value,
1993
+ factor
1994
+ ] : value);
1995
+ return [
1996
+ op,
1997
+ input,
1998
+ [
1999
+ "*",
2000
+ firstOutput,
2001
+ factor
2002
+ ],
2003
+ ...scaled
2004
+ ];
2005
+ }
2006
+ return base;
2007
+ };
2008
+ const itineraryLineWidth = (emphasis, baseWidth) => {
2009
+ switch (emphasis.mode) {
2010
+ case "none":
2011
+ case "dimAll":
2012
+ case "waypoint": return baseWidth;
2013
+ case "itinerary": return scaleLineWidth(baseWidth, [
2014
+ "case",
2015
+ [
2016
+ "==",
2017
+ ["get", "itinerary_id"],
2018
+ emphasis.id
2019
+ ],
2020
+ HOVER_WIDTH_MULTIPLIER,
2021
+ 1
2022
+ ]);
2023
+ case "segment": return scaleLineWidth(baseWidth, [
2024
+ "case",
2025
+ [
2026
+ "==",
2027
+ ["get", "segment_id"],
2028
+ emphasis.id
2029
+ ],
2030
+ HOVER_WIDTH_MULTIPLIER,
2031
+ 1
2032
+ ]);
2033
+ case "segments": return scaleLineWidth(baseWidth, [
2034
+ "case",
2035
+ [
2036
+ "in",
2037
+ ["get", "segment_id"],
2038
+ ["literal", emphasis.ids]
2039
+ ],
2040
+ HOVER_WIDTH_MULTIPLIER,
2041
+ 1
2042
+ ]);
2043
+ }
2044
+ };
2045
+ const endpointColorIconImage = (color, base) => [
2046
+ "match",
2047
+ [
2048
+ "coalesce",
2049
+ ["get", "icon"],
2050
+ ""
2051
+ ],
2052
+ require_order.ITINERARY_ENDPOINT_ICONS[0],
2053
+ require_sprites.waypointIconImageId(require_order.ITINERARY_ENDPOINT_ICONS[0], color),
2054
+ require_order.ITINERARY_ENDPOINT_ICONS[1],
2055
+ require_sprites.waypointIconImageId(require_order.ITINERARY_ENDPOINT_ICONS[1], color),
2056
+ base
2057
+ ];
2058
+ const hasItineraryLayer = (source) => source.layers.some((layer) => layer.source_layer === "itinerary_lines" || layer.source_layer === "itinerary_points");
2059
+ const itineraryExclusionFilter = (base, idProp, ids) => {
2060
+ if (ids.length === 0) return base ?? null;
2061
+ const exclude = ["!", [
2062
+ "in",
2063
+ ["get", idProp],
2064
+ ["literal", ids]
2065
+ ]];
2066
+ return base ? [
2067
+ "all",
2068
+ base,
2069
+ exclude
2070
+ ] : ["all", exclude];
2071
+ };
2072
+ const zoneExclusionFilter = (base, excludedId) => {
2073
+ if (excludedId === null) return base ?? null;
2074
+ const exclude = [
2075
+ "!=",
2076
+ ["get", "id"],
2077
+ excludedId
2078
+ ];
2079
+ return base ? [
2080
+ "all",
2081
+ base,
2082
+ exclude
2083
+ ] : ["all", exclude];
2084
+ };
2085
+ const CATEGORY_OVERLAY_SLOT = "overlay";
2086
+ const sameManifestValue = (left, right) => {
2087
+ if (left === right) return true;
2088
+ if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length === right.length && left.every((value, index) => sameManifestValue(value, right[index]));
2089
+ if (typeof left !== "object" || typeof right !== "object" || left === null || right === null) return false;
2090
+ const leftFields = left;
2091
+ const rightFields = right;
2092
+ const keys = Object.keys(leftFields);
2093
+ return keys.length === Object.keys(rightFields).length && keys.every((key) => Object.hasOwn(rightFields, key) && sameManifestValue(leftFields[key], rightFields[key]));
2094
+ };
2095
+ const zoneOverlayFilter = (reference, excludedId) => {
2096
+ const inactive = zoneClockVisibilityFilter(reference);
2097
+ return zoneExclusionFilter(inactive, excludedId) ?? inactive;
2098
+ };
2099
+ const HILLSHADE_DIRECTION_MAX_DEG = 359;
2100
+ const hillshadeDirection = (bearing) => {
2101
+ const wrapped = (bearing % 360 + 360) % 360;
2102
+ if (wrapped <= HILLSHADE_DIRECTION_MAX_DEG) return wrapped;
2103
+ return wrapped < 719 / 2 ? HILLSHADE_DIRECTION_MAX_DEG : 0;
2104
+ };
2105
+ var OverlayRenderer = class {
2106
+ mountayaMap;
2107
+ events;
2108
+ manifestMounts = /* @__PURE__ */ new Map();
2109
+ slotMounts = /* @__PURE__ */ new Map();
2110
+ tileOverridesById = /* @__PURE__ */ new Map();
2111
+ departedPins = /* @__PURE__ */ new Map();
2112
+ overlayMountWaits = /* @__PURE__ */ new Map();
2113
+ disposed = false;
2114
+ slotWrites = Promise.resolve();
2115
+ pendingSlotWrites = 0;
2116
+ overlayQueryLayerIds = [];
2117
+ lastHillshadeDirection = null;
2118
+ itineraryEmphasis = { mode: "none" };
2119
+ itinerarySegmentColor = null;
2120
+ accessRestrictionsVisible = true;
2121
+ itineraryExclusions = {
2122
+ segmentIds: [],
2123
+ waypointIds: []
2124
+ };
2125
+ activeItinerarySegments = [];
2126
+ editStyledSegmentId = null;
2127
+ zoneTimeReference = Math.floor(Date.now() / require_conversions.MILLISECONDS_PER_SECOND);
2128
+ excludedZoneId = null;
2129
+ excludedWaypointId = null;
2130
+ resolveMissingImage = (id) => loadMissingIcon(this.map, id, this.icons);
2131
+ map;
2132
+ icons;
2133
+ cancelMarkerWarm;
2134
+ zoneBadges;
2135
+ constructor(mountayaMap, events) {
2136
+ this.mountayaMap = mountayaMap;
2137
+ this.events = events;
2138
+ this.map = mountayaMap.raw;
2139
+ this.icons = mountayaMap.icons;
2140
+ this.events.setMissingImageResolver(this.resolveMissingImage);
2141
+ this.cancelMarkerWarm = schedulePrebakeMarkerIcons(this.map, this.icons);
2142
+ this.zoneBadges = new ZoneBadgeEngine(this.map, this, this.events);
2143
+ }
2144
+ dispose() {
2145
+ this.cancelMarkerWarm();
2146
+ this.zoneBadges.dispose();
2147
+ this.disposed = true;
2148
+ for (const waits of [...this.overlayMountWaits.values()]) for (const end of [...waits]) end(false);
2149
+ }
2150
+ whenCategoryOverlayMounted(slug, signal) {
2151
+ if (this.disposed) return Promise.resolve(false);
2152
+ if (this.pendingSlotWrites === 0 && this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug === slug) return Promise.resolve(true);
2153
+ if (signal?.aborted === true) return Promise.resolve(false);
2154
+ return new Promise((resolve) => {
2155
+ const waits = this.overlayMountWaits.get(slug) ?? /* @__PURE__ */ new Set();
2156
+ this.overlayMountWaits.set(slug, waits);
2157
+ const end = (mounted) => {
2158
+ waits.delete(end);
2159
+ if (waits.size === 0 && this.overlayMountWaits.get(slug) === waits) this.overlayMountWaits.delete(slug);
2160
+ signal?.removeEventListener("abort", onAbort);
2161
+ resolve(mounted);
2162
+ };
2163
+ const onAbort = () => {
2164
+ end(false);
2165
+ };
2166
+ waits.add(end);
2167
+ signal?.addEventListener("abort", onAbort, { once: true });
2168
+ });
2169
+ }
2170
+ answerOverlayMountWaits() {
2171
+ if (this.pendingSlotWrites > 0) return;
2172
+ const slug = this.slotMounts.get(CATEGORY_OVERLAY_SLOT)?.slug;
2173
+ if (slug === void 0) return;
2174
+ for (const end of [...this.overlayMountWaits.get(slug) ?? []]) end(true);
2175
+ }
2176
+ setTileLayerVisibility(layerId, visible) {
2177
+ if (this.pendingSlotWrites === 0) {
2178
+ this.mountayaMap.setLayerVisibility(layerId, visible);
2179
+ return;
2180
+ }
2181
+ this.queueSlotWrite(async () => {
2182
+ this.mountayaMap.setLayerVisibility(layerId, visible);
2183
+ });
2184
+ }
2185
+ setCategoryOverlay(overlay) {
2186
+ this.queueSlotWrite(async () => {
2187
+ if (overlay === null) {
2188
+ this.releaseSlot(CATEGORY_OVERLAY_SLOT);
2189
+ this.mountayaMap.clearOverlay();
2190
+ return;
2191
+ }
2192
+ await this.mountayaMap.setOverlaySpecification(overlay, { onMounted: (mounted) => {
2193
+ this.adoptSlotMount(CATEGORY_OVERLAY_SLOT, overlay.slug, mounted);
2194
+ } });
2195
+ });
2196
+ }
2197
+ addEnrichmentOverlay(overlay) {
2198
+ const slot = `${require_slotNames.ENRICHMENT_SLOT_PREFIX}${overlay.slug}`;
2199
+ this.queueSlotWrite(async () => {
2200
+ await this.mountayaMap.addEnrichmentSpecification(overlay, { onMounted: (mounted) => {
2201
+ this.adoptSlotMount(slot, overlay.slug, mounted);
2202
+ } });
2203
+ });
2204
+ }
2205
+ removeEnrichmentOverlay(slug) {
2206
+ this.queueSlotWrite(async () => {
2207
+ this.releaseSlot(`${require_slotNames.ENRICHMENT_SLOT_PREFIX}${slug}`);
2208
+ this.mountayaMap.removeEnrichment(slug);
2209
+ });
2210
+ }
2211
+ queueSlotWrite(write) {
2212
+ this.pendingSlotWrites += 1;
2213
+ this.slotWrites = this.slotWrites.then(write).catch((cause) => {
2214
+ this.map.fire("error", { error: require_errors.errorFrom(cause, "A write to an overlay slot failed. Check what the overlay's mount rejects with.") });
2215
+ }).finally(() => {
2216
+ this.pendingSlotWrites -= 1;
2217
+ this.answerOverlayMountWaits();
2218
+ });
2219
+ }
2220
+ whenSlotWritesLand() {
2221
+ return this.pendingSlotWrites === 0 ? null : this.slotWrites;
2222
+ }
2223
+ adoptSlotMount(slot, slug, mounted) {
2224
+ const departing = this.slotMounts.get(slot);
2225
+ if (departing) {
2226
+ const replaced = departing.slug !== slug;
2227
+ const incoming = new Set(mounted.sourceIds);
2228
+ for (const sourceId of departing.sourceIds) if (replaced || !incoming.has(sourceId)) this.tileOverridesById.delete(sourceId);
2229
+ }
2230
+ const departed = this.departedPins.get(slot);
2231
+ this.departedPins.delete(slot);
2232
+ if (departed?.slug === slug) for (const sourceId of mounted.sourceIds) {
2233
+ const tiles = departed.tilesById.get(sourceId);
2234
+ if (tiles !== void 0 && !this.tileOverridesById.has(sourceId)) this.tileOverridesById.set(sourceId, tiles);
2235
+ }
2236
+ this.slotMounts.set(slot, {
2237
+ layerIds: mounted.layerIds,
2238
+ slug,
2239
+ sourceIds: mounted.sourceIds
2240
+ });
2241
+ for (const sourceId of mounted.sourceIds) {
2242
+ const tiles = this.tileOverridesById.get(sourceId);
2243
+ if (tiles) this.applySourceTiles(sourceId, tiles);
2244
+ }
2245
+ this.applyHillshadeIllumination();
2246
+ if (slot === CATEGORY_OVERLAY_SLOT) this.answerOverlayMountWaits();
2247
+ }
2248
+ releaseSlot(slot) {
2249
+ const mount = this.slotMounts.get(slot);
2250
+ if (!mount) return;
2251
+ const tilesById = /* @__PURE__ */ new Map();
2252
+ for (const sourceId of mount.sourceIds) {
2253
+ const tiles = this.tileOverridesById.get(sourceId);
2254
+ if (tiles !== void 0) tilesById.set(sourceId, tiles);
2255
+ this.tileOverridesById.delete(sourceId);
2256
+ }
2257
+ if (tilesById.size > 0) this.departedPins.set(slot, {
2258
+ slug: mount.slug,
2259
+ tilesById
2260
+ });
2261
+ else this.departedPins.delete(slot);
2262
+ this.slotMounts.delete(slot);
2263
+ }
2264
+ addTileSources(sources) {
2265
+ for (const source of sources) this.queueSlotWrite(async () => {
2266
+ const mounted = this.manifestMounts.get(source.id);
2267
+ if (mounted) {
2268
+ if (sameManifestValue(mounted.source, source)) return;
2269
+ this.releaseCompanionLayers(mounted);
2270
+ }
2271
+ await this.mountayaMap.setSpecification(source.id, { sources: [source] }, { onMounted: (mount) => {
2272
+ this.adoptManifestMount(source, mount);
2273
+ } });
2274
+ });
2275
+ }
2276
+ removeTileSources(ids) {
2277
+ this.queueSlotWrite(async () => {
2278
+ for (const id of ids) this.releaseManifestMount(id);
2279
+ });
2280
+ }
2281
+ adoptManifestMount(source, mounted) {
2282
+ const companionLayerIds = [];
2283
+ if (hasItineraryLayer(source)) {
2284
+ loadDirectionArrowIcon(this.map);
2285
+ this.addDirectionLayers(source, companionLayerIds);
2286
+ this.addRoadAccessLayers(source, companionLayerIds, mounted.layerIds);
2287
+ }
2288
+ if (hasZoneLayer(source)) {
2289
+ loadZoneClockIcon(this.map, this.icons);
2290
+ loadZoneStripeIcons(this.map);
2291
+ this.addZoneStripeLayer(source, companionLayerIds);
2292
+ }
2293
+ this.manifestMounts.set(source.id, {
2294
+ companionLayerIds,
2295
+ layerIds: mounted.layerIds,
2296
+ source
2297
+ });
2298
+ for (const sourceId of mounted.sourceIds) {
2299
+ const tiles = this.tileOverridesById.get(sourceId);
2300
+ if (tiles) this.applySourceTiles(sourceId, tiles);
2301
+ }
2302
+ if (hasItineraryLayer(source)) {
2303
+ if (this.itinerarySegmentColor !== null) this.applyItinerarySegmentColor();
2304
+ this.applyItineraryEmphasis();
2305
+ this.applyItineraryExclusions();
2306
+ this.applyEditStyling();
2307
+ }
2308
+ if (hasZoneLayer(source)) {
2309
+ this.applyZoneTimeStyling();
2310
+ this.applyZoneExclusions();
2311
+ }
2312
+ this.drawZoneBadges();
2313
+ this.applyHillshadeIllumination();
2314
+ }
2315
+ releaseCompanionLayers(mount) {
2316
+ for (const layerId of mount.companionLayerIds) this.forgetLayerRank(layerId);
2317
+ for (const layer of mount.source.layers) if (layer.source_layer === "itinerary_lines") this.forgetLayerRank(editGhostLayerId(layer.id));
2318
+ }
2319
+ releaseManifestMount(id) {
2320
+ const mount = this.manifestMounts.get(id);
2321
+ if (!mount) return;
2322
+ this.releaseCompanionLayers(mount);
2323
+ this.tileOverridesById.delete(id);
2324
+ this.mountayaMap.removeSpecification(id);
2325
+ this.manifestMounts.delete(id);
2326
+ this.drawZoneBadges();
2327
+ }
2328
+ *manifestLayers() {
2329
+ for (const mount of this.manifestMounts.values()) yield* mount.source.layers;
2330
+ }
2331
+ repaintBustedTiles(sourceIds) {
2332
+ const map = this.map;
2333
+ if (!sourceIds.some((id) => map.getSource(id))) return;
2334
+ if (map.isMoving()) {
2335
+ map.triggerRepaint();
2336
+ return;
2337
+ }
2338
+ const zoom = map.getZoom();
2339
+ const detach = this.events.on("moveend", () => {
2340
+ detach();
2341
+ if (map.isMoving() || map._removed) return;
2342
+ map.easeTo({
2343
+ duration: REPAINT_JOG_MS,
2344
+ zoom
2345
+ });
2346
+ });
2347
+ map.easeTo({
2348
+ duration: REPAINT_JOG_MS,
2349
+ zoom: zoom - .1
2350
+ });
2351
+ }
2352
+ bustableSources(matches) {
2353
+ const sources = [];
2354
+ for (const mount of this.manifestMounts.values()) if (matches(mount.source)) sources.push({
2355
+ id: mount.source.id,
2356
+ tiles: this.tileOverridesById.get(mount.source.id) ?? mount.source.tiles
2357
+ });
2358
+ return sources;
2359
+ }
2360
+ refreshItineraryTiles(bustToken) {
2361
+ const itinerarySources = this.bustableSources(hasItineraryLayer);
2362
+ if (itinerarySources.length === 0) return;
2363
+ bustItineraryTileCache(this.map, itinerarySources, bustToken);
2364
+ this.repaintBustedTiles(itinerarySources.map((source) => source.id));
2365
+ }
2366
+ refreshZoneTiles() {
2367
+ const zoneSources = this.bustableSources(hasZoneLayer);
2368
+ if (zoneSources.length === 0) return;
2369
+ bustItineraryTileCache(this.map, zoneSources);
2370
+ this.repaintBustedTiles(zoneSources.map((source) => source.id));
2371
+ }
2372
+ setSourceTiles(sourceId, tiles) {
2373
+ this.tileOverridesById.set(sourceId, tiles);
2374
+ this.applySourceTiles(sourceId, tiles);
2375
+ }
2376
+ applySourceTiles(sourceId, tiles) {
2377
+ const source = this.map.getSource(sourceId);
2378
+ if (source && "setTiles" in source) source.setTiles(tiles);
2379
+ }
2380
+ setOverlayQueryLayers(layerIds) {
2381
+ this.overlayQueryLayerIds = layerIds;
2382
+ }
2383
+ getOverlayQueryLayerIds() {
2384
+ return this.overlayQueryLayerIds;
2385
+ }
2386
+ getZoneQueryLayerIds() {
2387
+ const layerIds = [];
2388
+ for (const layer of this.manifestLayers()) if (isZoneSourceLayer(layer.source_layer)) layerIds.push(layer.id);
2389
+ return layerIds;
2390
+ }
2391
+ ensureOverlayInZoomRange(overlay) {
2392
+ this.mountayaMap.easeIntoZoomRange({
2393
+ maxzoom: overlay.maxzoom,
2394
+ minzoom: overlay.minzoom
2395
+ });
2396
+ }
2397
+ prewarmItineraryIcons(icons) {
2398
+ for (const entry of icons) loadWaypointIcon(this.map, entry.icon, entry.color, this.icons);
2399
+ }
2400
+ setItineraryEmphasis(target) {
2401
+ this.itineraryEmphasis = target;
2402
+ this.applyItineraryEmphasis();
2403
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2404
+ }
2405
+ setItinerarySegmentColor(color) {
2406
+ if (this.itinerarySegmentColor === color) return;
2407
+ this.itinerarySegmentColor = color;
2408
+ this.applyItinerarySegmentColor();
2409
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2410
+ }
2411
+ setAccessRestrictionsVisibility(visible) {
2412
+ if (this.accessRestrictionsVisible === visible) return;
2413
+ this.accessRestrictionsVisible = visible;
2414
+ for (const mount of this.manifestMounts.values()) {
2415
+ const line = require_order.roadAccessLineLayerOf(mount.source);
2416
+ if (!line) continue;
2417
+ for (const layerId of [require_order.roadAccessStripeLayerId(line.id), require_order.roadAccessIconLayerId(line.id)]) if (this.map.getLayer(layerId)) this.map.setLayoutProperty(layerId, "visibility", visible ? "visible" : "none");
2418
+ }
2419
+ }
2420
+ setZoneTimeReference(epochSeconds) {
2421
+ this.zoneTimeReference = epochSeconds;
2422
+ this.applyZoneTimeStyling();
2423
+ this.drawZoneBadges();
2424
+ }
2425
+ setEditedZone(zoneId) {
2426
+ this.excludedZoneId = zoneId;
2427
+ this.applyZoneExclusions();
2428
+ this.drawZoneBadges();
2429
+ }
2430
+ setEditedWaypoint(waypointId) {
2431
+ this.excludedWaypointId = waypointId;
2432
+ this.applyItineraryExclusions();
2433
+ }
2434
+ setItineraryExclusions(exclusions) {
2435
+ this.itineraryExclusions = exclusions;
2436
+ this.applyItineraryExclusions();
2437
+ if (this.editStyledSegmentId !== null) this.applyEditStyling();
2438
+ }
2439
+ setActiveItinerarySegments(lines) {
2440
+ this.activeItinerarySegments = lines;
2441
+ }
2442
+ getActiveItinerarySegments() {
2443
+ return this.activeItinerarySegments;
2444
+ }
2445
+ setHillshadeIllumination(direction) {
2446
+ if (!Number.isFinite(direction)) return;
2447
+ this.lastHillshadeDirection = hillshadeDirection(direction);
2448
+ this.applyHillshadeIllumination();
2449
+ }
2450
+ setEditedSegment(segmentId) {
2451
+ this.editStyledSegmentId = segmentId;
2452
+ this.applyEditStyling();
2453
+ }
2454
+ reapplyItineraryPaint() {
2455
+ this.applyItineraryEmphasis();
2456
+ this.applyItineraryExclusions();
2457
+ }
2458
+ addLayerOrdered(spec, rank) {
2459
+ this.mountayaMap.addLayer(spec, rank);
2460
+ }
2461
+ forgetLayerRank(layerId) {
2462
+ this.mountayaMap.removeLayer(layerId);
2463
+ }
2464
+ applyEditStyling() {
2465
+ const editingId = this.editStyledSegmentId;
2466
+ if (editingId === null) {
2467
+ for (const layer of this.manifestLayers()) if (layer.source_layer === "itinerary_lines") this.forgetLayerRank(editGhostLayerId(layer.id));
2468
+ this.applyItineraryEmphasis();
2469
+ return;
2470
+ }
2471
+ for (const layer of this.manifestLayers()) {
2472
+ if (layer.source_layer !== "itinerary_lines" || layer.type !== "line") continue;
2473
+ const drawn = this.map.getLayer(layer.id);
2474
+ if (!drawn) continue;
2475
+ const editHidden = [
2476
+ "case",
2477
+ [
2478
+ "==",
2479
+ ["get", "segment_id"],
2480
+ editingId
2481
+ ],
2482
+ 0,
2483
+ itineraryOpacity(this.itineraryEmphasis, true)
2484
+ ];
2485
+ this.setFoldPaint(layer.id, "line-opacity", editHidden);
2486
+ if (require_order.isItineraryCasingLayer(layer)) continue;
2487
+ this.applyDirectionOpacity(layer.id, editHidden);
2488
+ this.drawEditGhost(layer, drawn.source, editingId);
2489
+ }
2490
+ this.applyRoadAccessOpacity([
2491
+ "case",
2492
+ [
2493
+ "==",
2494
+ ["get", "segment_id"],
2495
+ editingId
2496
+ ],
2497
+ 0,
2498
+ itineraryOpacity(this.itineraryEmphasis, true)
2499
+ ]);
2500
+ }
2501
+ drawEditGhost(layer, sourceId, segmentId) {
2502
+ const ghostId = editGhostLayerId(layer.id);
2503
+ const shown = itineraryExclusionFilter(layer.filter, "segment_id", this.itineraryExclusions.segmentIds);
2504
+ const edited = [
2505
+ "==",
2506
+ ["get", "segment_id"],
2507
+ segmentId
2508
+ ];
2509
+ const filter = shown === null ? edited : [
2510
+ "all",
2511
+ shown,
2512
+ edited
2513
+ ];
2514
+ const color = this.itinerarySegmentColor ?? layer.paint?.["line-color"];
2515
+ const width = itineraryLineWidth(this.itineraryEmphasis, layer.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH);
2516
+ if (this.map.getLayer(ghostId)) {
2517
+ this.map.setFilter(ghostId, filter);
2518
+ this.setFoldPaint(ghostId, "line-color", color);
2519
+ this.setFoldPaint(ghostId, "line-width", width);
2520
+ return;
2521
+ }
2522
+ this.addLayerOrdered({
2523
+ filter,
2524
+ id: ghostId,
2525
+ layout: layer.layout ?? {},
2526
+ maxzoom: layer.zoom_max,
2527
+ minzoom: layer.zoom_min,
2528
+ paint: {
2529
+ ...color === void 0 ? {} : { "line-color": color },
2530
+ "line-dasharray": [...ITINERARY_EDIT_DASHARRAY],
2531
+ "line-opacity": ITINERARY_EDIT_OPACITY,
2532
+ "line-width": width
2533
+ },
2534
+ source: sourceId,
2535
+ "source-layer": layer.source_layer,
2536
+ type: "line"
2537
+ }, 50);
2538
+ }
2539
+ applyHillshadeIllumination() {
2540
+ const direction = this.lastHillshadeDirection;
2541
+ if (direction === null) return;
2542
+ const drawn = [...[...this.manifestMounts.values()].map((mount) => mount.layerIds), ...[...this.slotMounts.values()].map((mount) => mount.layerIds)];
2543
+ for (const layerIds of drawn) for (const layerId of layerIds) if (this.map.getLayer(layerId)?.type === "hillshade") {
2544
+ this.map.setPaintProperty(layerId, "hillshade-illumination-anchor", "map");
2545
+ this.map.setPaintProperty(layerId, "hillshade-illumination-direction", direction);
2546
+ }
2547
+ }
2548
+ drawZoneBadges() {
2549
+ const layerIds = [];
2550
+ const sourceIds = /* @__PURE__ */ new Set();
2551
+ for (const mount of this.manifestMounts.values()) {
2552
+ const zoneLayers = mount.source.layers.filter((layer) => isZoneSourceLayer(layer.source_layer));
2553
+ const fills = zoneLayers.filter((layer) => layer.type === "fill");
2554
+ for (const layer of fills.length > 0 ? fills : zoneLayers) {
2555
+ layerIds.push(layer.id);
2556
+ sourceIds.add(layer.source ?? mount.source.id);
2557
+ }
2558
+ }
2559
+ this.zoneBadges.draw({
2560
+ filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
2561
+ layerIds,
2562
+ sourceIds: [...sourceIds]
2563
+ });
2564
+ }
2565
+ addZoneStripeLayer(source, companionLayerIds) {
2566
+ for (const layer of source.layers) {
2567
+ if (layer.source_layer !== "fills") continue;
2568
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2569
+ companionLayerIds.push(stripeLayerId);
2570
+ if (this.map.getLayer(stripeLayerId)) continue;
2571
+ this.addLayerOrdered({
2572
+ filter: zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId),
2573
+ id: stripeLayerId,
2574
+ maxzoom: layer.zoom_max,
2575
+ minzoom: layer.zoom_min,
2576
+ paint: {
2577
+ "fill-opacity": ZONE_INACTIVE_FILL_OPACITY,
2578
+ "fill-pattern": zoneStripeFillPattern()
2579
+ },
2580
+ source: layer.source ?? source.id,
2581
+ "source-layer": layer.source_layer,
2582
+ type: "fill"
2583
+ }, 40);
2584
+ }
2585
+ }
2586
+ addDirectionLayers(source, companionLayerIds) {
2587
+ const waypointZoom = this.waypointZoomBounds(source);
2588
+ for (const layer of source.layers) {
2589
+ if (layer.source_layer !== "itinerary_lines") continue;
2590
+ if (require_order.isItineraryCasingLayer(layer)) continue;
2591
+ const minzoom = waypointZoom?.minzoom ?? layer.zoom_min;
2592
+ const maxzoom = waypointZoom?.maxzoom ?? layer.zoom_max;
2593
+ const chevronLayerId = `${layer.id}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2594
+ companionLayerIds.push(chevronLayerId);
2595
+ if (this.map.getLayer(chevronLayerId)) continue;
2596
+ this.addLayerOrdered({
2597
+ id: chevronLayerId,
2598
+ layout: { ...directionChevronLayout() },
2599
+ maxzoom,
2600
+ minzoom,
2601
+ paint: { "icon-opacity": DIRECTION_CHEVRON_OPACITY },
2602
+ source: layer.source ?? source.id,
2603
+ "source-layer": layer.source_layer,
2604
+ type: "symbol"
2605
+ }, 60);
2606
+ }
2607
+ }
2608
+ addRoadAccessLayers(source, companionLayerIds, drawnLayerIds) {
2609
+ const layers = require_roadAccessLine.roadAccessLayersOf(source, { visible: this.accessRestrictionsVisible });
2610
+ if (layers.length === 0) return;
2611
+ loadRoadAccessIcons(this.map, this.icons);
2612
+ for (const { layer, rank } of layers) {
2613
+ companionLayerIds.push(layer.id);
2614
+ if (this.map.getLayer(layer.id)) this.map.setLayoutProperty(layer.id, "visibility", this.accessRestrictionsVisible ? "visible" : "none");
2615
+ else if (!drawnLayerIds.includes(layer.id)) this.addLayerOrdered(layer, rank);
2616
+ }
2617
+ }
2618
+ applyRoadAccessOpacity(lineOpacity) {
2619
+ for (const mount of this.manifestMounts.values()) {
2620
+ const line = require_order.roadAccessLineLayerOf(mount.source);
2621
+ if (!line) continue;
2622
+ const stripeLayerId = require_order.roadAccessStripeLayerId(line.id);
2623
+ if (this.map.getLayer(stripeLayerId)) {
2624
+ const stripeOpacity = [
2625
+ "*",
2626
+ lineOpacity,
2627
+ require_roadAccessLine.ROAD_ACCESS_STRIPE_OPACITY
2628
+ ];
2629
+ this.setFoldPaint(stripeLayerId, "line-opacity", stripeOpacity);
2630
+ const baseWidth = line.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH;
2631
+ this.setFoldPaint(stripeLayerId, "line-width", itineraryLineWidth(this.itineraryEmphasis, baseWidth));
2632
+ }
2633
+ const iconLayerId = require_order.roadAccessIconLayerId(line.id);
2634
+ if (this.map.getLayer(iconLayerId)) this.setFoldPaint(iconLayerId, "icon-opacity", lineOpacity);
2635
+ }
2636
+ }
2637
+ applyRoadAccessExclusion() {
2638
+ const filter = itineraryExclusionFilter(void 0, "segment_id", this.itineraryExclusions.segmentIds);
2639
+ for (const mount of this.manifestMounts.values()) {
2640
+ const line = require_order.roadAccessLineLayerOf(mount.source);
2641
+ if (!line) continue;
2642
+ for (const layerId of [require_order.roadAccessStripeLayerId(line.id), require_order.roadAccessIconLayerId(line.id)]) if (this.map.getLayer(layerId)) this.map.setFilter(layerId, filter);
2643
+ }
2644
+ }
2645
+ waypointZoomBounds(source) {
2646
+ for (const layer of source.layers) if (layer.source_layer === "itinerary_points") return {
2647
+ maxzoom: layer.zoom_max,
2648
+ minzoom: layer.zoom_min
2649
+ };
2650
+ return null;
2651
+ }
2652
+ applyZoneTimeStyling() {
2653
+ const reference = this.zoneTimeReference;
2654
+ for (const layer of this.manifestLayers()) {
2655
+ if (!isZoneSourceLayer(layer.source_layer)) continue;
2656
+ if (!this.map.getLayer(layer.id)) continue;
2657
+ if (layer.type === "fill") this.setFoldPaint(layer.id, "fill-opacity", ZONE_FILL_OPACITY);
2658
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2659
+ if (this.map.getLayer(stripeLayerId)) this.map.setFilter(stripeLayerId, zoneOverlayFilter(reference, this.excludedZoneId));
2660
+ }
2661
+ }
2662
+ applyZoneExclusions() {
2663
+ for (const layer of this.manifestLayers()) {
2664
+ if (!isZoneSourceLayer(layer.source_layer)) continue;
2665
+ if (!this.map.getLayer(layer.id)) continue;
2666
+ const base = layer.filter;
2667
+ this.map.setFilter(layer.id, zoneExclusionFilter(base, this.excludedZoneId));
2668
+ const stripeLayerId = `${layer.id}${ZONE_STRIPE_LAYER_SUFFIX}`;
2669
+ if (this.map.getLayer(stripeLayerId)) this.map.setFilter(stripeLayerId, zoneOverlayFilter(this.zoneTimeReference, this.excludedZoneId));
2670
+ }
2671
+ }
2672
+ applyItinerarySegmentColor() {
2673
+ const color = this.itinerarySegmentColor;
2674
+ if (color !== null) for (const icon of require_order.ITINERARY_ENDPOINT_ICONS) loadWaypointIcon(this.map, icon, color, this.icons).catch(() => {});
2675
+ for (const layer of this.manifestLayers()) {
2676
+ if (!this.map.getLayer(layer.id)) continue;
2677
+ if (layer.source_layer === "itinerary_lines" && layer.type === "line") {
2678
+ if (require_order.isItineraryCasingLayer(layer)) continue;
2679
+ const baseColor = layer.paint?.["line-color"];
2680
+ this.setFoldPaint(layer.id, "line-color", color ?? baseColor);
2681
+ continue;
2682
+ }
2683
+ if (layer.source_layer === "itinerary_points" && layer.type === "symbol") {
2684
+ const baseImage = layer.layout?.["icon-image"];
2685
+ if (baseImage === void 0) continue;
2686
+ this.map.setLayoutProperty(layer.id, "icon-image", color === null ? baseImage : endpointColorIconImage(color, baseImage));
2687
+ }
2688
+ }
2689
+ }
2690
+ applyItineraryEmphasis() {
2691
+ for (const layer of this.manifestLayers()) {
2692
+ const isLine = layer.source_layer === require_order.ITINERARY_LINE_SOURCE_LAYER;
2693
+ const isPoint = layer.source_layer === require_order.ITINERARY_POINT_SOURCE_LAYER;
2694
+ if (!isLine && !isPoint) continue;
2695
+ const property = itineraryOpacityProperty(layer.type);
2696
+ if (!property || !this.map.getLayer(layer.id)) continue;
2697
+ const expr = itineraryOpacity(this.itineraryEmphasis, isLine);
2698
+ this.setFoldPaint(layer.id, property, expr);
2699
+ if (isLine && layer.type === "line") {
2700
+ const baseWidth = layer.paint?.["line-width"] ?? DEFAULT_LINE_WIDTH;
2701
+ this.setFoldPaint(layer.id, "line-width", itineraryLineWidth(this.itineraryEmphasis, baseWidth));
2702
+ if (!require_order.isItineraryCasingLayer(layer)) this.applyDirectionOpacity(layer.id, expr);
2703
+ }
2704
+ }
2705
+ this.applyRoadAccessOpacity(itineraryOpacity(this.itineraryEmphasis, true));
2706
+ }
2707
+ applyDirectionOpacity(lineLayerId, lineOpacity) {
2708
+ const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2709
+ if (this.map.getLayer(chevronLayerId)) {
2710
+ const chevronOpacity = [
2711
+ "*",
2712
+ lineOpacity,
2713
+ DIRECTION_CHEVRON_OPACITY
2714
+ ];
2715
+ this.setFoldPaint(chevronLayerId, "icon-opacity", chevronOpacity);
2716
+ }
2717
+ }
2718
+ setFoldPaint(layerId, property, value) {
2719
+ this.map.setPaintProperty(layerId, transitionOf[property], noTransition);
2720
+ this.map.setPaintProperty(layerId, property, value);
2721
+ }
2722
+ applyItineraryExclusions() {
2723
+ for (const layer of this.manifestLayers()) {
2724
+ const isLine = layer.source_layer === require_order.ITINERARY_LINE_SOURCE_LAYER;
2725
+ const isPoint = layer.source_layer === require_order.ITINERARY_POINT_SOURCE_LAYER;
2726
+ if (!isLine && !isPoint) continue;
2727
+ if (!this.map.getLayer(layer.id)) continue;
2728
+ const idProp = isLine ? "segment_id" : "waypoint_id";
2729
+ const ids = isLine ? this.itineraryExclusions.segmentIds : this.excludedWaypointId ? [...this.itineraryExclusions.waypointIds, this.excludedWaypointId] : this.itineraryExclusions.waypointIds;
2730
+ const base = layer.filter;
2731
+ this.map.setFilter(layer.id, itineraryExclusionFilter(base, idProp, ids));
2732
+ if (isLine && !require_order.isItineraryCasingLayer(layer)) this.applyDirectionExclusion(layer.id);
2733
+ }
2734
+ this.applyRoadAccessExclusion();
2735
+ }
2736
+ applyDirectionExclusion(lineLayerId) {
2737
+ const filter = itineraryExclusionFilter(void 0, "segment_id", this.itineraryExclusions.segmentIds);
2738
+ const chevronLayerId = `${lineLayerId}${DIRECTION_CHEVRON_LAYER_SUFFIX}`;
2739
+ if (this.map.getLayer(chevronLayerId)) this.map.setFilter(chevronLayerId, filter);
2740
+ }
2741
+ };
2742
+ const PEER_DRAFT_PREFIX = "peer-draft";
2743
+ const PEER_DRAFT_CORE_WIDTH = 4;
2744
+ const PEER_DRAFT_CORE_OPACITY = .95;
2745
+ const PEER_DRAFT_HALO_WIDTH = 12;
2746
+ const PEER_DRAFT_HALO_BLUR = 4;
2747
+ const PEER_DRAFT_HALO_OPACITY_MIN = .14;
2748
+ const PEER_DRAFT_HALO_OPACITY_MID = .48000000000000004 / 2;
2749
+ const PEER_DRAFT_PUCK_RADIUS = 5;
2750
+ const PEER_DRAFT_PUCK_STROKE_WIDTH = 2;
2751
+ const PEER_DRAFT_STROKE_COLOR = "#ffffff";
2752
+ const PEER_DRAFT_LABEL_TEXT_COLOR = "#ffffff";
2753
+ const PEER_DRAFT_LABEL_TEXT_SIZE = 12;
2754
+ const PEER_DRAFT_LABEL_HALO_WIDTH = 1.5;
2755
+ const PEER_DRAFT_LABEL_PROPERTY = "label";
2756
+ const PEER_DRAFT_LABEL_OFFSET = [0, -.9];
2757
+ const PEER_DRAFT_LABEL_TEXT_FIELD = ["get", PEER_DRAFT_LABEL_PROPERTY];
2758
+ const PEER_DRAFT_ZONE_FILL_OPACITY = .12;
2759
+ const PEER_DRAFT_RING_RADIUS = 6;
2760
+ const PEER_DRAFT_RING_OPACITY = .95;
2761
+ const PEER_DRAFT_RING_STROKE_WIDTH = 2;
2762
+ const PEER_DRAFT_RING_HALO_RADIUS_MIN = 8;
2763
+ const PEER_DRAFT_RING_HALO_RADIUS_MID = 12;
2764
+ const PEER_DRAFT_RING_HALO_OPACITY_MAX = .35;
2765
+ const PEER_DRAFT_RING_HALO_OPACITY_MID = .44999999999999996 / 2;
2766
+ const PEER_DRAFT_RING_HALO_BLUR = .4;
2767
+ const PEER_DRAFT_PULSE_PERIOD_MS = 1400;
2768
+ const PEER_DRAFT_PULSE_FPS = 30;
2769
+ const PEER_DRAFT_LAYER_SUFFIXES = [
2770
+ "-halo",
2771
+ "-core",
2772
+ "-fill",
2773
+ "-puck",
2774
+ "-label"
2775
+ ];
2776
+ const PEER_DRAFT_POINT_FILTER = [
2777
+ "==",
2778
+ ["geometry-type"],
2779
+ "Point"
2780
+ ];
2781
+ const ghostFamilies = {
2782
+ segment: "line",
2783
+ waypoint: "point",
2784
+ zone: "polygon"
2785
+ };
2786
+ const ghostGeometryOf = (type) => {
2787
+ switch (type) {
2788
+ case "LineString":
2789
+ case "MultiLineString": return "line";
2790
+ case "Polygon":
2791
+ case "MultiPolygon": return "polygon";
2792
+ case "Point":
2793
+ case "MultiPoint": return "point";
2794
+ default: return null;
2795
+ }
2796
+ };
2797
+ const drawnFamilyOf = (state) => {
2798
+ const family = ghostGeometryOf(state.geometry.type);
2799
+ return family === ghostFamilies[state.kind] ? family : null;
2800
+ };
2801
+ const leadingVertex = (geometry) => {
2802
+ if (geometry.type === "LineString") return geometry.coordinates.at(-1) ?? null;
2803
+ if (geometry.type === "MultiLineString") return geometry.coordinates.at(-1)?.at(-1) ?? null;
2804
+ return null;
2805
+ };
2806
+ const ghostFeatureCollection = (geometry, label) => {
2807
+ const features = [{
2808
+ geometry,
2809
+ properties: {},
2810
+ type: "Feature"
2811
+ }];
2812
+ const tip = leadingVertex(geometry);
2813
+ if (tip) features.push({
2814
+ geometry: {
2815
+ coordinates: tip,
2816
+ type: "Point"
2817
+ },
2818
+ properties: { [PEER_DRAFT_LABEL_PROPERTY]: label ?? "" },
2819
+ type: "Feature"
2820
+ });
2821
+ return {
2822
+ features,
2823
+ type: "FeatureCollection"
2824
+ };
2825
+ };
2826
+ const peerDraftPulseWave = (timeMs) => {
2827
+ const phase = (timeMs % PEER_DRAFT_PULSE_PERIOD_MS + PEER_DRAFT_PULSE_PERIOD_MS) % PEER_DRAFT_PULSE_PERIOD_MS / PEER_DRAFT_PULSE_PERIOD_MS;
2828
+ return .5 - .5 * Math.cos(2 * Math.PI * phase);
2829
+ };
2830
+ const haloLineOpacity = (wave) => PEER_DRAFT_HALO_OPACITY_MIN + .2 * wave;
2831
+ const ringHaloRadius = (wave) => PEER_DRAFT_RING_HALO_RADIUS_MIN + 8 * wave;
2832
+ const ringHaloOpacity = (wave) => PEER_DRAFT_RING_HALO_OPACITY_MAX - .24999999999999997 * wave;
2833
+ const entityKey = (entity) => `${entity.kind}/${entity.id}`;
2834
+ const sourceId = (key) => `${PEER_DRAFT_PREFIX}-${key}`;
2835
+ const candidateLayerIds = (key) => PEER_DRAFT_LAYER_SUFFIXES.map((suffix) => `${PEER_DRAFT_PREFIX}-${key}${suffix}`);
2836
+ const colorPairs = (geometry, base) => {
2837
+ switch (geometry) {
2838
+ case "line": return [
2839
+ [`${base}-halo`, "line-color"],
2840
+ [`${base}-core`, "line-color"],
2841
+ [`${base}-puck`, "circle-color"],
2842
+ [`${base}-label`, "text-halo-color"]
2843
+ ];
2844
+ case "polygon": return [
2845
+ [`${base}-fill`, "fill-color"],
2846
+ [`${base}-halo`, "line-color"],
2847
+ [`${base}-core`, "line-color"]
2848
+ ];
2849
+ case "point": return [[`${base}-halo`, "circle-color"], [`${base}-core`, "circle-color"]];
2850
+ }
2851
+ };
2852
+ const layerSpecs = (geometry, base, source, color) => {
2853
+ switch (geometry) {
2854
+ case "line": return [
2855
+ {
2856
+ id: `${base}-halo`,
2857
+ layout: {
2858
+ "line-cap": "round",
2859
+ "line-join": "round"
2860
+ },
2861
+ paint: {
2862
+ "line-blur": PEER_DRAFT_HALO_BLUR,
2863
+ "line-color": color,
2864
+ "line-opacity": PEER_DRAFT_HALO_OPACITY_MID,
2865
+ "line-width": PEER_DRAFT_HALO_WIDTH
2866
+ },
2867
+ source,
2868
+ type: "line"
2869
+ },
2870
+ {
2871
+ id: `${base}-core`,
2872
+ layout: {
2873
+ "line-cap": "round",
2874
+ "line-join": "round"
2875
+ },
2876
+ paint: {
2877
+ "line-color": color,
2878
+ "line-opacity": PEER_DRAFT_CORE_OPACITY,
2879
+ "line-width": PEER_DRAFT_CORE_WIDTH
2880
+ },
2881
+ source,
2882
+ type: "line"
2883
+ },
2884
+ {
2885
+ filter: PEER_DRAFT_POINT_FILTER,
2886
+ id: `${base}-puck`,
2887
+ paint: {
2888
+ "circle-color": color,
2889
+ "circle-radius": PEER_DRAFT_PUCK_RADIUS,
2890
+ "circle-stroke-color": PEER_DRAFT_STROKE_COLOR,
2891
+ "circle-stroke-width": PEER_DRAFT_PUCK_STROKE_WIDTH
2892
+ },
2893
+ source,
2894
+ type: "circle"
2895
+ }
2896
+ ];
2897
+ case "polygon": return [
2898
+ {
2899
+ id: `${base}-fill`,
2900
+ paint: {
2901
+ "fill-color": color,
2902
+ "fill-opacity": PEER_DRAFT_ZONE_FILL_OPACITY
2903
+ },
2904
+ source,
2905
+ type: "fill"
2906
+ },
2907
+ {
2908
+ id: `${base}-halo`,
2909
+ layout: {
2910
+ "line-cap": "round",
2911
+ "line-join": "round"
2912
+ },
2913
+ paint: {
2914
+ "line-blur": PEER_DRAFT_HALO_BLUR,
2915
+ "line-color": color,
2916
+ "line-opacity": PEER_DRAFT_HALO_OPACITY_MID,
2917
+ "line-width": PEER_DRAFT_HALO_WIDTH
2918
+ },
2919
+ source,
2920
+ type: "line"
2921
+ },
2922
+ {
2923
+ id: `${base}-core`,
2924
+ layout: {
2925
+ "line-cap": "round",
2926
+ "line-join": "round"
2927
+ },
2928
+ paint: {
2929
+ "line-color": color,
2930
+ "line-opacity": PEER_DRAFT_CORE_OPACITY,
2931
+ "line-width": PEER_DRAFT_CORE_WIDTH
2932
+ },
2933
+ source,
2934
+ type: "line"
2935
+ }
2936
+ ];
2937
+ case "point": return [{
2938
+ id: `${base}-halo`,
2939
+ paint: {
2940
+ "circle-blur": PEER_DRAFT_RING_HALO_BLUR,
2941
+ "circle-color": color,
2942
+ "circle-opacity": PEER_DRAFT_RING_HALO_OPACITY_MID,
2943
+ "circle-radius": PEER_DRAFT_RING_HALO_RADIUS_MID
2944
+ },
2945
+ source,
2946
+ type: "circle"
2947
+ }, {
2948
+ id: `${base}-core`,
2949
+ paint: {
2950
+ "circle-color": color,
2951
+ "circle-opacity": PEER_DRAFT_RING_OPACITY,
2952
+ "circle-radius": PEER_DRAFT_RING_RADIUS,
2953
+ "circle-stroke-color": PEER_DRAFT_STROKE_COLOR,
2954
+ "circle-stroke-width": PEER_DRAFT_RING_STROKE_WIDTH
2955
+ },
2956
+ source,
2957
+ type: "circle"
2958
+ }];
2959
+ }
2960
+ };
2961
+ const labelLayerSpec = (base, source, color) => ({
2962
+ filter: PEER_DRAFT_POINT_FILTER,
2963
+ id: `${base}-label`,
2964
+ layout: {
2965
+ "text-allow-overlap": true,
2966
+ "text-anchor": "bottom",
2967
+ "text-field": PEER_DRAFT_LABEL_TEXT_FIELD,
2968
+ "text-ignore-placement": true,
2969
+ "text-offset": PEER_DRAFT_LABEL_OFFSET,
2970
+ "text-size": PEER_DRAFT_LABEL_TEXT_SIZE
2971
+ },
2972
+ paint: {
2973
+ "text-color": PEER_DRAFT_LABEL_TEXT_COLOR,
2974
+ "text-halo-color": color,
2975
+ "text-halo-width": PEER_DRAFT_LABEL_HALO_WIDTH
2976
+ },
2977
+ source,
2978
+ type: "symbol"
2979
+ });
2980
+ var PeerDraftLayer = class {
2981
+ map;
2982
+ placement;
2983
+ events;
2984
+ drafts = /* @__PURE__ */ new Map();
2985
+ pulse;
2986
+ constructor(map, placement, events, scheduler, prefersReducedMotion) {
2987
+ this.map = map;
2988
+ this.placement = placement;
2989
+ this.events = events;
2990
+ this.pulse = new FrameLoopEngine((timeMs) => this.applyPulse(peerDraftPulseWave(timeMs)), () => this.hasDrawnDraft(), {
2991
+ fps: PEER_DRAFT_PULSE_FPS,
2992
+ prefersReducedMotion,
2993
+ scheduler
2994
+ });
2995
+ }
2996
+ set(entity, geometry, color, label) {
2997
+ const key = entityKey(entity);
2998
+ const state = {
2999
+ color,
3000
+ geometry,
3001
+ kind: entity.kind,
3002
+ label
3003
+ };
3004
+ this.drafts.set(key, state);
3005
+ this.events.afterStyleLoad(() => this.render(key));
3006
+ if (drawnFamilyOf(state) !== null) {
3007
+ this.pulse.ensure();
3008
+ return;
3009
+ }
3010
+ this.stopPulseIfNothingIsDrawn();
3011
+ }
3012
+ clear(entity) {
3013
+ const key = entityKey(entity);
3014
+ if (!this.drafts.delete(key)) return;
3015
+ this.events.afterStyleLoad(() => this.teardownKey(key));
3016
+ this.stopPulseIfNothingIsDrawn();
3017
+ }
3018
+ clearAll() {
3019
+ const keys = [...this.drafts.keys()];
3020
+ this.drafts.clear();
3021
+ this.pulse.stop();
3022
+ this.events.afterStyleLoad(() => {
3023
+ for (const key of keys) this.teardownKey(key);
3024
+ });
3025
+ }
3026
+ replay() {
3027
+ const keys = [...this.drafts.keys()];
3028
+ this.events.afterStyleLoad(() => {
3029
+ for (const key of keys) this.render(key);
3030
+ });
3031
+ this.pulse.ensure();
3032
+ }
3033
+ dispose() {
3034
+ this.pulse.dispose();
3035
+ for (const key of this.drafts.keys()) this.teardownKey(key);
3036
+ this.drafts.clear();
3037
+ }
3038
+ render(key) {
3039
+ const state = this.drafts.get(key);
3040
+ if (!state) {
3041
+ this.teardownKey(key);
3042
+ return;
3043
+ }
3044
+ const geometry = drawnFamilyOf(state);
3045
+ if (!geometry) {
3046
+ this.teardownKey(key);
3047
+ return;
3048
+ }
3049
+ const base = `${PEER_DRAFT_PREFIX}-${key}`;
3050
+ const source = sourceId(key);
3051
+ const data = ghostFeatureCollection(state.geometry, state.label);
3052
+ const existing = this.map.getSource(source);
3053
+ if (existing) {
3054
+ existing.setData(data);
3055
+ this.applyColor(base, geometry, state.color);
3056
+ this.reconcileLabel(base, source, geometry, state.color, state.label);
3057
+ return;
3058
+ }
3059
+ this.teardownKey(key);
3060
+ this.map.addSource(source, {
3061
+ data,
3062
+ type: "geojson"
3063
+ });
3064
+ for (const spec of layerSpecs(geometry, base, source, state.color)) this.placement.addLayerOrdered(spec, 100);
3065
+ this.reconcileLabel(base, source, geometry, state.color, state.label);
3066
+ }
3067
+ reconcileLabel(base, source, geometry, color, label) {
3068
+ const labelId = `${base}-label`;
3069
+ const shouldExist = geometry === "line" && this.styleHasGlyphs() && Boolean(label);
3070
+ const exists = Boolean(this.map.getLayer(labelId));
3071
+ if (shouldExist && !exists) {
3072
+ this.placement.addLayerOrdered(labelLayerSpec(base, source, color), 100);
3073
+ return;
3074
+ }
3075
+ if (!shouldExist && exists) this.placement.forgetLayerRank(labelId);
3076
+ }
3077
+ styleHasGlyphs() {
3078
+ try {
3079
+ const glyphs = this.map.getGlyphs();
3080
+ return typeof glyphs === "string" && glyphs.length > 0;
3081
+ } catch {
3082
+ return false;
3083
+ }
3084
+ }
3085
+ applyColor(base, geometry, color) {
3086
+ for (const [layerId, property] of colorPairs(geometry, base)) if (this.map.getLayer(layerId)) this.map.setPaintProperty(layerId, property, color);
3087
+ }
3088
+ teardownKey(key) {
3089
+ for (const layerId of candidateLayerIds(key)) this.placement.forgetLayerRank(layerId);
3090
+ if (this.map.getSource(sourceId(key))) this.map.removeSource(sourceId(key));
3091
+ }
3092
+ hasDrawnDraft() {
3093
+ for (const state of this.drafts.values()) if (drawnFamilyOf(state) !== null) return true;
3094
+ return false;
3095
+ }
3096
+ stopPulseIfNothingIsDrawn() {
3097
+ if (!this.hasDrawnDraft()) this.pulse.stop();
3098
+ }
3099
+ applyPulse(wave) {
3100
+ for (const [key, state] of this.drafts) {
3101
+ const geometry = drawnFamilyOf(state);
3102
+ if (!geometry) continue;
3103
+ const halo = `${PEER_DRAFT_PREFIX}-${key}-halo`;
3104
+ if (!this.map.getLayer(halo)) continue;
3105
+ if (geometry === "point") {
3106
+ this.map.setPaintProperty(halo, "circle-radius", ringHaloRadius(wave));
3107
+ this.map.setPaintProperty(halo, "circle-opacity", ringHaloOpacity(wave));
3108
+ continue;
3109
+ }
3110
+ this.map.setPaintProperty(halo, "line-opacity", haloLineOpacity(wave));
3111
+ }
3112
+ }
3113
+ };
3114
+ var PointPickEngine = class {
3115
+ lock;
3116
+ detachClick;
3117
+ constructor(emitChange, seam, lock) {
3118
+ this.lock = lock;
3119
+ this.lock.acquire("point-pick");
3120
+ this.detachClick = seam.onMapClick((lngLat) => {
3121
+ require_listeners.notifyListeners([emitChange], { lngLat });
3122
+ });
3123
+ }
3124
+ dispose() {
3125
+ this.detachClick();
3126
+ this.lock.release("point-pick");
3127
+ }
3128
+ };
3129
+ const ROAD_ACCESS_LIVE_SOURCE = "itinerary-road-access-source";
3130
+ const ROAD_ACCESS_LIVE_STRIPE_LAYER = "itinerary-road-access-stripe";
3131
+ const ROAD_ACCESS_LIVE_ICON_LAYER = "itinerary-road-access-icon";
3132
+ var RoadAccessLineEngine = class {
3133
+ map;
3134
+ placement;
3135
+ icons;
3136
+ lastFeatures = null;
3137
+ constructor(map, placement, icons) {
3138
+ this.map = map;
3139
+ this.placement = placement;
3140
+ this.icons = icons;
3141
+ }
3142
+ apply(features) {
3143
+ if (features.length === 0) {
3144
+ this.clear();
3145
+ return;
3146
+ }
3147
+ this.lastFeatures = features;
3148
+ const data = {
3149
+ features: [...features],
3150
+ type: "FeatureCollection"
3151
+ };
3152
+ const existing = this.map.getSource(ROAD_ACCESS_LIVE_SOURCE);
3153
+ if (isGeoJsonSource(existing)) {
3154
+ existing.setData(data);
3155
+ return;
3156
+ }
3157
+ loadRoadAccessIcons(this.map, this.icons);
3158
+ this.map.addSource(ROAD_ACCESS_LIVE_SOURCE, {
3159
+ data,
3160
+ type: "geojson"
3161
+ });
3162
+ this.placement.addLayerOrdered(require_roadAccessLine.roadAccessStripeSpec({
3163
+ id: ROAD_ACCESS_LIVE_STRIPE_LAYER,
3164
+ source: ROAD_ACCESS_LIVE_SOURCE
3165
+ }), 100);
3166
+ this.placement.addLayerOrdered(require_roadAccessLine.roadAccessIconSpec({
3167
+ id: ROAD_ACCESS_LIVE_ICON_LAYER,
3168
+ source: ROAD_ACCESS_LIVE_SOURCE
3169
+ }), 100);
3170
+ }
3171
+ clear() {
3172
+ for (const layerId of [ROAD_ACCESS_LIVE_STRIPE_LAYER, ROAD_ACCESS_LIVE_ICON_LAYER]) this.placement.forgetLayerRank(layerId);
3173
+ if (this.map.getSource(ROAD_ACCESS_LIVE_SOURCE)) this.map.removeSource(ROAD_ACCESS_LIVE_SOURCE);
3174
+ this.lastFeatures = null;
3175
+ }
3176
+ replay() {
3177
+ const features = this.lastFeatures;
3178
+ if (features === null) return;
3179
+ this.lastFeatures = null;
3180
+ this.apply(features);
3181
+ }
3182
+ forgetFeatures() {
3183
+ this.lastFeatures = null;
3184
+ }
3185
+ };
3186
+ const EDITOR_HIGHLIGHT_SOURCE = "search-highlight";
3187
+ var SearchHighlightLayer = class {
3188
+ map;
3189
+ placement;
3190
+ events;
3191
+ icons;
3192
+ lastPayload = null;
3193
+ constructor(map, placement, events, icons) {
3194
+ this.map = map;
3195
+ this.placement = placement;
3196
+ this.events = events;
3197
+ this.icons = icons;
3198
+ refuseUndrawableProvider("SearchHighlightLayer", icons);
3199
+ }
3200
+ set(payload) {
3201
+ this.lastPayload = payload;
3202
+ this.events.afterStyleLoad(() => {
3203
+ this.teardown();
3204
+ if (!payload) return;
3205
+ this.draw(payload);
3206
+ });
3207
+ }
3208
+ replay() {
3209
+ this.set(this.lastPayload);
3210
+ }
3211
+ dispose() {
3212
+ this.teardown();
3213
+ }
3214
+ teardown() {
3215
+ for (const role of require_searchHighlight.SEARCH_HIGHLIGHT_ROLES) this.placement.forgetLayerRank(`${EDITOR_HIGHLIGHT_SOURCE}-${role}`);
3216
+ if (this.map.getSource(EDITOR_HIGHLIGHT_SOURCE)) this.map.removeSource(EDITOR_HIGHLIGHT_SOURCE);
3217
+ }
3218
+ accent() {
3219
+ return require_accentColor.accentHexAt(this.map.getContainer());
3220
+ }
3221
+ draw(payload) {
3222
+ const { data, layers, rank, sourceId, sprite } = require_searchHighlight.searchHighlightLayers(payload, {
3223
+ accent: this.accent(),
3224
+ hasPointGlyph: hasMarkerIconPath(require_searchHighlight.searchHighlightStyle.placeGlyph, this.icons),
3225
+ sourceId: EDITOR_HIGHLIGHT_SOURCE
3226
+ });
3227
+ if (sprite !== null) loadPoiIcon(this.map, sprite.glyph, sprite.color, this.icons);
3228
+ this.map.addSource(sourceId, {
3229
+ data,
3230
+ type: "geojson"
3231
+ });
3232
+ for (const layer of layers) this.placement.addLayerOrdered(layer, rank);
3233
+ }
3234
+ };
3235
+ const SV_CORRIDOR_SOURCE = "sv-corridor";
3236
+ const SV_CORRIDOR_LAYER = "sv-corridor-layer";
3237
+ const GOOGLE_BLUE_HUE = 217;
3238
+ const TERRAIN_PREWARM_MIN_PAD_DEG = .02;
3239
+ const poiCategory = (properties) => {
3240
+ const subclass = properties.subclass;
3241
+ if (typeof subclass === "string" && subclass.length > 0) return subclass;
3242
+ const klass = properties.class;
3243
+ return typeof klass === "string" ? klass : "";
3244
+ };
3245
+ const featureToPoi = (feature) => {
3246
+ const properties = feature.properties ?? {};
3247
+ const category = poiCategory(properties);
3248
+ const rawName = properties.name;
3249
+ const name = typeof rawName === "string" && rawName.length > 0 ? rawName : null;
3250
+ if (name === null && category === "") return null;
3251
+ return {
3252
+ category,
3253
+ id: feature.id === void 0 ? null : String(feature.id),
3254
+ name
3255
+ };
3256
+ };
3257
+ const featureToHit = (feature) => {
3258
+ const properties = {};
3259
+ for (const [key, value] of Object.entries(feature.properties ?? {})) if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") properties[key] = value;
3260
+ return feature.sourceLayer === void 0 ? {
3261
+ id: feature.id ?? null,
3262
+ properties
3263
+ } : {
3264
+ id: feature.id ?? null,
3265
+ properties,
3266
+ sourceLayer: feature.sourceLayer
3267
+ };
3268
+ };
3269
+ const overlayInternalKeys = /* @__PURE__ */ new Set(["id", "_symbol"]);
3270
+ const featureToOverlayFeature = (feature) => {
3271
+ const properties = feature.properties ?? {};
3272
+ const cleaned = {};
3273
+ for (const [key, value] of Object.entries(properties)) {
3274
+ if (overlayInternalKeys.has(key) || value === null || value === void 0) continue;
3275
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") cleaned[key] = value;
3276
+ }
3277
+ return Object.keys(cleaned).length === 0 ? null : cleaned;
3278
+ };
3279
+ const zoneEpochProperty = (properties, key) => {
3280
+ const value = properties[key];
3281
+ return typeof value === "number" ? value : null;
3282
+ };
3283
+ const featureToContextMenuZone = (feature) => {
3284
+ const properties = feature.properties ?? {};
3285
+ const rawId = properties.id;
3286
+ if (typeof rawId !== "string" || rawId.length === 0) return null;
3287
+ const description = typeof properties.description === "string" ? properties.description : "";
3288
+ const level = typeof properties.level === "string" ? properties.level : "";
3289
+ const name = typeof properties.name === "string" ? properties.name : "";
3290
+ const organizationId = typeof properties.organization_id === "string" ? properties.organization_id : null;
3291
+ return {
3292
+ description,
3293
+ endAt: zoneEpochProperty(properties, "end_at"),
3294
+ id: rawId,
3295
+ level,
3296
+ name,
3297
+ organizationId,
3298
+ startAt: zoneEpochProperty(properties, "start_at")
3299
+ };
3300
+ };
3301
+ const coordsEqual = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
3302
+ const segmentSeedsEqual = (a, b) => {
3303
+ const aVias = a.seedVias ?? [];
3304
+ const bVias = b.seedVias ?? [];
3305
+ if (aVias.length !== bVias.length) return false;
3306
+ for (const [index, via] of aVias.entries()) {
3307
+ const other = bVias[index];
3308
+ if (other === void 0 || !coordsEqual(via, other)) return false;
3309
+ }
3310
+ return pinsEqual(a.pinnedStart ?? null, b.pinnedStart ?? null) && pinsEqual(a.pinnedEnd ?? null, b.pinnedEnd ?? null);
3311
+ };
3312
+ const pinsEqual = (a, b) => a === null || b === null ? a === null && b === null : coordsEqual(a, b);
3313
+ const editEngineRecords = /* @__PURE__ */ new WeakMap();
3314
+ const bindEditEngines = (holder, factories) => {
3315
+ editEngineRecords.set(holder, factories);
3316
+ };
3317
+ var MapLibreViewClient = class {
3318
+ mountayaMap;
3319
+ map;
3320
+ events;
3321
+ mapEvents;
3322
+ cursor;
3323
+ overlay;
3324
+ placement;
3325
+ lastConstraints = null;
3326
+ segmentEditEngine = null;
3327
+ segmentEditEngineSegmentId = null;
3328
+ segmentEditEngineMode = null;
3329
+ segmentEditEngineSeed = null;
3330
+ waypointEditEngine = null;
3331
+ waypointEditEngineWaypointId = null;
3332
+ waypointEditEngineMode = null;
3333
+ segmentDraftSubscribers = /* @__PURE__ */ new Set();
3334
+ segmentViaPromptSubscribers = /* @__PURE__ */ new Set();
3335
+ waypointDraftChangeSubscribers = /* @__PURE__ */ new Set();
3336
+ pointPickEngine = null;
3337
+ pointPickChangeSubscribers = /* @__PURE__ */ new Set();
3338
+ zoneEditEngine = null;
3339
+ zoneEditEngineZoneId = null;
3340
+ zoneEditEngineMode = null;
3341
+ zoneEditEngineColor = null;
3342
+ zoneDraftSubscribers = /* @__PURE__ */ new Set();
3343
+ boundaryEditEngine = null;
3344
+ boundaryEditEngineFeatureId = null;
3345
+ boundaryDraftSubscribers = /* @__PURE__ */ new Set();
3346
+ lock;
3347
+ heldBaseTerrain = null;
3348
+ enginesAwaitingReplay = /* @__PURE__ */ new Set();
3349
+ profileMarker = null;
3350
+ profileMarkerIconKey = null;
3351
+ miniBearingMarker = null;
3352
+ miniBearingPlacement = 0;
3353
+ searchHighlight;
3354
+ peerDraft;
3355
+ itineraryPreview;
3356
+ flowAnimator;
3357
+ editDirectionArrows;
3358
+ editArrowLine = null;
3359
+ editArrowFrame = null;
3360
+ editArrowsDrawn = false;
3361
+ editArrowHeld = null;
3362
+ editArrowAwaitingStyle = false;
3363
+ editRoadAccess;
3364
+ editRoadAccessRoute = null;
3365
+ editRoadAccessHeld = null;
3366
+ video;
3367
+ icons;
3368
+ waypointCursor;
3369
+ initialViewHash;
3370
+ settleFrames = /* @__PURE__ */ new Set();
3371
+ hoverSubscriptions = /* @__PURE__ */ new Set();
3372
+ hoverLayerIds = [];
3373
+ detachHoverListeners = null;
3374
+ hoverPoint = null;
3375
+ hoverFrame = null;
3376
+ hoverRestingPoint = null;
3377
+ hoverTeardownFrame = null;
3378
+ hoverPointer = false;
3379
+ refusedSources = /* @__PURE__ */ new Set();
3380
+ tilesAccessRestoredSubscribers = /* @__PURE__ */ new Set();
3381
+ pointerLeaveDetachers = /* @__PURE__ */ new Set();
3382
+ slotWriteWaits = /* @__PURE__ */ new Set();
3383
+ constructor(mountayaMap, options = {}) {
3384
+ this.mountayaMap = mountayaMap;
3385
+ refuseUndrawableProvider(this.editEngines() === null ? "MapLibreViewClient" : "MapLibreClient", mountayaMap.icons);
3386
+ this.initialViewHash = options.initialViewHash ?? false;
3387
+ this.video = options.video;
3388
+ this.icons = mountayaMap.icons;
3389
+ this.waypointCursor = {
3390
+ provider: mountayaMap.icons,
3391
+ size: 48
3392
+ };
3393
+ const map = mountayaMap.raw;
3394
+ this.map = map;
3395
+ this.mapEvents = require_slotNames.mapEventEngineOf(mountayaMap);
3396
+ this.events = new MapEventScopeEngine(map, this.mapEvents);
3397
+ this.trackTilesAccess();
3398
+ this.redrawEditsAsContextReturns();
3399
+ this.cursor = new require_cursor.CursorEngine(map, this.events);
3400
+ this.lock = new MapLockGuard();
3401
+ this.placement = {
3402
+ addLayerOrdered: (spec, rank) => this.overlay.addLayerOrdered(spec, rank),
3403
+ forgetLayerRank: (layerId) => this.overlay.forgetLayerRank(layerId)
3404
+ };
3405
+ this.itineraryPreview = new ItineraryPreviewLayer(map, this.placement);
3406
+ this.searchHighlight = new SearchHighlightLayer(map, this.placement, this.events, this.icons);
3407
+ this.peerDraft = new PeerDraftLayer(map, this.placement, this.events);
3408
+ this.flowAnimator = new DirectionFlowAnimator(map);
3409
+ this.editDirectionArrows = new DirectionArrowLayer(map, this.placement);
3410
+ this.editRoadAccess = new RoadAccessLineEngine(map, this.placement, this.icons);
3411
+ this.overlay = new OverlayRenderer(mountayaMap, this.events);
3412
+ }
3413
+ beginSegmentEdit(options) {
3414
+ if (this.events.disposed) return;
3415
+ this.requireEditEngines("beginSegmentEdit").refuseSegment(options);
3416
+ if (this.segmentEditEngine && this.segmentEditEngineSegmentId === options.featureId && this.segmentEditEngineMode === options.mode && this.segmentEditEngineSeed !== null && segmentSeedsEqual(this.segmentEditEngineSeed, options)) return;
3417
+ if (this.segmentEditEngine) this.teardownSegmentEdit();
3418
+ const segmentEngine = this.armEditEngine("segment", () => this.buildSegmentEngine(options));
3419
+ this.segmentEditEngine = segmentEngine;
3420
+ this.replayIfStyleReloading(segmentEngine);
3421
+ this.segmentEditEngineSegmentId = options.featureId;
3422
+ this.segmentEditEngineMode = options.mode;
3423
+ this.segmentEditEngineSeed = {
3424
+ pinnedEnd: options.pinnedEnd ?? null,
3425
+ pinnedStart: options.pinnedStart ?? null,
3426
+ seedVias: options.seedVias ?? []
3427
+ };
3428
+ this.overlay.setEditedSegment(options.featureId);
3429
+ }
3430
+ beginWaypointEdit(options) {
3431
+ if (this.events.disposed) return;
3432
+ this.requireEditEngines("beginWaypointEdit").refuseWaypoint(options);
3433
+ if (this.waypointEditEngine && this.waypointEditEngineWaypointId === options.waypointId && this.waypointEditEngineMode === options.mode) return;
3434
+ if (this.waypointEditEngine) this.teardownWaypointEdit();
3435
+ const waypointEngine = this.armEditEngine("waypoint", () => this.buildWaypointEngine(options));
3436
+ this.waypointEditEngine = waypointEngine;
3437
+ this.replayIfStyleReloading(waypointEngine);
3438
+ this.waypointEditEngineWaypointId = options.waypointId;
3439
+ this.waypointEditEngineMode = options.mode;
3440
+ this.overlay.setEditedWaypoint(options.waypointId);
3441
+ }
3442
+ endWaypointEdit() {
3443
+ this.teardownWaypointEdit();
3444
+ this.applyHeldBaseTerrain();
3445
+ }
3446
+ teardownWaypointEdit() {
3447
+ this.waypointEditEngine?.dispose();
3448
+ this.waypointEditEngine = null;
3449
+ this.waypointEditEngineWaypointId = null;
3450
+ this.waypointEditEngineMode = null;
3451
+ this.overlay.setEditedWaypoint(null);
3452
+ this.lock.release("waypoint");
3453
+ }
3454
+ beginPointPick(_options) {
3455
+ if (this.events.disposed) return;
3456
+ if (this.pointPickEngine) this.teardownPointPick();
3457
+ this.pointPickEngine = new PointPickEngine((change) => this.emitPointPickChange(change), { onMapClick: (cb) => this.takeMapClicks(cb) }, this.lock);
3458
+ }
3459
+ endPointPick() {
3460
+ this.teardownPointPick();
3461
+ this.applyHeldBaseTerrain();
3462
+ }
3463
+ teardownPointPick() {
3464
+ this.pointPickEngine?.dispose();
3465
+ this.pointPickEngine = null;
3466
+ }
3467
+ beginZoneEdit(options) {
3468
+ if (this.events.disposed) return;
3469
+ this.requireEditEngines("beginZoneEdit").refuseZone(options);
3470
+ if (this.zoneEditEngine && this.zoneEditEngineZoneId === options.featureId && this.zoneEditEngineMode === options.mode) {
3471
+ this.restyleZoneEdit(this.zoneEditEngine, options.color);
3472
+ return;
3473
+ }
3474
+ if (this.zoneEditEngine && this.zoneEditEngineMode === options.mode && this.zoneEditEngineZoneId !== options.featureId && require_geometry.geometriesEqual(options.seedGeometry ?? null, this.zoneEditEngine.readDraft())) {
3475
+ this.zoneEditEngineZoneId = options.featureId;
3476
+ this.restyleZoneEdit(this.zoneEditEngine, options.color);
3477
+ this.overlay.setEditedZone(options.featureId);
3478
+ return;
3479
+ }
3480
+ if (this.zoneEditEngine) this.teardownZoneEdit();
3481
+ const zoneEngine = this.armEditEngine("zone", () => this.buildZoneEngine(options));
3482
+ this.zoneEditEngine = zoneEngine;
3483
+ this.replayIfStyleReloading(zoneEngine);
3484
+ this.zoneEditEngineZoneId = options.featureId;
3485
+ this.zoneEditEngineMode = options.mode;
3486
+ this.zoneEditEngineColor = options.color;
3487
+ this.overlay.setEditedZone(options.featureId);
3488
+ }
3489
+ endZoneEdit() {
3490
+ this.teardownZoneEdit();
3491
+ this.applyHeldBaseTerrain();
3492
+ }
3493
+ teardownZoneEdit() {
3494
+ this.zoneEditEngine?.dispose();
3495
+ this.zoneEditEngine = null;
3496
+ this.zoneEditEngineZoneId = null;
3497
+ this.zoneEditEngineMode = null;
3498
+ this.zoneEditEngineColor = null;
3499
+ this.overlay.setEditedZone(null);
3500
+ this.lock.release("zone");
3501
+ }
3502
+ isZoneEditing(zoneId) {
3503
+ if (this.zoneEditEngine === null) return false;
3504
+ if (zoneId === void 0) return true;
3505
+ return this.zoneEditEngineZoneId === zoneId;
3506
+ }
3507
+ setZoneDraftStyle(style) {
3508
+ if (this.zoneEditEngine) this.restyleZoneEdit(this.zoneEditEngine, style.color);
3509
+ }
3510
+ restyleZoneEdit(engine, color) {
3511
+ if (this.zoneEditEngineColor === color) return;
3512
+ engine.setDraftStyle({ color });
3513
+ this.zoneEditEngineColor = color;
3514
+ }
3515
+ getZoneDraft() {
3516
+ const geometry = this.zoneEditEngine?.readDraft();
3517
+ if (!geometry || this.zoneEditEngineMode === null) return null;
3518
+ return {
3519
+ geometry,
3520
+ mode: this.zoneEditEngineMode,
3521
+ phase: "settled",
3522
+ programmatic: true
3523
+ };
3524
+ }
3525
+ applyZoneDraft(geometry) {
3526
+ this.zoneEditEngine?.applyDraft(geometry);
3527
+ }
3528
+ onZoneDraftChange(cb) {
3529
+ this.zoneDraftSubscribers.add(cb);
3530
+ return () => {
3531
+ this.zoneDraftSubscribers.delete(cb);
3532
+ };
3533
+ }
3534
+ beginBoundaryEdit(options) {
3535
+ if (this.events.disposed) return;
3536
+ this.requireEditEngines("beginBoundaryEdit").refuseBoundary(options);
3537
+ if (this.boundaryEditEngine && this.boundaryEditEngineFeatureId === options.featureId) return;
3538
+ if (this.boundaryEditEngine) this.teardownBoundaryEdit();
3539
+ const boundaryEngine = this.armEditEngine("boundary", () => this.buildBoundaryEngine(options));
3540
+ this.boundaryEditEngine = boundaryEngine;
3541
+ this.replayIfStyleReloading(boundaryEngine);
3542
+ this.boundaryEditEngineFeatureId = options.featureId;
3543
+ }
3544
+ endBoundaryEdit() {
3545
+ this.teardownBoundaryEdit();
3546
+ this.applyHeldBaseTerrain();
3547
+ }
3548
+ teardownBoundaryEdit() {
3549
+ this.boundaryEditEngine?.dispose();
3550
+ this.boundaryEditEngine = null;
3551
+ this.boundaryEditEngineFeatureId = null;
3552
+ this.lock.release("boundary");
3553
+ }
3554
+ isBoundaryEditing() {
3555
+ return this.boundaryEditEngine !== null;
3556
+ }
3557
+ applyBoundaryDraft(bbox) {
3558
+ this.boundaryEditEngine?.applyDraft(bbox);
3559
+ }
3560
+ clearBoundaryDraft() {
3561
+ this.boundaryEditEngine?.clearDraft();
3562
+ }
3563
+ getBoundaryDraft() {
3564
+ return this.boundaryEditEngine?.readDraft() ?? null;
3565
+ }
3566
+ onBoundaryDraftChange(cb) {
3567
+ this.boundaryDraftSubscribers.add(cb);
3568
+ return () => {
3569
+ this.boundaryDraftSubscribers.delete(cb);
3570
+ };
3571
+ }
3572
+ setZoneTimeReference(epochSeconds) {
3573
+ this.overlay.setZoneTimeReference(epochSeconds);
3574
+ }
3575
+ isSegmentEditing(segmentId) {
3576
+ if (this.segmentEditEngine === null) return false;
3577
+ if (segmentId === void 0) return true;
3578
+ return this.segmentEditEngineSegmentId === segmentId;
3579
+ }
3580
+ isWaypointEditing(waypointId) {
3581
+ if (this.waypointEditEngine === null) return false;
3582
+ if (waypointId === void 0) return true;
3583
+ return this.waypointEditEngineWaypointId === waypointId;
3584
+ }
3585
+ ensureOverlayInZoomRange(overlay) {
3586
+ this.overlay.ensureOverlayInZoomRange(overlay);
3587
+ }
3588
+ applyWaypointDraft(snapshot) {
3589
+ this.waypointEditEngine?.applyDraft(snapshot);
3590
+ }
3591
+ clearWaypointDraft() {
3592
+ this.waypointEditEngine?.clearDraft();
3593
+ }
3594
+ reseedWaypointEdit(lngLat) {
3595
+ const current = this.waypointEditEngine?.readDraft();
3596
+ if (!current) return;
3597
+ this.waypointEditEngine?.applyDraft({
3598
+ ...current,
3599
+ lngLat
3600
+ });
3601
+ }
3602
+ setWaypointDraftStyle(style) {
3603
+ this.waypointEditEngine?.setDraftStyle(style);
3604
+ }
3605
+ getWaypointDraft() {
3606
+ return this.waypointEditEngine?.readDraft() ?? null;
3607
+ }
3608
+ setSearchHighlight(payload) {
3609
+ this.searchHighlight.set(payload);
3610
+ }
3611
+ setPeerDraft(entity, geometry, color, label) {
3612
+ this.peerDraft.set(entity, geometry, color, label);
3613
+ }
3614
+ clearPeerDraft(entity) {
3615
+ this.peerDraft.clear(entity);
3616
+ }
3617
+ setProfileMarker(lngLat, icon = null) {
3618
+ if (this.events.disposed) return;
3619
+ if (!lngLat) {
3620
+ this.profileMarker?.remove();
3621
+ this.profileMarker = null;
3622
+ this.profileMarkerIconKey = null;
3623
+ return;
3624
+ }
3625
+ const center = new maplibre_gl.LngLat(lngLat[0], lngLat[1]);
3626
+ const key = profileMarkerIconKey(icon);
3627
+ if (this.profileMarker) {
3628
+ if (key === this.profileMarkerIconKey) {
3629
+ this.profileMarker.setLngLat(center);
3630
+ return;
3631
+ }
3632
+ this.profileMarker.remove();
3633
+ this.profileMarker = null;
3634
+ }
3635
+ const element = buildProfileMarkerElement(icon, this.icons);
3636
+ this.profileMarkerIconKey = key;
3637
+ this.profileMarker = new maplibre_gl.Marker({
3638
+ anchor: "bottom",
3639
+ element
3640
+ }).setLngLat(center).addTo(this.map);
3641
+ }
3642
+ setVideoFocusMarker(lngLat) {
3643
+ this.video?.setVideoFocusMarker(lngLat);
3644
+ }
3645
+ setSegmentDraftStyle(style) {
3646
+ this.segmentEditEngine?.setDraftStyle(style);
3647
+ }
3648
+ getSegmentDraft() {
3649
+ return this.segmentEditEngine?.readDraft() ?? null;
3650
+ }
3651
+ applySegmentDraft(vias) {
3652
+ this.segmentEditEngine?.applyDraft(vias);
3653
+ }
3654
+ setSegmentViaPromptPending(pending) {
3655
+ this.segmentEditEngine?.setViaPromptPending(pending);
3656
+ }
3657
+ onSegmentDraftChange(cb) {
3658
+ this.segmentDraftSubscribers.add(cb);
3659
+ return () => {
3660
+ this.segmentDraftSubscribers.delete(cb);
3661
+ };
3662
+ }
3663
+ onSegmentViaPrompt(cb) {
3664
+ this.segmentViaPromptSubscribers.add(cb);
3665
+ return () => {
3666
+ this.segmentViaPromptSubscribers.delete(cb);
3667
+ };
3668
+ }
3669
+ onWaypointDraftChange(cb) {
3670
+ this.waypointDraftChangeSubscribers.add(cb);
3671
+ return () => {
3672
+ this.waypointDraftChangeSubscribers.delete(cb);
3673
+ };
3674
+ }
3675
+ onPointPickChange(cb) {
3676
+ this.pointPickChangeSubscribers.add(cb);
3677
+ return () => {
3678
+ this.pointPickChangeSubscribers.delete(cb);
3679
+ };
3680
+ }
3681
+ endSegmentEdit() {
3682
+ this.teardownSegmentEdit();
3683
+ this.applyHeldBaseTerrain();
3684
+ }
3685
+ teardownSegmentEdit() {
3686
+ this.segmentEditEngine?.dispose();
3687
+ this.segmentEditEngine = null;
3688
+ this.segmentEditEngineSegmentId = null;
3689
+ this.segmentEditEngineMode = null;
3690
+ this.segmentEditEngineSeed = null;
3691
+ this.overlay.reapplyItineraryPaint();
3692
+ this.overlay.setEditedSegment(null);
3693
+ this.clearSegmentEditArrows();
3694
+ this.clearSegmentEditRoadAccess();
3695
+ this.lock.release("segment");
3696
+ }
3697
+ setTileLayerVisibility(layerId, visible) {
3698
+ this.overlay.setTileLayerVisibility(layerId, visible);
3699
+ }
3700
+ addTileSources(sources) {
3701
+ this.overlay.addTileSources(sources);
3702
+ }
3703
+ setCategoryOverlay(overlay) {
3704
+ this.overlay.setCategoryOverlay(overlay);
3705
+ }
3706
+ addEnrichmentOverlay(overlay) {
3707
+ this.overlay.addEnrichmentOverlay(overlay);
3708
+ }
3709
+ removeEnrichmentOverlay(slug) {
3710
+ this.overlay.removeEnrichmentOverlay(slug);
3711
+ }
3712
+ removeTileSources(ids) {
3713
+ this.overlay.removeTileSources(ids);
3714
+ }
3715
+ refreshItineraryTiles(bustToken) {
3716
+ this.overlay.refreshItineraryTiles(bustToken);
3717
+ }
3718
+ refreshItineraryTilesWhenSettled(bustToken) {
3719
+ let scheduled = false;
3720
+ let detachIdle = () => {};
3721
+ const onFrame = (callback) => {
3722
+ const handle = requestAnimationFrame(() => {
3723
+ this.settleFrames.delete(handle);
3724
+ callback();
3725
+ });
3726
+ this.settleFrames.add(handle);
3727
+ };
3728
+ const scheduleBust = () => {
3729
+ if (scheduled) return;
3730
+ scheduled = true;
3731
+ detachIdle();
3732
+ onFrame(() => this.overlay.refreshItineraryTiles(bustToken));
3733
+ };
3734
+ detachIdle = this.events.on("idle", scheduleBust);
3735
+ onFrame(() => onFrame(scheduleBust));
3736
+ }
3737
+ refreshZoneTiles() {
3738
+ this.overlay.refreshZoneTiles();
3739
+ }
3740
+ applyCamera(view) {
3741
+ const options = {};
3742
+ if (view.center !== void 0) options.center = view.center;
3743
+ if (view.zoom !== void 0) options.zoom = view.zoom;
3744
+ if (view.bearing !== void 0) options.bearing = view.bearing;
3745
+ if (view.pitch !== void 0) options.pitch = view.pitch;
3746
+ if (Object.keys(options).length === 0) return;
3747
+ if (options.center !== void 0) {
3748
+ this.map.jumpTo(options);
3749
+ return;
3750
+ }
3751
+ this.map.easeTo(options);
3752
+ }
3753
+ fitBounds(bounds, padding, maxZoom, animate) {
3754
+ const camera = this.fitCamera(bounds, padding, maxZoom, this.map.getMinZoom());
3755
+ if (camera !== null) this.map.flyTo(animate === false ? {
3756
+ ...camera,
3757
+ animate
3758
+ } : camera);
3759
+ }
3760
+ cameraForBounds(bounds, padding, maxZoom) {
3761
+ const camera = this.fitCamera(bounds, padding, maxZoom, -2);
3762
+ return camera === null ? null : {
3763
+ center: camera.center,
3764
+ zoom: camera.zoom
3765
+ };
3766
+ }
3767
+ fitCamera(bounds, padding, maxZoom, floor) {
3768
+ if (!require_camera.normalizeBoundingBox(bounds).every((edge) => Number.isFinite(edge))) return null;
3769
+ const [west, south, east, north] = bounds;
3770
+ return require_slotNames.fitCameraOn(this.map, require_camera.normalizeBoundingBox([
3771
+ west,
3772
+ south,
3773
+ west > east ? east + 360 : east,
3774
+ north
3775
+ ]), {
3776
+ maxZoom,
3777
+ padding,
3778
+ window: {
3779
+ max: this.map.getMaxZoom(),
3780
+ min: floor
3781
+ }
3782
+ });
3783
+ }
3784
+ hadInitialViewHash() {
3785
+ return this.initialViewHash;
3786
+ }
3787
+ async prewarmTerrain(bounds) {
3788
+ const [west, south, east, north] = require_camera.normalizeBoundingBox(bounds);
3789
+ const padLng = Math.max(east - west, TERRAIN_PREWARM_MIN_PAD_DEG);
3790
+ const padLat = Math.max(north - south, TERRAIN_PREWARM_MIN_PAD_DEG);
3791
+ const padded = require_camera.normalizeBoundingBox([
3792
+ west - padLng,
3793
+ south - padLat,
3794
+ east + padLng,
3795
+ north + padLat
3796
+ ]);
3797
+ if (bounds.every((edge) => Number.isFinite(edge))) this.map.fitBounds(padded);
3798
+ await this.waitForRender();
3799
+ }
3800
+ async warmPoses(poses, signal) {
3801
+ return warmPosesThrough(this.map, this.events, poses, signal);
3802
+ }
3803
+ sampleTerrainElevation(lngLat) {
3804
+ return queryTerrainElevation(this.map, lngLat);
3805
+ }
3806
+ getViewport() {
3807
+ const center = this.map.getCenter();
3808
+ return {
3809
+ center: [center.lng, center.lat],
3810
+ zoom: this.map.getZoom()
3811
+ };
3812
+ }
3813
+ getBearing() {
3814
+ return this.map.getBearing();
3815
+ }
3816
+ getCameraPose() {
3817
+ const center = this.map.getCenter();
3818
+ return {
3819
+ bearing: this.map.getBearing(),
3820
+ center: [center.lng, center.lat],
3821
+ pitch: this.map.getPitch(),
3822
+ zoom: this.map.getZoom()
3823
+ };
3824
+ }
3825
+ async previewPoses(poses, options) {
3826
+ if (!this.video) return;
3827
+ return this.video.previewPoses(poses, options);
3828
+ }
3829
+ async recordPoses(poses, output, options) {
3830
+ if (!this.video) return {
3831
+ blob: null,
3832
+ cancelled: true,
3833
+ extension: require_presets.containerExtension(output.format),
3834
+ reason: "unavailable"
3835
+ };
3836
+ return this.video.recordPoses(poses, output, options);
3837
+ }
3838
+ zoomIn() {
3839
+ this.map.zoomIn();
3840
+ }
3841
+ zoomOut() {
3842
+ this.map.zoomOut();
3843
+ }
3844
+ resetNorth() {
3845
+ this.map.resetNorthPitch();
3846
+ }
3847
+ async tryGeolocate() {
3848
+ const fix = await this.mountayaMap.geolocation.locate();
3849
+ if (!fix.ok) return {
3850
+ ok: false,
3851
+ reason: fix.reason
3852
+ };
3853
+ if (this.events.disposed) return {
3854
+ ok: false,
3855
+ reason: "unavailable"
3856
+ };
3857
+ this.fitBounds(require_camera.accuracyBounds(fix.position, fix.accuracyMeters), void 0, 16);
3858
+ return { ok: true };
3859
+ }
3860
+ setMiniBearingMarker(position, headingDeg) {
3861
+ if (this.events.disposed) return;
3862
+ const center = new maplibre_gl.LngLat(position[0], position[1]);
3863
+ this.miniBearingPlacement += 1;
3864
+ const placement = this.miniBearingPlacement;
3865
+ if (this.miniBearingMarker) {
3866
+ this.miniBearingMarker.setLngLat(center);
3867
+ this.rotateMiniBearingMarker(this.miniBearingMarker.getElement(), headingDeg);
3868
+ return;
3869
+ }
3870
+ const place = () => {
3871
+ if (this.miniBearingMarker) {
3872
+ this.miniBearingMarker.setLngLat(center);
3873
+ this.rotateMiniBearingMarker(this.miniBearingMarker.getElement(), headingDeg);
3874
+ return;
3875
+ }
3876
+ const element = buildMiniBearingMarkerElement();
3877
+ this.miniBearingMarker = new maplibre_gl.Marker({
3878
+ anchor: "center",
3879
+ element
3880
+ }).setLngLat(center).addTo(this.map);
3881
+ this.rotateMiniBearingMarker(element, headingDeg);
3882
+ };
3883
+ if (this.map.loaded() && this.map.isStyleLoaded()) {
3884
+ place();
3885
+ return;
3886
+ }
3887
+ this.waitForRender().then(() => {
3888
+ if (!this.events.disposed && placement === this.miniBearingPlacement) place();
3889
+ });
3890
+ }
3891
+ clearMiniBearingMarker() {
3892
+ this.miniBearingPlacement += 1;
3893
+ this.miniBearingMarker?.remove();
3894
+ this.miniBearingMarker = null;
3895
+ }
3896
+ setMiniCenter(position) {
3897
+ this.map.jumpTo({ center: position });
3898
+ }
3899
+ rotateMiniBearingMarker(root, headingDeg) {
3900
+ const rotator = root.querySelector(`[${MINI_BEARING_ROTATOR_DATA}]`);
3901
+ if (rotator) rotator.style.transform = `rotate(${headingDeg}deg)`;
3902
+ }
3903
+ applyCursor(cursor) {
3904
+ this.cursor.apply(cursor);
3905
+ }
3906
+ lockCursor(cursor) {
3907
+ this.cursor.lock(cursor);
3908
+ }
3909
+ unlockCursor() {
3910
+ this.cursor.unlock();
3911
+ }
3912
+ waitForRender() {
3913
+ const writes = this.overlay.whenSlotWritesLand();
3914
+ if (writes === null || this.events.disposed) return this.events.whenSettled();
3915
+ return new Promise((resolve) => {
3916
+ const end = () => {
3917
+ this.slotWriteWaits.delete(end);
3918
+ resolve();
3919
+ };
3920
+ this.slotWriteWaits.add(end);
3921
+ writes.then(end);
3922
+ }).then(() => this.events.whenSettled());
3923
+ }
3924
+ waitForCategoryOverlay(slug, options = {}) {
3925
+ return this.overlay.whenCategoryOverlayMounted(slug, options.signal);
3926
+ }
3927
+ unproject(point) {
3928
+ return this.map.unproject(point).toArray();
3929
+ }
3930
+ project(lngLat) {
3931
+ const projected = this.map.project(lngLat);
3932
+ return [projected.x, projected.y];
3933
+ }
3934
+ onShownCopy([lng, lat]) {
3935
+ return [lng + 360 * Math.round((this.map.getCenter().lng - lng) / 360), lat];
3936
+ }
3937
+ projectOnShownCopy(lngLat) {
3938
+ return this.map.project(this.onShownCopy(lngLat));
3939
+ }
3940
+ queryOverlayFeaturesAt(lngLat) {
3941
+ const overlayQueryLayerIds = this.overlay.getOverlayQueryLayerIds();
3942
+ if (overlayQueryLayerIds.length === 0) return [];
3943
+ const point = this.projectOnShownCopy(lngLat);
3944
+ const features = this.map.queryRenderedFeatures(point, { layers: overlayQueryLayerIds });
3945
+ const overlayFeatures = [];
3946
+ const seen = /* @__PURE__ */ new Set();
3947
+ for (const feature of features) {
3948
+ const overlayFeature = featureToOverlayFeature(feature);
3949
+ if (!overlayFeature) continue;
3950
+ const key = JSON.stringify(overlayFeature);
3951
+ if (seen.has(key)) continue;
3952
+ seen.add(key);
3953
+ overlayFeatures.push(overlayFeature);
3954
+ }
3955
+ return overlayFeatures;
3956
+ }
3957
+ sampleOverlayAt(lngLat) {
3958
+ const sample = sampleTerrainAt(this.map, this.onShownCopy(lngLat));
3959
+ if (!sample) return null;
3960
+ const readout = {
3961
+ elevation: Math.round(sample.elevation),
3962
+ slope: Math.round(sample.slope)
3963
+ };
3964
+ if (sample.aspect !== null) readout.aspect = Math.round(sample.aspect) % 360;
3965
+ return readout;
3966
+ }
3967
+ queryPoisAt(lngLat) {
3968
+ const layers = this.map.getLayersOrder().filter((layerId) => require_order.poiSourceLayers.has(this.map.getLayer(layerId)?.sourceLayer ?? ""));
3969
+ if (layers.length === 0) return [];
3970
+ const point = this.projectOnShownCopy(lngLat);
3971
+ const features = this.map.queryRenderedFeatures(point, { layers });
3972
+ const pois = [];
3973
+ const seen = /* @__PURE__ */ new Set();
3974
+ for (const feature of features) {
3975
+ const poi = featureToPoi(feature);
3976
+ if (!poi) continue;
3977
+ const key = `${poi.name ?? ""}${poi.category}`;
3978
+ if (seen.has(key)) continue;
3979
+ seen.add(key);
3980
+ pois.push(poi);
3981
+ }
3982
+ return pois;
3983
+ }
3984
+ zoneAtPoint(lngLat) {
3985
+ const zoneLayerIds = this.overlay.getZoneQueryLayerIds();
3986
+ if (zoneLayerIds.length === 0) return null;
3987
+ const point = this.projectOnShownCopy(lngLat);
3988
+ const features = this.map.queryRenderedFeatures(point, { layers: zoneLayerIds });
3989
+ for (const feature of features) {
3990
+ const zone = featureToContextMenuZone(feature);
3991
+ if (zone) return zone;
3992
+ }
3993
+ return null;
3994
+ }
3995
+ onFeatureClick(layerIds, cb, options) {
3996
+ if (layerIds.length === 0) return () => {};
3997
+ let subscribed = true;
3998
+ const handler = (event) => {
3999
+ const layers = layerIds.filter((layerId) => this.map.getLayer(layerId) !== void 0);
4000
+ if (layers.length === 0) return;
4001
+ const accepts = options?.accepts;
4002
+ const hit = this.map.queryRenderedFeatures(event.point, { layers }).map(featureToHit).find((candidate) => accepts === void 0 || accepts(candidate));
4003
+ if (hit === void 0) return;
4004
+ const clicks = event.originalEvent?.detail;
4005
+ const clicked = typeof clicks === "number" && clicks > 0 ? {
4006
+ ...hit,
4007
+ clickCount: clicks
4008
+ } : hit;
4009
+ queueMicrotask(() => {
4010
+ if (subscribed && !this.events.disposed && !event.defaultPrevented) cb(clicked);
4011
+ });
4012
+ };
4013
+ const detach = this.events.on("click", handler);
4014
+ return () => {
4015
+ subscribed = false;
4016
+ detach();
4017
+ };
4018
+ }
4019
+ onFeatureHover(layerIds, handlers, options) {
4020
+ if (layerIds.length === 0 || this.events.disposed) return () => {};
4021
+ const subscription = {
4022
+ accepts: options?.accepts,
4023
+ handlers,
4024
+ inside: false,
4025
+ layerIds: new Set(layerIds)
4026
+ };
4027
+ this.hoverSubscriptions.add(subscription);
4028
+ this.refreshHoverLayerIds();
4029
+ this.cancelHoverTeardown();
4030
+ this.attachHoverListeners();
4031
+ if (this.hoverRestingPoint !== null) {
4032
+ this.hoverPoint = this.hoverRestingPoint;
4033
+ this.requestHoverFrame();
4034
+ }
4035
+ return () => {
4036
+ if (!this.hoverSubscriptions.delete(subscription)) return;
4037
+ this.refreshHoverLayerIds();
4038
+ if (this.hoverSubscriptions.size === 0) {
4039
+ this.cancelHoverFrame();
4040
+ this.scheduleHoverTeardown();
4041
+ }
4042
+ };
4043
+ }
4044
+ scheduleHoverTeardown() {
4045
+ if (this.hoverTeardownFrame !== null) return;
4046
+ this.hoverTeardownFrame = requestAnimationFrame(() => {
4047
+ this.hoverTeardownFrame = null;
4048
+ if (this.hoverPointer) {
4049
+ this.applyCursor("");
4050
+ this.hoverPointer = false;
4051
+ }
4052
+ this.cancelHoverFrame();
4053
+ this.detachHoverListeners?.();
4054
+ this.detachHoverListeners = null;
4055
+ this.hoverRestingPoint = null;
4056
+ });
4057
+ }
4058
+ cancelHoverTeardown() {
4059
+ if (this.hoverTeardownFrame !== null) {
4060
+ cancelAnimationFrame(this.hoverTeardownFrame);
4061
+ this.hoverTeardownFrame = null;
4062
+ }
4063
+ }
4064
+ requestHoverFrame() {
4065
+ if (this.hoverFrame === null) this.hoverFrame = requestAnimationFrame(() => {
4066
+ this.hoverFrame = null;
4067
+ this.hitTestHover();
4068
+ });
4069
+ }
4070
+ attachHoverListeners() {
4071
+ if (this.detachHoverListeners !== null) return;
4072
+ const detachMove = this.events.on("mousemove", (event) => {
4073
+ this.hoverPoint = event.point;
4074
+ this.hoverRestingPoint = event.point;
4075
+ this.requestHoverFrame();
4076
+ });
4077
+ const detachOut = this.events.on("mouseout", () => {
4078
+ this.cancelHoverFrame();
4079
+ this.hoverRestingPoint = null;
4080
+ this.reportHover([]);
4081
+ });
4082
+ this.detachHoverListeners = () => {
4083
+ detachMove();
4084
+ detachOut();
4085
+ };
4086
+ }
4087
+ refreshHoverLayerIds() {
4088
+ const union = /* @__PURE__ */ new Set();
4089
+ for (const subscription of this.hoverSubscriptions) for (const layerId of subscription.layerIds) union.add(layerId);
4090
+ this.hoverLayerIds = [...union];
4091
+ }
4092
+ cancelHoverFrame() {
4093
+ if (this.hoverFrame !== null) {
4094
+ cancelAnimationFrame(this.hoverFrame);
4095
+ this.hoverFrame = null;
4096
+ }
4097
+ this.hoverPoint = null;
4098
+ }
4099
+ hitTestHover() {
4100
+ const point = this.hoverPoint;
4101
+ this.hoverPoint = null;
4102
+ if (point === null || this.hoverSubscriptions.size === 0) return;
4103
+ const layers = this.hoverLayerIds.filter((layerId) => this.map.getLayer(layerId) !== void 0);
4104
+ this.reportHover(layers.length === 0 ? [] : this.map.queryRenderedFeatures(point, { layers }));
4105
+ }
4106
+ reportHover(features) {
4107
+ const hits = [...this.hoverSubscriptions].map((subscription) => {
4108
+ const { accepts } = subscription;
4109
+ for (const candidate of features) {
4110
+ if (!subscription.layerIds.has(candidate.layer.id)) continue;
4111
+ const hit = featureToHit(candidate);
4112
+ if (accepts === void 0 || accepts(hit)) return {
4113
+ hit,
4114
+ subscription
4115
+ };
4116
+ }
4117
+ return {
4118
+ hit: void 0,
4119
+ subscription
4120
+ };
4121
+ });
4122
+ if (hits.some(({ hit }) => hit !== void 0)) {
4123
+ this.applyCursor("pointer");
4124
+ this.hoverPointer = true;
4125
+ } else if (this.hoverPointer) {
4126
+ this.applyCursor("");
4127
+ this.hoverPointer = false;
4128
+ }
4129
+ for (const { hit, subscription } of hits) if (hit === void 0 && subscription.inside) {
4130
+ subscription.inside = false;
4131
+ if (this.hoverSubscriptions.has(subscription)) require_listeners.notifyListeners([() => subscription.handlers.onLeave()]);
4132
+ }
4133
+ for (const { hit, subscription } of hits) if (hit !== void 0 && this.hoverSubscriptions.has(subscription)) {
4134
+ subscription.inside = true;
4135
+ require_listeners.notifyListeners([() => subscription.handlers.onEnter(hit)]);
4136
+ }
4137
+ }
4138
+ onContextMenu(cb) {
4139
+ let subscribed = true;
4140
+ const handler = (event) => {
4141
+ queueMicrotask(() => {
4142
+ if (!subscribed || this.events.disposed || event.defaultPrevented) return;
4143
+ cb({
4144
+ lngLat: [require_longitude.wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat],
4145
+ point: [event.point.x, event.point.y]
4146
+ });
4147
+ });
4148
+ };
4149
+ const detach = this.events.on("contextmenu", handler);
4150
+ return () => {
4151
+ subscribed = false;
4152
+ detach();
4153
+ };
4154
+ }
4155
+ onMapClick(cb) {
4156
+ const handler = (event) => {
4157
+ require_listeners.notifyListeners([cb], [require_longitude.wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat]);
4158
+ };
4159
+ return this.events.on("click", handler);
4160
+ }
4161
+ takeMapClicks(cb) {
4162
+ return this.events.on("click", (event) => {
4163
+ event.preventDefault();
4164
+ require_listeners.notifyListeners([cb], [require_longitude.wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat]);
4165
+ });
4166
+ }
4167
+ onPointerMove(cb) {
4168
+ const handler = (event) => {
4169
+ require_listeners.notifyListeners([cb], {
4170
+ lngLat: [require_longitude.wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat],
4171
+ point: [event.point.x, event.point.y]
4172
+ });
4173
+ };
4174
+ return this.events.on("mousemove", handler);
4175
+ }
4176
+ onPointerLeave(cb) {
4177
+ if (this.events.disposed) return () => {};
4178
+ const canvas = this.map.getCanvas();
4179
+ canvas.addEventListener("pointerleave", cb);
4180
+ const detach = () => {
4181
+ canvas.removeEventListener("pointerleave", cb);
4182
+ this.pointerLeaveDetachers.delete(detach);
4183
+ };
4184
+ this.pointerLeaveDetachers.add(detach);
4185
+ return detach;
4186
+ }
4187
+ onViewportChange(cb) {
4188
+ const handler = () => {
4189
+ const center = this.map.getCenter();
4190
+ require_listeners.notifyListeners([cb], {
4191
+ bearing: this.map.getBearing(),
4192
+ center: [center.lng, center.lat],
4193
+ zoom: this.map.getZoom()
4194
+ });
4195
+ };
4196
+ return this.events.on("move", handler);
4197
+ }
4198
+ onViewportSettle(cb) {
4199
+ const handler = () => {
4200
+ const center = this.map.getCenter();
4201
+ require_listeners.notifyListeners([cb], {
4202
+ bearing: this.map.getBearing(),
4203
+ center: [center.lng, center.lat],
4204
+ zoom: this.map.getZoom()
4205
+ });
4206
+ };
4207
+ return this.events.on("moveend", handler);
4208
+ }
4209
+ onResize(cb) {
4210
+ return this.events.on("resize", () => require_listeners.notifyListeners([cb]));
4211
+ }
4212
+ onTilesAccessRequired(cb) {
4213
+ const handler = (event) => {
4214
+ if (require_slotNames.accessRefusalStatus(event.error) !== null && !require_slotNames.isToldToNobody(event.error)) require_listeners.notifyListeners([cb]);
4215
+ };
4216
+ return this.events.on("error", handler);
4217
+ }
4218
+ onTilesAccessRestored(cb) {
4219
+ this.tilesAccessRestoredSubscribers.add(cb);
4220
+ return () => {
4221
+ this.tilesAccessRestoredSubscribers.delete(cb);
4222
+ };
4223
+ }
4224
+ isTilesAccessRequired() {
4225
+ return this.refusedSources.size > 0;
4226
+ }
4227
+ trackTilesAccess() {
4228
+ this.events.on("error", (event) => {
4229
+ if (require_slotNames.accessRefusalStatus(event.error) !== null && !require_slotNames.isToldToNobody(event.error)) this.answerTilesAccess({
4230
+ kind: "refused",
4231
+ source: require_slotNames.accessRefusalSource(event)
4232
+ });
4233
+ });
4234
+ this.events.on("sourcedata", (event) => {
4235
+ if (event.tile !== void 0) this.answerTilesAccess({
4236
+ kind: "tile",
4237
+ source: event.sourceId
4238
+ });
4239
+ });
4240
+ this.events.on("style.load", () => this.answerTilesAccess({ kind: "style" }));
4241
+ }
4242
+ redrawEditsAsContextReturns() {
4243
+ this.events.on("webglcontextrestored", () => {
4244
+ const armed = [
4245
+ this.segmentEditEngine,
4246
+ this.waypointEditEngine,
4247
+ this.zoneEditEngine,
4248
+ this.boundaryEditEngine
4249
+ ].filter((engine) => engine !== null && !this.enginesAwaitingReplay.has(engine));
4250
+ this.events.afterStyleLoad(() => {
4251
+ for (const engine of armed) if (this.isLiveEditEngine(engine) && !this.enginesAwaitingReplay.has(engine)) {
4252
+ engine.detachBeforeStyleReload();
4253
+ engine.replayAfterStyleReload();
4254
+ }
4255
+ });
4256
+ });
4257
+ }
4258
+ answerTilesAccess(answer) {
4259
+ const { restored, standing } = require_slotNames.accessStandingAfter(this.refusedSources, answer, (id) => this.map.getSource(id) !== void 0);
4260
+ this.refusedSources = standing;
4261
+ if (restored) require_listeners.notifyListeners([...this.tilesAccessRestoredSubscribers].map((cb) => () => {
4262
+ if (this.tilesAccessRestoredSubscribers.has(cb)) cb();
4263
+ }));
4264
+ }
4265
+ setConstraints(constraints) {
4266
+ if (constraints.maxBounds != null) this.toMaxBounds(constraints.maxBounds);
4267
+ const next = {
4268
+ ...this.lastConstraints,
4269
+ ...constraints
4270
+ };
4271
+ this.refuseZoomWindow(constraints, next);
4272
+ const previous = this.lastConstraints;
4273
+ this.lastConstraints = next;
4274
+ try {
4275
+ this.applyConstraints(constraints);
4276
+ } catch (cause) {
4277
+ this.lastConstraints = previous;
4278
+ throw new require_errors.MountayaElementsError(`MapClient.setConstraints: the renderer refused minZoom ${String(constraints.minZoom)} and maxZoom ${String(constraints.maxZoom)}. Pass zooms inside the range the map draws.`, { cause });
4279
+ }
4280
+ }
4281
+ refuseZoomWindow(stated, window) {
4282
+ for (const limit of ["minZoom", "maxZoom"]) {
4283
+ const zoom = stated[limit];
4284
+ if (zoom !== void 0 && zoom !== null && !Number.isFinite(zoom)) throw new require_errors.MountayaElementsError(`MapClient.setConstraints: ${limit} is ${String(zoom)}. Pass a finite zoom, null to release the limit, or leave it out to keep the one in force.`);
4285
+ }
4286
+ if (stated.minZoom === void 0 && stated.maxZoom === void 0) return;
4287
+ const minZoom = window.minZoom === null ? -2 : window.minZoom ?? this.map.getMinZoom();
4288
+ const maxZoom = window.maxZoom === null ? 22 : window.maxZoom ?? this.map.getMaxZoom();
4289
+ if (minZoom > maxZoom) {
4290
+ const named = stated.minZoom !== void 0 ? "minZoom" : "maxZoom";
4291
+ throw new require_errors.MountayaElementsError(`MapClient.setConstraints: ${named} is ${String(stated[named])}, which leaves a zoom window from ${String(minZoom)} to ${String(maxZoom)} that holds no zoom. Pass a minZoom at or below the maxZoom, stating both when the window moves.`);
4292
+ }
4293
+ }
4294
+ setBaseTerrain(config) {
4295
+ if (this.events.disposed) return;
4296
+ if (this.lock.isLocked()) {
4297
+ this.heldBaseTerrain = config;
4298
+ return;
4299
+ }
4300
+ this.heldBaseTerrain = null;
4301
+ this.segmentEditEngine?.detachBeforeStyleReload();
4302
+ this.waypointEditEngine?.detachBeforeStyleReload();
4303
+ this.zoneEditEngine?.detachBeforeStyleReload();
4304
+ this.boundaryEditEngine?.detachBeforeStyleReload();
4305
+ const demUrl = config.demUrl;
4306
+ this.mountayaMap.setStyle(config.styleUrl, { transformStyle: (_previous, next) => bakeTerrain(next, demUrl) }).catch((cause) => {
4307
+ this.map.fire("error", { error: require_errors.errorFrom(cause, "The base-map switch failed. Check what the style request rejects with.") });
4308
+ });
4309
+ this.events.afterStyleLoad(() => {
4310
+ prebakeMarkerIcons(this.map, this.icons);
4311
+ });
4312
+ this.peerDraft.replay();
4313
+ if (this.lastConstraints) this.applyConstraints(this.lastConstraints);
4314
+ this.queueReplaysAfterStyleLoad();
4315
+ }
4316
+ queueReplaysAfterStyleLoad() {
4317
+ if (this.segmentEditEngine) this.queueEngineReplay(this.segmentEditEngine);
4318
+ if (this.waypointEditEngine) this.queueEngineReplay(this.waypointEditEngine);
4319
+ if (this.zoneEditEngine) this.queueEngineReplay(this.zoneEditEngine);
4320
+ if (this.boundaryEditEngine) this.queueEngineReplay(this.boundaryEditEngine);
4321
+ this.events.afterStyleLoad(() => {
4322
+ this.itineraryPreview.replay();
4323
+ });
4324
+ this.events.afterStyleLoad(() => {
4325
+ this.searchHighlight.replay();
4326
+ });
4327
+ this.events.afterStyleLoad(() => {
4328
+ this.editDirectionArrows.replay();
4329
+ if (this.segmentEditEngine) this.flowAnimator.register(this.editDirectionArrows.flowLayerId());
4330
+ this.editRoadAccess.replay();
4331
+ });
4332
+ }
4333
+ applyHeldBaseTerrain() {
4334
+ if (this.heldBaseTerrain !== null) this.setBaseTerrain(this.heldBaseTerrain);
4335
+ }
4336
+ armEditEngine(holder, build) {
4337
+ this.lock.acquire(holder);
4338
+ try {
4339
+ return build();
4340
+ } catch (cause) {
4341
+ this.lock.release(holder);
4342
+ this.applyHeldBaseTerrain();
4343
+ throw cause;
4344
+ }
4345
+ }
4346
+ replayIfStyleReloading(engine) {
4347
+ if (!this.events.isStyleReloading()) return;
4348
+ engine.detachBeforeStyleReload();
4349
+ this.queueEngineReplay(engine);
4350
+ }
4351
+ queueEngineReplay(engine) {
4352
+ if (this.enginesAwaitingReplay.has(engine)) return;
4353
+ this.enginesAwaitingReplay.add(engine);
4354
+ this.events.afterStyleLoad(() => {
4355
+ this.enginesAwaitingReplay.delete(engine);
4356
+ if (this.isLiveEditEngine(engine)) engine.replayAfterStyleReload();
4357
+ });
4358
+ }
4359
+ isLiveEditEngine(engine) {
4360
+ return engine === this.segmentEditEngine || engine === this.waypointEditEngine || engine === this.zoneEditEngine || engine === this.boundaryEditEngine;
4361
+ }
4362
+ jumpToPose(pose) {
4363
+ this.map.jumpTo(pose);
4364
+ }
4365
+ setViewport(viewport) {
4366
+ this.map.jumpTo({
4367
+ center: viewport.center,
4368
+ zoom: viewport.zoom
4369
+ });
4370
+ }
4371
+ setSourceTiles(sourceId, tiles) {
4372
+ this.overlay.setSourceTiles(sourceId, tiles);
4373
+ }
4374
+ setStreetviewCoverage(visible) {
4375
+ this.mountayaMap.setStreetviewCoverage(visible, visible ? { "raster-hue-rotate": this.themeHueRotation() } : {});
4376
+ }
4377
+ setStreetviewCorridor(lines, radiusMeters) {
4378
+ if (!(!lines || lines.length === 0) && !(Number.isFinite(radiusMeters) && radiusMeters > 0)) throw new require_errors.MountayaElementsError(`MapClient.setStreetviewCorridor: radiusMeters is ${String(radiusMeters)}. The band is drawn that many meters of ground on each side of the route: pass a finite number above 0, or null lines to clear the band.`);
4379
+ this.events.afterStyleLoad(() => {
4380
+ if (!lines || lines.length === 0) {
4381
+ this.overlay.forgetLayerRank(SV_CORRIDOR_LAYER);
4382
+ if (this.map.getSource(SV_CORRIDOR_SOURCE)) this.map.removeSource(SV_CORRIDOR_SOURCE);
4383
+ return;
4384
+ }
4385
+ const data = {
4386
+ features: lines.map((coordinates) => ({
4387
+ geometry: {
4388
+ coordinates,
4389
+ type: "LineString"
4390
+ },
4391
+ properties: {},
4392
+ type: "Feature"
4393
+ })),
4394
+ type: "FeatureCollection"
4395
+ };
4396
+ const source = this.map.getSource(SV_CORRIDOR_SOURCE);
4397
+ if (isGeoJsonSource(source)) source.setData(data);
4398
+ else this.map.addSource(SV_CORRIDOR_SOURCE, {
4399
+ data,
4400
+ type: "geojson"
4401
+ });
4402
+ let latitudeSum = 0;
4403
+ let coordinateCount = 0;
4404
+ for (const line of lines) for (const coordinate of line) {
4405
+ latitudeSum += coordinate[1];
4406
+ coordinateCount += 1;
4407
+ }
4408
+ const centerLatitude = coordinateCount > 0 ? latitudeSum / coordinateCount : 0;
4409
+ const widthPxAtZ0 = 2 * radiusMeters / require_webMercator.groundMetersPerPixel(0, centerLatitude);
4410
+ const widthByZoom = [
4411
+ "interpolate",
4412
+ ["exponential", 2],
4413
+ ["zoom"],
4414
+ 0,
4415
+ widthPxAtZ0,
4416
+ 24,
4417
+ widthPxAtZ0 * 2 ** 24
4418
+ ];
4419
+ if (this.map.getLayer(SV_CORRIDOR_LAYER)) {
4420
+ this.map.setPaintProperty(SV_CORRIDOR_LAYER, "line-width", widthByZoom);
4421
+ return;
4422
+ }
4423
+ this.overlay.addLayerOrdered({
4424
+ id: SV_CORRIDOR_LAYER,
4425
+ layout: {
4426
+ "line-cap": "round",
4427
+ "line-join": "round"
4428
+ },
4429
+ paint: {
4430
+ "line-blur": 2,
4431
+ "line-color": require_accent.DEFAULT_ACCENT,
4432
+ "line-opacity": .2,
4433
+ "line-width": widthByZoom
4434
+ },
4435
+ source: SV_CORRIDOR_SOURCE,
4436
+ type: "line"
4437
+ }, 70);
4438
+ });
4439
+ }
4440
+ setHillshadeIllumination(direction) {
4441
+ this.overlay.setHillshadeIllumination(direction);
4442
+ }
4443
+ prewarmItineraryIcons(icons) {
4444
+ this.overlay.prewarmItineraryIcons(icons);
4445
+ }
4446
+ setItineraryEmphasis(target) {
4447
+ this.overlay.setItineraryEmphasis(target);
4448
+ }
4449
+ setItineraryExclusions(exclusions) {
4450
+ this.overlay.setItineraryExclusions(exclusions);
4451
+ }
4452
+ setItinerarySegmentColor(color) {
4453
+ this.overlay.setItinerarySegmentColor(color);
4454
+ }
4455
+ setAccessRestrictionsVisibility(visible) {
4456
+ this.overlay.setAccessRestrictionsVisibility(visible);
4457
+ }
4458
+ setItineraryPreview(preview) {
4459
+ this.events.afterStyleLoad(() => {
4460
+ if (!preview) {
4461
+ this.itineraryPreview.clear();
4462
+ return;
4463
+ }
4464
+ this.itineraryPreview.apply(preview);
4465
+ });
4466
+ }
4467
+ setActiveItinerarySegments(lines) {
4468
+ this.overlay.setActiveItinerarySegments(lines);
4469
+ }
4470
+ getActiveItinerarySegments() {
4471
+ return this.overlay.getActiveItinerarySegments();
4472
+ }
4473
+ setMapLanguage(language) {
4474
+ this.mountayaMap.setLanguage(language);
4475
+ }
4476
+ setOverlayQueryLayers(layerIds) {
4477
+ this.overlay.setOverlayQueryLayers(layerIds);
4478
+ }
4479
+ editEngines() {
4480
+ for (let holder = this; holder !== null; holder = Object.getPrototypeOf(holder)) {
4481
+ const record = editEngineRecords.get(holder);
4482
+ if (record !== void 0) return record;
4483
+ }
4484
+ return null;
4485
+ }
4486
+ requireEditEngines(method) {
4487
+ const engines = this.editEngines();
4488
+ if (engines === null) throw new require_errors.MountayaElementsError(`MapLibreViewClient.${method}: this client holds no edit engine, so it cannot start an edit. Construct MapLibreClient from "@mountaya/elements/editor" to edit on the map.`);
4489
+ return engines;
4490
+ }
4491
+ editEngineSeams() {
4492
+ return {
4493
+ cursor: this.cursor,
4494
+ events: this.events,
4495
+ map: this.map,
4496
+ placement: this.placement
4497
+ };
4498
+ }
4499
+ buildSegmentEngine(options) {
4500
+ const engines = this.requireEditEngines("beginSegmentEdit");
4501
+ const emitDraft = (draft) => {
4502
+ this.updateSegmentEditArrows(draft);
4503
+ this.updateSegmentEditRoadAccess(draft);
4504
+ this.emitSegmentDraft(draft);
4505
+ };
4506
+ const emitViaPrompt = (prompt) => this.emitSegmentViaPrompt(prompt);
4507
+ return engines.segment(this.editEngineSeams(), options, emitDraft, emitViaPrompt);
4508
+ }
4509
+ updateSegmentEditArrows(draft) {
4510
+ const coordinates = lineFromSegmentDraft(draft);
4511
+ if (coordinates.length < 2) {
4512
+ this.clearSegmentEditArrows();
4513
+ return;
4514
+ }
4515
+ this.flowAnimator.register(this.editDirectionArrows.flowLayerId());
4516
+ if (!this.editArrowsDrawn) {
4517
+ this.editArrowsDrawn = true;
4518
+ this.paintSegmentEditArrows(coordinates);
4519
+ return;
4520
+ }
4521
+ this.editArrowLine = coordinates;
4522
+ if (this.editArrowFrame === null) this.editArrowFrame = requestAnimationFrame(() => {
4523
+ this.editArrowFrame = null;
4524
+ const line = this.editArrowLine;
4525
+ this.editArrowLine = null;
4526
+ if (line !== null) this.paintSegmentEditArrows(line);
4527
+ });
4528
+ }
4529
+ paintSegmentEditArrows(line) {
4530
+ this.editArrowHeld = line;
4531
+ if (this.editArrowAwaitingStyle) return;
4532
+ this.editArrowAwaitingStyle = true;
4533
+ this.events.afterStyleLoad(this.drawHeldSegmentEditArrows);
4534
+ }
4535
+ drawHeldSegmentEditArrows = () => {
4536
+ this.editArrowAwaitingStyle = false;
4537
+ const held = this.editArrowHeld;
4538
+ this.editArrowHeld = null;
4539
+ if (held !== null) this.editDirectionArrows.apply(held);
4540
+ };
4541
+ clearSegmentEditArrows(events = this.events) {
4542
+ if (this.editArrowFrame !== null) {
4543
+ cancelAnimationFrame(this.editArrowFrame);
4544
+ this.editArrowFrame = null;
4545
+ }
4546
+ this.editArrowLine = null;
4547
+ this.editArrowHeld = null;
4548
+ this.editArrowsDrawn = false;
4549
+ this.editDirectionArrows.forgetLine();
4550
+ this.flowAnimator.unregister(this.editDirectionArrows.flowLayerId());
4551
+ events.afterStyleLoad(() => {
4552
+ if (!this.editArrowsDrawn) this.editDirectionArrows.clear();
4553
+ });
4554
+ }
4555
+ updateSegmentEditRoadAccess(draft) {
4556
+ const route = draft.route ?? null;
4557
+ if (route === this.editRoadAccessRoute) return;
4558
+ this.editRoadAccessRoute = route;
4559
+ this.editRoadAccessHeld = require_roadAccess.roadAccessFeatures(route?.geometry, route?.roadAccessInfo);
4560
+ this.events.afterStyleLoad(() => {
4561
+ const held = this.editRoadAccessHeld;
4562
+ this.editRoadAccessHeld = null;
4563
+ if (held !== null) this.editRoadAccess.apply(held);
4564
+ });
4565
+ }
4566
+ clearSegmentEditRoadAccess(events = this.events) {
4567
+ this.editRoadAccessRoute = null;
4568
+ this.editRoadAccessHeld = null;
4569
+ this.editRoadAccess.forgetFeatures();
4570
+ events.afterStyleLoad(() => {
4571
+ if (this.editRoadAccessRoute === null) this.editRoadAccess.clear();
4572
+ });
4573
+ }
4574
+ buildWaypointEngine(options) {
4575
+ return this.requireEditEngines("beginWaypointEdit").waypoint({
4576
+ ...this.editEngineSeams(),
4577
+ cursorOptions: this.waypointCursor,
4578
+ pick: {
4579
+ onMapClick: (cb) => this.onMapClick(cb),
4580
+ onPointerMove: (cb) => this.onPointerMove(cb),
4581
+ queryPoisAt: (lngLat) => this.queryPoisAt(lngLat)
4582
+ },
4583
+ snapSegments: () => this.getActiveItinerarySegments()
4584
+ }, options, (change) => this.emitWaypointDraftChange(change));
4585
+ }
4586
+ emitSegmentDraft(draft) {
4587
+ require_listeners.notifyListeners(this.segmentDraftSubscribers, draft);
4588
+ }
4589
+ emitSegmentViaPrompt(prompt) {
4590
+ require_listeners.notifyListeners(this.segmentViaPromptSubscribers, prompt);
4591
+ }
4592
+ buildZoneEngine(options) {
4593
+ return this.requireEditEngines("beginZoneEdit").zone(this.editEngineSeams(), options, (draft) => this.emitZoneDraft(draft));
4594
+ }
4595
+ emitZoneDraft(draft) {
4596
+ require_listeners.notifyListeners(this.zoneDraftSubscribers, draft);
4597
+ }
4598
+ buildBoundaryEngine(options) {
4599
+ return this.requireEditEngines("beginBoundaryEdit").boundary(this.editEngineSeams(), options, (draft) => this.emitBoundaryDraft(draft));
4600
+ }
4601
+ emitBoundaryDraft(draft) {
4602
+ require_listeners.notifyListeners(this.boundaryDraftSubscribers, draft);
4603
+ }
4604
+ emitWaypointDraftChange(change) {
4605
+ require_listeners.notifyListeners(this.waypointDraftChangeSubscribers, change);
4606
+ }
4607
+ emitPointPickChange(change) {
4608
+ require_listeners.notifyListeners(this.pointPickChangeSubscribers, change);
4609
+ }
4610
+ applyConstraints(constraints) {
4611
+ const minZoom = constraints.minZoom === null ? -2 : constraints.minZoom;
4612
+ const maxZoom = constraints.maxZoom === null ? 22 : constraints.maxZoom;
4613
+ if (minZoom !== void 0 || maxZoom !== void 0) this.mountayaMap.setConstraints({ zoom: {
4614
+ ...maxZoom === void 0 ? {} : { max: maxZoom },
4615
+ ...minZoom === void 0 ? {} : { min: minZoom }
4616
+ } });
4617
+ if (constraints.maxBounds !== void 0) this.map.setMaxBounds(constraints.maxBounds === null ? null : this.toMaxBounds(constraints.maxBounds));
4618
+ }
4619
+ toMaxBounds(bounds) {
4620
+ return require_slotNames.readBoxLock(bounds);
4621
+ }
4622
+ themeHueRotation() {
4623
+ const hex = require_accentColor.accentHexAt(this.map.getContainer()).replace("#", "");
4624
+ const r = Number.parseInt(hex.substring(0, 2), 16) / 255;
4625
+ const g = Number.parseInt(hex.substring(2, 4), 16) / 255;
4626
+ const b = Number.parseInt(hex.substring(4, 6), 16) / 255;
4627
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) return 0;
4628
+ const max = Math.max(r, g, b);
4629
+ const delta = max - Math.min(r, g, b);
4630
+ if (delta === 0) return 0;
4631
+ let hue = 0;
4632
+ if (max === r) hue = (g - b) / delta % 6;
4633
+ else if (max === g) hue = (b - r) / delta + 2;
4634
+ else hue = (r - g) / delta + 4;
4635
+ hue = Math.round(hue * 60);
4636
+ if (hue < 0) hue += 360;
4637
+ return hue - GOOGLE_BLUE_HUE;
4638
+ }
4639
+ released = false;
4640
+ dispose() {
4641
+ if (this.released) return;
4642
+ this.released = true;
4643
+ const release = (step) => {
4644
+ try {
4645
+ step();
4646
+ } catch (fault) {
4647
+ require_listeners.surfaceFault(fault);
4648
+ }
4649
+ };
4650
+ release(() => this.video?.dispose());
4651
+ if (this.segmentEditEngine) release(() => this.overlay.setEditedSegment(null));
4652
+ if (this.waypointEditEngine) release(() => this.overlay.setEditedWaypoint(null));
4653
+ if (this.zoneEditEngine) release(() => this.overlay.setEditedZone(null));
4654
+ release(() => this.segmentEditEngine?.dispose());
4655
+ this.segmentEditEngine = null;
4656
+ this.segmentEditEngineSegmentId = null;
4657
+ this.segmentEditEngineMode = null;
4658
+ this.segmentEditEngineSeed = null;
4659
+ release(() => this.waypointEditEngine?.dispose());
4660
+ this.waypointEditEngine = null;
4661
+ this.waypointEditEngineWaypointId = null;
4662
+ this.waypointEditEngineMode = null;
4663
+ release(() => this.zoneEditEngine?.dispose());
4664
+ this.zoneEditEngine = null;
4665
+ this.zoneEditEngineZoneId = null;
4666
+ this.zoneEditEngineMode = null;
4667
+ release(() => this.boundaryEditEngine?.dispose());
4668
+ this.boundaryEditEngine = null;
4669
+ this.boundaryEditEngineFeatureId = null;
4670
+ release(() => this.pointPickEngine?.dispose());
4671
+ this.pointPickEngine = null;
4672
+ release(() => this.itineraryPreview.clear());
4673
+ release(() => this.clearSegmentEditArrows(this.mapEvents));
4674
+ release(() => this.clearSegmentEditRoadAccess(this.mapEvents));
4675
+ release(() => {
4676
+ this.overlay.forgetLayerRank(SV_CORRIDOR_LAYER);
4677
+ if (this.map.getSource(SV_CORRIDOR_SOURCE)) this.map.removeSource(SV_CORRIDOR_SOURCE);
4678
+ });
4679
+ for (const detach of [...this.pointerLeaveDetachers]) release(detach);
4680
+ release(() => this.events.dispose());
4681
+ for (const end of [...this.slotWriteWaits]) release(end);
4682
+ release(() => this.overlay.dispose());
4683
+ this.refusedSources = /* @__PURE__ */ new Set();
4684
+ this.tilesAccessRestoredSubscribers.clear();
4685
+ release(() => this.profileMarker?.remove());
4686
+ this.profileMarker = null;
4687
+ this.profileMarkerIconKey = null;
4688
+ release(() => this.searchHighlight.dispose());
4689
+ release(() => this.peerDraft.dispose());
4690
+ release(() => this.flowAnimator.dispose());
4691
+ for (const handle of this.settleFrames) cancelAnimationFrame(handle);
4692
+ this.settleFrames.clear();
4693
+ release(() => this.cancelHoverFrame());
4694
+ release(() => this.cancelHoverTeardown());
4695
+ this.hoverSubscriptions.clear();
4696
+ this.hoverLayerIds = [];
4697
+ this.detachHoverListeners = null;
4698
+ this.hoverPointer = false;
4699
+ this.hoverRestingPoint = null;
4700
+ release(() => this.miniBearingMarker?.remove());
4701
+ this.miniBearingMarker = null;
4702
+ }
4703
+ };
4704
+ Object.defineProperty(exports, "MapLibreViewClient", {
4705
+ enumerable: true,
4706
+ get: function() {
4707
+ return MapLibreViewClient;
4708
+ }
4709
+ });
4710
+ Object.defineProperty(exports, "PER_FRAME_IDLE_TIMEOUT_MS", {
4711
+ enumerable: true,
4712
+ get: function() {
4713
+ return PER_FRAME_IDLE_TIMEOUT_MS;
4714
+ }
4715
+ });
4716
+ Object.defineProperty(exports, "bindEditEngines", {
4717
+ enumerable: true,
4718
+ get: function() {
4719
+ return bindEditEngines;
4720
+ }
4721
+ });
4722
+ Object.defineProperty(exports, "blankStyle", {
4723
+ enumerable: true,
4724
+ get: function() {
4725
+ return blankStyle;
4726
+ }
4727
+ });
4728
+ Object.defineProperty(exports, "isGeoJsonSource", {
4729
+ enumerable: true,
4730
+ get: function() {
4731
+ return isGeoJsonSource;
4732
+ }
4733
+ });
4734
+ Object.defineProperty(exports, "warmPosesThrough", {
4735
+ enumerable: true,
4736
+ get: function() {
4737
+ return warmPosesThrough;
4738
+ }
4739
+ });
4740
+
4741
+ //# sourceMappingURL=chunk-CMG5OV0q.cjs.map