@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,3122 @@
1
+ "use strict";
2
+ const require_rolldown_runtime = require("./chunk-Bn6ZbxkS.cjs");
3
+ const require_errors = require("./chunk-o3IRANDf.cjs");
4
+ const require_adapt = require("./chunk-CbOtHnnB.cjs");
5
+ const require_camera = require("./chunk-D6KdIW5e.cjs");
6
+ const require_geometry = require("./chunk-BWMuCNc9.cjs");
7
+ const require_longitude = require("./chunk-RHZrxUrM.cjs");
8
+ const require_lucideMarkers_gen = require("./chunk-qwYDLeXc.cjs");
9
+ const require_paint = require("./chunk-twQItIRg.cjs");
10
+ const require_order = require("./chunk-xh3UkuVs.cjs");
11
+ const require_geoJson = require("./chunk-BwK6Hl3q.cjs");
12
+ const require_listeners = require("./chunk-BIEc_SkR.cjs");
13
+ const require_geolocation = require("./chunk-B-m1AchR.cjs");
14
+ const require_language = require("./chunk-CTd-qgJc.cjs");
15
+ const require_roadAccessColors = require("./chunk-CnLucxjG.cjs");
16
+ const require_language$1 = require("./chunk-BjJcqX5J.cjs");
17
+ const require_roadAccessLine = require("./chunk-lItIuOIS.cjs");
18
+ const require_slotNames = require("./chunk-9fp0lDic.cjs");
19
+ const require_inDevelopment = require("./chunk-BTPjDw_y.cjs");
20
+ const require_glyphNode = require("./chunk-De2FmNPu.cjs");
21
+ require("./chunk-DEfsb2lc.cjs");
22
+ let maplibre_gl = require("maplibre-gl");
23
+ maplibre_gl = require_rolldown_runtime.__toESM(maplibre_gl);
24
+ const CLIENT_HEADER_VALUE = `mountaya-typescript/0.2.0`;
25
+ const DEFAULT_ORIGINS = ["https://tiles.mountaya.com"];
26
+ const credentialPrefixes = {
27
+ publishableKey: "pk_",
28
+ sessionToken: "sess_",
29
+ shareToken: "share_"
30
+ };
31
+ const SECRET_KEY_PREFIX = "sk_";
32
+ const edgeWhitespacePattern = /^[\t\n\r ]+|[\t\n\r ]+$/g;
33
+ const printableAsciiPattern = /^[\x20-\x7e]*$/;
34
+ const headerValueRefusal = (member, value) => {
35
+ if (typeof value !== "string") return `is ${value === null ? "null" : `a value of type ${typeof value}`}, not a string`;
36
+ if (value.replace(edgeWhitespacePattern, "") === "") return value === "" ? "is an empty string" : "is whitespace alone";
37
+ if (!printableAsciiPattern.test(value)) return "holds a character no request header carries: a request header carries printable ASCII alone, so a line break, a tab or another control character, at either end too, or a character past ASCII such as a letter of Latin-1, is none";
38
+ if (member === "language") return;
39
+ if (member === "publishableKey" && value.startsWith(SECRET_KEY_PREFIX)) return "is a secret key, which must never reach a browser: anyone can read it out of the page. Pass the publishable key, and mint session tokens with the secret key on your server";
40
+ const prefix = credentialPrefixes[member];
41
+ return value.startsWith(prefix) ? void 0 : `must start with "${prefix}"`;
42
+ };
43
+ const assertMapCredential = (credential, path, context) => {
44
+ for (const member of [
45
+ "publishableKey",
46
+ "sessionToken",
47
+ "shareToken"
48
+ ]) {
49
+ const value = credential[member];
50
+ if (value === void 0 || member === "sessionToken" && typeof value === "function") continue;
51
+ const refusal = headerValueRefusal(member, value);
52
+ if (refusal !== void 0) throw new require_errors.MountayaElementsError(`${context}: ${path}${member} ${refusal}.`);
53
+ }
54
+ };
55
+ const PAGE_STAND_IN = "http://page.invalid";
56
+ const CLAIMED_PROTOCOLS = ["http:", "https:"];
57
+ const parsed = (url, base) => {
58
+ try {
59
+ return new URL(url, base);
60
+ } catch {
61
+ return;
62
+ }
63
+ };
64
+ const pageOf = () => {
65
+ if (typeof location === "undefined") return;
66
+ const address = parsed(location.href);
67
+ return {
68
+ base: ((typeof document === "undefined" ? void 0 : parsed(document.baseURI)) ?? address)?.href,
69
+ origin: address !== void 0 && CLAIMED_PROTOCOLS.includes(address.protocol) ? address.origin : null
70
+ };
71
+ };
72
+ const withoutTrailingSlash = (path) => path.replace(/\/+$/, "");
73
+ const isUnder = (path, base) => base === "" || path === base || path.startsWith(`${base}/`);
74
+ const placeOf = (url, page) => {
75
+ const absolute = parsed(url);
76
+ if (page !== void 0) {
77
+ const sent = page.base === void 0 ? absolute : parsed(url, page.base);
78
+ return sent !== void 0 && CLAIMED_PROTOCOLS.includes(sent.protocol) ? {
79
+ origin: sent.origin,
80
+ path: sent.pathname,
81
+ resolved: absolute?.href === sent.href ? void 0 : sent.href
82
+ } : void 0;
83
+ }
84
+ if (absolute !== void 0) return CLAIMED_PROTOCOLS.includes(absolute.protocol) ? {
85
+ origin: absolute.origin,
86
+ path: absolute.pathname,
87
+ resolved: void 0
88
+ } : void 0;
89
+ const relative = parsed(url, PAGE_STAND_IN);
90
+ return relative !== void 0 && relative.origin === PAGE_STAND_IN ? {
91
+ origin: null,
92
+ path: relative.pathname,
93
+ resolved: void 0
94
+ } : void 0;
95
+ };
96
+ const refuseEntry = (name, value, expected) => {
97
+ if (typeof value !== "string") return new require_errors.MountayaElementsError(`createTransformRequest: ${name} is ${value === null ? "null" : typeof value}, not a string; pass ${expected}.`);
98
+ return new require_errors.MountayaElementsError(value.includes("@") ? `createTransformRequest: ${name} holds an "@" and is not quoted, since a password may stand before it; pass ${expected}.` : `createTransformRequest: ${name} is ${JSON.stringify(value)}; pass ${expected}.`);
99
+ };
100
+ const ENTRY_FORMS = "an http or https URL with no username or password, a path starting with one \"/\" on the page's own origin, or \"\" for that origin whole";
101
+ const entryPlace = (name, entry) => {
102
+ if (typeof entry !== "string") throw refuseEntry(name, entry, ENTRY_FORMS);
103
+ if (entry === "" || entry.startsWith("/")) {
104
+ const relative = parsed(entry, PAGE_STAND_IN);
105
+ if (relative === void 0 || relative.origin !== PAGE_STAND_IN) throw refuseEntry(name, entry, ENTRY_FORMS);
106
+ return {
107
+ origin: null,
108
+ path: withoutTrailingSlash(relative.pathname)
109
+ };
110
+ }
111
+ const absolute = parsed(entry);
112
+ if (absolute === void 0 || !CLAIMED_PROTOCOLS.includes(absolute.protocol) || absolute.username !== "" || absolute.password !== "") throw refuseEntry(name, entry, ENTRY_FORMS);
113
+ return {
114
+ origin: absolute.origin,
115
+ path: withoutTrailingSlash(absolute.pathname)
116
+ };
117
+ };
118
+ const scopedPathFrom = (prefix) => {
119
+ const expected = "a path under the claimed base, such as \"/v1/itineraries/abc\"";
120
+ if (typeof prefix !== "string") throw refuseEntry("scoped.pathPrefix", prefix, expected);
121
+ const relative = parsed(prefix, PAGE_STAND_IN);
122
+ if (relative === void 0 || relative.origin !== PAGE_STAND_IN) throw refuseEntry("scoped.pathPrefix", prefix, expected);
123
+ return withoutTrailingSlash(relative.pathname);
124
+ };
125
+ const thrownAs = (thrown) => {
126
+ if (typeof thrown === "string") return `the string ${JSON.stringify(thrown)}`;
127
+ try {
128
+ if (thrown instanceof Error) {
129
+ const { message } = thrown;
130
+ if (typeof message === "string") return `an error, ${JSON.stringify(message)}`;
131
+ }
132
+ } catch {}
133
+ return thrown === null ? "null" : `a value of type ${typeof thrown}`;
134
+ };
135
+ const sessionTokenFrom = (read) => {
136
+ let answer;
137
+ try {
138
+ answer = read();
139
+ } catch (cause) {
140
+ throw new require_errors.MountayaElementsError(`createTransformRequest: sessionToken threw ${thrownAs(cause)}, while a claimed request read it. Return the current token, or undefined while there is none.`, { cause });
141
+ }
142
+ if (answer === void 0) return answer;
143
+ if (typeof answer !== "string") throw new require_errors.MountayaElementsError(`createTransformRequest: sessionToken answered ${answer === null ? "null" : `a value of type ${typeof answer}`}; return the current token as a string, or undefined while there is none.`);
144
+ const refusal = headerValueRefusal("sessionToken", answer);
145
+ if (refusal !== void 0) throw new require_errors.MountayaElementsError(`createTransformRequest: the sessionToken a claimed request read ${refusal}; return the token your server minted, or undefined while there is none.`);
146
+ return answer;
147
+ };
148
+ const attachmentFor = (credential, language) => {
149
+ const headers = { "X-Mountaya-Client": CLIENT_HEADER_VALUE };
150
+ if (credential.shareToken !== void 0) headers["X-Share-Token"] = credential.shareToken;
151
+ else if (credential.publishableKey !== void 0) {
152
+ headers["X-API-Key"] = credential.publishableKey;
153
+ const sessionToken = typeof credential.sessionToken === "function" ? sessionTokenFrom(credential.sessionToken) : credential.sessionToken;
154
+ if (sessionToken !== void 0) headers["X-Session-Token"] = sessionToken;
155
+ }
156
+ if (language !== void 0) headers["Accept-Language"] = language;
157
+ return {
158
+ headers,
159
+ withCookie: credential.cookie === true
160
+ };
161
+ };
162
+ const attachmentReaderFor = (credential, language) => {
163
+ if (typeof credential.sessionToken === "function") return () => attachmentFor(credential, language);
164
+ const attachment = attachmentFor(credential, language);
165
+ return () => attachment;
166
+ };
167
+ const OMIT_COOKIES = "omit";
168
+ const apply = (base, attachment) => {
169
+ const stated = new Set(Object.keys(base.headers ?? {}).map((name) => name.toLowerCase()));
170
+ const attached = Object.fromEntries(Object.entries(attachment.headers).filter(([name]) => !stated.has(name.toLowerCase())));
171
+ return {
172
+ ...base,
173
+ credentials: attachment.withCookie ? "include" : OMIT_COOKIES,
174
+ headers: {
175
+ ...attached,
176
+ ...base.headers
177
+ }
178
+ };
179
+ };
180
+ const createTransformRequest = (options = {}) => {
181
+ assertMapCredential(options, "", "createTransformRequest");
182
+ if (options.scoped !== void 0) assertMapCredential(options.scoped.credential, "scoped.credential.", "createTransformRequest");
183
+ if (options.language !== void 0) {
184
+ const refusal = headerValueRefusal("language", options.language);
185
+ if (refusal !== void 0) throw new require_errors.MountayaElementsError(`createTransformRequest: language ${refusal}; pass a BCP 47 tag such as "fr", or leave it out.`);
186
+ }
187
+ const baseUrls = (options.baseUrls ?? []).map((entry, index) => entryPlace(`baseUrls[${index}]`, entry));
188
+ const origins = (options.origins ?? (baseUrls.length > 0 ? [] : DEFAULT_ORIGINS)).map((entry, index) => entryPlace(`origins[${index}]`, entry));
189
+ const places = [...baseUrls, ...origins];
190
+ const attachment = attachmentReaderFor(options, options.language);
191
+ const scoped = options.scoped === void 0 ? void 0 : {
192
+ attachment: attachmentReaderFor(options.scoped.credential, options.language),
193
+ path: scopedPathFrom(options.scoped.pathPrefix)
194
+ };
195
+ const claimOf = (url) => {
196
+ const page = pageOf();
197
+ const request = placeOf(url, page);
198
+ if (request === void 0) return;
199
+ const own = page?.origin ?? null;
200
+ const entry = places.find((place) => (place.origin ?? own) === (request.origin ?? own) && isUnder(request.path, place.path));
201
+ return entry === void 0 ? void 0 : {
202
+ path: request.path.slice(entry.path.length),
203
+ resolved: request.resolved
204
+ };
205
+ };
206
+ return (url, resourceType) => {
207
+ const base = options.next?.(url, resourceType) ?? { url };
208
+ const claim = claimOf(base.url);
209
+ if (claim === void 0) return base;
210
+ return apply(claim.resolved === void 0 ? base : {
211
+ ...base,
212
+ url: claim.resolved
213
+ }, scoped !== void 0 && isUnder(claim.path, scoped.path) ? scoped.attachment() : attachment());
214
+ };
215
+ };
216
+ const prop = (name) => ["get", name];
217
+ const ofKind = (kind) => [
218
+ "==",
219
+ ["get", require_geoJson.analysisProps.KIND],
220
+ kind
221
+ ];
222
+ const isochroneLayers = (sourceId) => [{
223
+ id: `${sourceId}-fill`,
224
+ paint: {
225
+ "fill-color": prop(require_geoJson.analysisProps.COLOR),
226
+ "fill-opacity": require_geoJson.ISOCHRONE_FILL_OPACITY
227
+ },
228
+ source: sourceId,
229
+ type: "fill"
230
+ }, {
231
+ id: `${sourceId}-outline`,
232
+ paint: {
233
+ "line-color": require_geoJson.ISOCHRONE_LINE_COLOR,
234
+ "line-width": 1
235
+ },
236
+ source: sourceId,
237
+ type: "line"
238
+ }];
239
+ const directionsLayers = (sourceId, paint) => [require_roadAccessColors.itineraryCasingSpec({
240
+ id: `${sourceId}${require_order.ITINERARY_CASING_LAYER_SUFFIX}`,
241
+ paint,
242
+ source: sourceId
243
+ }), require_roadAccessColors.itineraryLineSpec({
244
+ color: require_geoJson.DIRECTIONS_LINE_COLOR,
245
+ id: `${sourceId}-line`,
246
+ paint,
247
+ source: sourceId
248
+ })];
249
+ const suggestionLayers = (sourceId, paint) => [require_roadAccessColors.itineraryDashedLineSpec({
250
+ color: prop(require_geoJson.analysisProps.COLOR),
251
+ filter: ["!", ["get", "chosen"]],
252
+ id: `${sourceId}-alternative`,
253
+ paint,
254
+ source: sourceId
255
+ }), require_roadAccessColors.itineraryLineSpec({
256
+ color: prop(require_geoJson.analysisProps.COLOR),
257
+ filter: ["get", "chosen"],
258
+ id: `${sourceId}-chosen`,
259
+ paint,
260
+ source: sourceId
261
+ })];
262
+ const pointLayers = (sourceId) => [{
263
+ id: `${sourceId}-point`,
264
+ paint: {
265
+ "circle-color": prop(require_geoJson.analysisProps.COLOR),
266
+ "circle-radius": 6,
267
+ "circle-stroke-color": require_geoJson.RESULT_POINT_STROKE_COLOR,
268
+ "circle-stroke-width": 2
269
+ },
270
+ source: sourceId,
271
+ type: "circle"
272
+ }];
273
+ const matrixLayers = (sourceId) => [{
274
+ filter: ofKind("matrix-connector"),
275
+ id: `${sourceId}-connector`,
276
+ layout: require_order.itineraryLineLayout,
277
+ paint: {
278
+ "line-color": require_geoJson.MATRIX_LINE_COLOR,
279
+ "line-opacity": require_geoJson.MATRIX_LINE_OPACITY,
280
+ "line-width": prop(require_geoJson.analysisProps.WIDTH)
281
+ },
282
+ source: sourceId,
283
+ type: "line"
284
+ }, {
285
+ filter: ofKind("matrix-location"),
286
+ id: `${sourceId}-location`,
287
+ paint: {
288
+ "circle-color": require_geoJson.MATRIX_LINE_COLOR,
289
+ "circle-radius": 6,
290
+ "circle-stroke-color": require_geoJson.RESULT_POINT_STROKE_COLOR,
291
+ "circle-stroke-width": 2
292
+ },
293
+ source: sourceId,
294
+ type: "circle"
295
+ }];
296
+ const statedMembers = (patch) => {
297
+ const stated = {};
298
+ for (const key in patch) if (Object.hasOwn(patch, key) && patch[key] !== void 0) stated[key] = patch[key];
299
+ return stated;
300
+ };
301
+ const statedLayerPatch = (patch, operation) => {
302
+ const layout = statedMembers(patch.layout ?? {});
303
+ const visibility = Reflect.get(layout, "visibility");
304
+ if (visibility !== void 0) throw new require_errors.MountayaElementsError(`${operation}: layout.visibility is ${require_errors.printValue(visibility)}; show or hide a layer with setLayerVisibility, which the map keeps across a base-map switch.`);
305
+ return {
306
+ layout,
307
+ paint: statedMembers(patch.paint ?? {})
308
+ };
309
+ };
310
+ const layerPatchesMerged = (earlier, later) => ({
311
+ layout: {
312
+ ...earlier.layout,
313
+ ...later.layout
314
+ },
315
+ paint: {
316
+ ...earlier.paint,
317
+ ...later.paint
318
+ }
319
+ });
320
+ const patchedProperties = (members) => Object.keys(members);
321
+ const ANALYSIS_SLOT_PREFIX = "analysis:";
322
+ const POI_QUERY_SLOT = `${ANALYSIS_SLOT_PREFIX}pois`;
323
+ const analysisSlotPrefix = (kind) => `${ANALYSIS_SLOT_PREFIX}${kind}:`;
324
+ const analysisMethods = {
325
+ directions: {
326
+ add: "addDirections",
327
+ edit: "editDirections"
328
+ },
329
+ isochrones: {
330
+ add: "addIsochrones",
331
+ edit: "editIsochrones"
332
+ },
333
+ matrix: {
334
+ add: "addMatrix",
335
+ edit: "editMatrix"
336
+ },
337
+ places: {
338
+ add: "addPlaces",
339
+ edit: "editPlaces"
340
+ },
341
+ pois: {
342
+ add: "setPointsOfInterest",
343
+ edit: "editPointsOfInterest"
344
+ },
345
+ suggestions: {
346
+ add: "addSuggestions",
347
+ edit: "editSuggestions"
348
+ }
349
+ };
350
+ const analysisOperations = {
351
+ directions: (client, input, signal) => client.data.directions(input, { signal }),
352
+ isochrones: (client, input, signal) => client.data.isochrones(input, { signal }),
353
+ matrix: (client, input, signal) => client.data.matrix(input, { signal }),
354
+ places: (client, input, signal) => client.data.geocode(input, { signal }),
355
+ pois: (client, input, signal) => client.data.pois(input, { signal }),
356
+ suggestions: (client, input, signal) => client.data.suggestions(input, { signal })
357
+ };
358
+ const drawnFeatures = (collection) => ({
359
+ features: collection.features.filter((feature) => feature.geometry !== null),
360
+ type: "FeatureCollection"
361
+ });
362
+ const analysisSpecs = {
363
+ directions: {
364
+ layers: directionsLayers,
365
+ rank: 50,
366
+ toGeoJson: (result) => require_geoJson.directionsToGeoJson(result)
367
+ },
368
+ isochrones: {
369
+ layers: isochroneLayers,
370
+ rank: 40,
371
+ toGeoJson: (result) => require_geoJson.isochronesToGeoJson(result)
372
+ },
373
+ matrix: {
374
+ layers: matrixLayers,
375
+ rank: 40,
376
+ toGeoJson: (result, input) => drawnFeatures(require_geoJson.matrixToGeoJson(input ?? {
377
+ locations: [],
378
+ metrics: []
379
+ }, result))
380
+ },
381
+ places: {
382
+ layers: pointLayers,
383
+ rank: 80,
384
+ toGeoJson: (result) => drawnFeatures(require_geoJson.placesToGeoJson(result))
385
+ },
386
+ pois: {
387
+ layers: pointLayers,
388
+ rank: 80,
389
+ toGeoJson: (result) => drawnFeatures(require_geoJson.poisToGeoJson(result))
390
+ },
391
+ suggestions: {
392
+ layers: suggestionLayers,
393
+ rank: 50,
394
+ toGeoJson: (result, _input, chosen) => require_geoJson.suggestionsToGeoJson(result, chosen)
395
+ }
396
+ };
397
+ const analysisResultMembers = {
398
+ directions: ["routes"],
399
+ isochrones: ["isochrones"],
400
+ matrix: ["durations", "distances"],
401
+ places: ["places"],
402
+ pois: ["pois"],
403
+ suggestions: ["routes"]
404
+ };
405
+ const isAnalysisResult = (kind, value) => analysisResultMembers[kind].some((member) => member in value);
406
+ const article = (kind) => kind === "isochrones" ? "an" : "a";
407
+ const heldAnalysisOf = (analyses, kind, id) => {
408
+ const held = analyses.get(id);
409
+ if (held === void 0) throw new require_errors.MountayaElementsNotFoundError(`No analysis is drawn under "${id}". It was either never added or already removed.`);
410
+ if (held.kind !== kind) throw new require_errors.MountayaElementsNotFoundError(`No ${kind} analysis is drawn under "${id}": it holds ${article(held.kind)} ${held.kind} one. Edit it with the method of its own kind.`);
411
+ return held;
412
+ };
413
+ const analysisEditOf = (held, id, patch, options) => {
414
+ const stated = statedMembers(patch);
415
+ const restyle = statedMembers(options);
416
+ const merged = {
417
+ ...held.options,
418
+ ...restyle
419
+ };
420
+ if (Object.keys(stated).length === 0) return {
421
+ input: void 0,
422
+ options: merged,
423
+ restyle
424
+ };
425
+ if (held.input === void 0) throw new require_errors.MountayaElementsError(`The analysis drawn under "${id}" was drawn from a result, so it holds no input to merge a patch onto. Remove it and add the query with its whole input, or pass an empty patch to restyle it.`);
426
+ return {
427
+ input: {
428
+ ...held.input,
429
+ ...stated
430
+ },
431
+ options: merged,
432
+ restyle
433
+ };
434
+ };
435
+ const analysisSlotsOfKind = (kind, slots, analyses) => {
436
+ const prefix = analysisSlotPrefix(kind);
437
+ return [...new Set(slots)].filter((slot) => analyses.get(slot)?.kind === kind || slot.startsWith(prefix));
438
+ };
439
+ const controlMoveTarget = (camera, window, move) => {
440
+ if (move === "reset-north") return {
441
+ ...camera,
442
+ bearing: 0,
443
+ pitch: 0
444
+ };
445
+ const step = move === "zoom-in" ? 1 : -1;
446
+ return {
447
+ ...camera,
448
+ zoom: Math.min(Math.max(camera.zoom + step, window.min), window.max)
449
+ };
450
+ };
451
+ const carryOwnLayers = (previous, next, { held, mapSources, own }) => {
452
+ if (previous === void 0 || own.size === 0) return {
453
+ layers: [],
454
+ style: next
455
+ };
456
+ const placed = previous.layers.filter((layer) => own.has(layer.id));
457
+ const onTheStyle = new Set(placed.map((layer) => layer.id));
458
+ const layers = [...placed, ...[...held.values()].filter((layer) => !onTheStyle.has(layer.id))];
459
+ const sources = {};
460
+ for (const layer of layers) {
461
+ const source = "source" in layer ? layer.source : void 0;
462
+ if (typeof source !== "string" || mapSources.has(source) || Object.hasOwn(next.sources, source) || !Object.hasOwn(previous.sources, source)) continue;
463
+ const spec = previous.sources[source];
464
+ if (spec !== void 0) sources[source] = spec;
465
+ }
466
+ return {
467
+ layers,
468
+ style: Object.keys(sources).length === 0 ? next : {
469
+ ...next,
470
+ sources: {
471
+ ...next.sources,
472
+ ...sources
473
+ }
474
+ }
475
+ };
476
+ };
477
+ const UNREWRITTEN_WORKER_PATH = "/@mountaya/elements/maplibre-worker.mjs";
478
+ let workerReported = false;
479
+ let stylesheetReported = false;
480
+ let containerReported = false;
481
+ const isUnrewrittenWorkerUrl = (href) => {
482
+ try {
483
+ return new URL(href).pathname.endsWith(UNREWRITTEN_WORKER_PATH);
484
+ } catch {
485
+ return false;
486
+ }
487
+ };
488
+ const warnOnUnrewrittenWorker = (href) => {
489
+ if (workerReported || !require_inDevelopment.inDevelopment() || typeof document === "undefined" || !isUnrewrittenWorkerUrl(href)) return;
490
+ workerReported = true;
491
+ console.warn(`[@mountaya/elements] No bundler resolved the MapLibre worker's address: it reads ${href}, the package's specifier joined onto this script's own address, which a server rarely answers. A map then mounts and draws no tile, with nothing thrown. Serve @mountaya/elements/maplibre-worker.mjs from an address of your own and pass that address to maplibre-gl's setWorkerUrl() before the first map is built.`);
492
+ };
493
+ const warnOnMissingStylesheet = (canvas) => {
494
+ if (stylesheetReported || !require_inDevelopment.inDevelopment() || typeof getComputedStyle === "undefined" || !canvas.isConnected || getComputedStyle(canvas).position === "absolute") return;
495
+ stylesheetReported = true;
496
+ console.warn("[@mountaya/elements] The map's stylesheet is not loaded, so its canvas, its attribution and its popups are laid out wrongly. Import \"@mountaya/elements/styles.css\" once, or the styles.css of @mountaya/elements-react or @mountaya/studio-react, which contain it.");
497
+ };
498
+ const warnOnCollapsedContainer = (container) => {
499
+ if (containerReported || !require_inDevelopment.inDevelopment() || !container.isConnected || container.getClientRects().length === 0) return;
500
+ const collapsed = [...container.clientHeight === 0 ? ["height"] : [], ...container.clientWidth === 0 ? ["width"] : []];
501
+ if (collapsed.length === 0) return;
502
+ containerReported = true;
503
+ console.warn(`[@mountaya/elements] The map's container has no ${collapsed.join(" and no ")}, so the map draws nothing a reader can see. Give the element a size in CSS (height: 400px, or a parent laid out to fill), before or after the map is built: the map follows its container.`);
504
+ };
505
+ const quoteBounds = (written) => {
506
+ if (!(written instanceof maplibre_gl.LngLatBounds)) return require_errors.printValue(written);
507
+ return written.isEmpty() ? "new LngLatBounds()" : require_errors.printValue(written.toArray());
508
+ };
509
+ const readLockEdges = (written) => {
510
+ try {
511
+ const lock = maplibre_gl.LngLatBounds.convert(written);
512
+ return [
513
+ lock.getWest(),
514
+ lock.getSouth(),
515
+ lock.getEast(),
516
+ lock.getNorth()
517
+ ];
518
+ } catch (cause) {
519
+ const said = cause instanceof Error ? ` (MapLibre: ${cause.message})` : "";
520
+ throw new require_errors.MountayaElementsError(`The maxBounds ${quoteBounds(written)} cannot be read as a pan lock${said}. Pass bounds MapLibre reads, or null to lift the lock.`, { cause });
521
+ }
522
+ };
523
+ const refuseLockWithNoArea = (edges, written) => require_camera.refuseMaxBoundsWithNoArea(edges, require_slotNames.isBoundingBox(written) ? written : quoteBounds(written));
524
+ const readMaxBounds = (bounds) => {
525
+ if (require_slotNames.isBoundingBox(bounds)) return require_slotNames.readBoxLock(bounds);
526
+ const [west, south, east, north] = readLockEdges(bounds);
527
+ const world = west <= east ? require_slotNames.wholeWorldLongitudes(west, east) : null;
528
+ if (world === null) {
529
+ refuseLockWithNoArea([
530
+ west,
531
+ south,
532
+ east,
533
+ north
534
+ ], bounds);
535
+ return bounds;
536
+ }
537
+ const lock = [
538
+ world[0],
539
+ south,
540
+ world[1],
541
+ north
542
+ ];
543
+ refuseLockWithNoArea(lock, bounds);
544
+ return lock;
545
+ };
546
+ const edgesOf = (bounds) => {
547
+ const corners = maplibre_gl.LngLatBounds.convert(bounds).adjustAntiMeridian();
548
+ return [
549
+ corners.getWest(),
550
+ corners.getSouth(),
551
+ corners.getEast(),
552
+ corners.getNorth()
553
+ ];
554
+ };
555
+ const readFitBox = (bounds, operation) => {
556
+ let box = null;
557
+ let cause;
558
+ try {
559
+ box = require_camera.normalizeBoundingBox(require_slotNames.isBoundingBox(bounds) ? bounds : edgesOf(bounds));
560
+ } catch (refused) {
561
+ cause = refused;
562
+ }
563
+ if (box === null || !box.every((edge) => Number.isFinite(edge))) throw new require_errors.MountayaElementsError(`${operation}: bounds is ${quoteBounds(bounds)}; pass [west, south, east, north] in degrees, each a finite number, or another shape MapLibre takes for bounds.`, cause === void 0 ? void 0 : { cause });
564
+ return box;
565
+ };
566
+ const POINT_GEOMETRY_TYPES = ["Point", "MultiPoint"];
567
+ const geoJsonLayers = (sourceId, color, paint, drawsPoints) => {
568
+ const point = {
569
+ filter: [
570
+ "in",
571
+ ["geometry-type"],
572
+ ["literal", POINT_GEOMETRY_TYPES]
573
+ ],
574
+ id: `${sourceId}-point`,
575
+ paint: {
576
+ "circle-color": color,
577
+ "circle-radius": 6,
578
+ "circle-stroke-color": paint.itinerary.casingColor,
579
+ "circle-stroke-width": 2
580
+ },
581
+ source: sourceId,
582
+ type: "circle"
583
+ };
584
+ return [
585
+ require_roadAccessColors.itineraryCasingSpec({
586
+ id: `${sourceId}${require_order.ITINERARY_CASING_LAYER_SUFFIX}`,
587
+ paint,
588
+ source: sourceId
589
+ }),
590
+ require_roadAccessColors.itineraryLineSpec({
591
+ color,
592
+ id: `${sourceId}-line`,
593
+ paint,
594
+ source: sourceId
595
+ }),
596
+ ...drawsPoints ? [point] : []
597
+ ];
598
+ };
599
+ const GEOMETRY_SLOTS = [
600
+ "preview",
601
+ "highlight",
602
+ "emphasis"
603
+ ];
604
+ const readGeometrySlot = (slot, operation) => {
605
+ const found = GEOMETRY_SLOTS.find((known) => known === slot);
606
+ if (found === void 0) throw new require_errors.MountayaElementsError(`${operation}: slot is ${require_errors.printValue(slot)}; pass "preview", "highlight" or "emphasis".`);
607
+ return found;
608
+ };
609
+ const geometrySlots = {
610
+ emphasis: {
611
+ color: "#e9501e",
612
+ rank: 52,
613
+ sourceId: "mountaya-emphasis"
614
+ },
615
+ highlight: {
616
+ color: "#f59f00",
617
+ rank: 100,
618
+ sourceId: "mountaya-highlight"
619
+ },
620
+ preview: {
621
+ color: "#2b8a3e",
622
+ rank: 52,
623
+ sourceId: "mountaya-preview"
624
+ }
625
+ };
626
+ const geometrySlotLayers = (slot, color, paint) => {
627
+ const { rank, sourceId } = geometrySlots[slot];
628
+ return {
629
+ layers: geoJsonLayers(sourceId, color, paint, slot === "highlight"),
630
+ rank,
631
+ sourceId
632
+ };
633
+ };
634
+ const emptyGeometrySlots = {
635
+ emphasis: {
636
+ color: geometrySlots.emphasis.color,
637
+ geometry: null
638
+ },
639
+ highlight: {
640
+ color: geometrySlots.highlight.color,
641
+ geometry: null
642
+ },
643
+ preview: {
644
+ color: geometrySlots.preview.color,
645
+ geometry: null
646
+ }
647
+ };
648
+ const slotAfter = (before, write) => {
649
+ const own = geometrySlots[write.slot].color;
650
+ if (write.change === "clear") return {
651
+ color: own,
652
+ geometry: null
653
+ };
654
+ if (write.change === "set") return {
655
+ color: write.color ?? own,
656
+ geometry: write.geometry
657
+ };
658
+ return {
659
+ color: write.color ?? before.color,
660
+ geometry: write.geometry === void 0 ? before.geometry : write.geometry
661
+ };
662
+ };
663
+ const geometrySlotsAfter = (held, write) => ({
664
+ ...held,
665
+ [write.slot]: slotAfter(held[write.slot], write)
666
+ });
667
+ const namesConcept = (key) => key !== "";
668
+ const drawnKeys = (contents, ranks, rank) => {
669
+ const keys = [];
670
+ for (const content of contents) for (const source of content.sources) for (const layer of source.layers) {
671
+ if (!namesConcept(layer.key)) continue;
672
+ if (rank !== void 0 && require_order.rankForTileLayer(layer, ranks) !== rank) continue;
673
+ if (!keys.includes(layer.key)) keys.push(layer.key);
674
+ }
675
+ return keys;
676
+ };
677
+ const keyLayerIds = (contents, key) => {
678
+ const ids = [];
679
+ if (!namesConcept(key)) return ids;
680
+ for (const content of contents) for (const source of content.sources) for (const layer of source.layers) if (layer.key === key && !ids.includes(layer.id)) ids.push(layer.id);
681
+ return ids;
682
+ };
683
+ const lowestRankedAbove = (order, layerRankById, rank, skipped) => {
684
+ for (const id of order) {
685
+ const otherRank = id === skipped ? void 0 : layerRankById.get(id);
686
+ if (otherRank !== void 0 && otherRank > rank) return id;
687
+ }
688
+ };
689
+ const beforeIdForRank = (map, layerRankById, rank) => lowestRankedAbove(map.getLayersOrder(), layerRankById, rank);
690
+ const placeRanked = (order, layerRankById, id, rank) => order.includes(id) && layerRankById.get(id) === rank ? null : { beforeId: lowestRankedAbove(order, layerRankById, rank, id) };
691
+ const LAYERS_MANIFEST_PATH = "/v1/tile-layers";
692
+ const layersManifestAddress = (tilesBaseUrl) => `${tilesBaseUrl.replace(/\/+$/u, "")}${LAYERS_MANIFEST_PATH}`;
693
+ const MARKER_PIN_PX = 28;
694
+ const MARKER_PIN_RING_PX = 3;
695
+ const MARKER_PIN_GLYPH_PX = 16;
696
+ const MARKER_PIN_DOT_PX = 8;
697
+ const MARKER_PIN_MARK_COLOR = "#ffffff";
698
+ const markerPinSpec = (marker, icons) => ({
699
+ centre: marker.glyph !== void 0 && icons.has(marker.glyph) ? {
700
+ color: MARKER_PIN_MARK_COLOR,
701
+ glyph: marker.glyph,
702
+ size: MARKER_PIN_GLYPH_PX
703
+ } : {
704
+ color: MARKER_PIN_MARK_COLOR,
705
+ dot: MARKER_PIN_DOT_PX
706
+ },
707
+ diameter: MARKER_PIN_PX,
708
+ fill: marker.color ?? null,
709
+ ring: {
710
+ color: MARKER_PIN_MARK_COLOR,
711
+ width: MARKER_PIN_RING_PX
712
+ }
713
+ });
714
+ const markerPinColor = (fill) => fill ?? `var(--mtya-accent, #1c7ed6)`;
715
+ const styleMarkerPin = (element, spec, svg, clickable) => {
716
+ const { style } = element;
717
+ style.alignItems = "center";
718
+ style.backgroundColor = "var(--mountaya-marker-color)";
719
+ style.border = `${spec.ring.width}px solid ${spec.ring.color}`;
720
+ style.borderRadius = "50%";
721
+ style.boxShadow = "0 1px 4px rgba(0, 0, 0, 0.35)";
722
+ style.boxSizing = "border-box";
723
+ style.color = spec.centre.color;
724
+ style.cursor = clickable ? "pointer" : "";
725
+ style.display = "flex";
726
+ style.height = `${spec.diameter}px`;
727
+ style.justifyContent = "center";
728
+ style.width = `${spec.diameter}px`;
729
+ if ("glyph" in spec.centre) {
730
+ svg?.setAttribute("height", String(spec.centre.size));
731
+ svg?.setAttribute("width", String(spec.centre.size));
732
+ return;
733
+ }
734
+ const dot = document.createElement("span");
735
+ dot.style.backgroundColor = spec.centre.color;
736
+ dot.style.borderRadius = "50%";
737
+ dot.style.height = `${spec.centre.dot}px`;
738
+ dot.style.width = `${spec.centre.dot}px`;
739
+ element.append(dot);
740
+ };
741
+ const markersAdded = (pinned, marker) => {
742
+ const lngLat = require_slotNames.readMarkerLngLat(marker.lngLat, "addMarker", "lngLat");
743
+ return [...pinned.filter((held) => held.marker.id !== marker.id), {
744
+ lngLat,
745
+ marker
746
+ }];
747
+ };
748
+ const markersEdited = (pinned, id, patch) => {
749
+ const held = pinned.find((entry) => entry.marker.id === id);
750
+ if (held === void 0) throw new require_errors.MountayaElementsNotFoundError(`No marker is pinned under "${id}". It was never added, or removed.`);
751
+ const marker = {
752
+ ...held.marker,
753
+ ...statedMembers(patch),
754
+ id
755
+ };
756
+ const lngLat = require_slotNames.readMarkerLngLat(marker.lngLat, "editMarker", "lngLat");
757
+ return pinned.map((entry) => entry === held ? {
758
+ lngLat,
759
+ marker
760
+ } : entry);
761
+ };
762
+ const markersRemoved = (pinned, id) => {
763
+ const kept = pinned.filter((entry) => entry.marker.id !== id);
764
+ return kept.length === pinned.length ? pinned : kept;
765
+ };
766
+ const requireOverlay = (layers, slug, kind) => {
767
+ const found = require_geoJson.findOverlay(layers, slug, kind);
768
+ if (found !== null) return found;
769
+ const stacks = kind === "enrichment";
770
+ const isOtherKind = require_geoJson.findOverlay(layers, slug, stacks ? "classic" : "enrichment") !== null;
771
+ const otherKind = stacks ? ": it is a classic overlay, which setOverlay draws" : ": it is an enrichment, which addEnrichment draws";
772
+ const available = layers.overlays.filter((category) => require_geoJson.isEnrichmentCategory(category) === stacks).flatMap((category) => category.children.map((child) => child.slug)).join(", ");
773
+ throw new require_errors.MountayaElementsNotFoundError(`No ${stacks ? "enrichment" : "classic overlay"} named "${slug}"${isOtherKind ? otherKind : ""}. Available: ${available}.`);
774
+ };
775
+ const paintOf = (layer) => "paint" in layer && layer.paint !== void 0 ? layer.paint : {};
776
+ const paintProperties = (paint) => Object.keys(paint);
777
+ const sameValue = (a, b) => JSON.stringify(a) === JSON.stringify(b);
778
+ const sameButPaint = (a, b) => sameValue({
779
+ ...a,
780
+ paint: void 0
781
+ }, {
782
+ ...b,
783
+ paint: void 0
784
+ });
785
+ const queriedFeature = (feature) => {
786
+ const properties = {};
787
+ for (const [key, value] of Object.entries(feature.properties ?? {})) if (value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "string") properties[key] = value;
788
+ return {
789
+ geometry: feature.geometry,
790
+ ...feature.id === void 0 ? {} : { id: feature.id },
791
+ layer: feature.layer.id,
792
+ properties,
793
+ ...feature.sourceLayer === void 0 ? {} : { sourceLayer: feature.sourceLayer },
794
+ type: "Feature"
795
+ };
796
+ };
797
+ const queryBands = {
798
+ itineraries: [50, 90],
799
+ pois: [80],
800
+ zones: [40]
801
+ };
802
+ const queryLayerIds = (query, ranks, isLive) => {
803
+ const bands = query === "features" ? null : queryBands[query];
804
+ const ids = [...ranks].filter(([id, rank]) => (bands === null || bands.includes(rank)) && isLive(id)).map(([id]) => id);
805
+ return ids.length === 0 ? null : ids;
806
+ };
807
+ const TERRAIN_VARIANTS = ["light", "dark"];
808
+ const readTerrainVariant = (variant, operation, member) => {
809
+ const found = TERRAIN_VARIANTS.find((known) => known === variant);
810
+ if (found === void 0) throw new require_errors.MountayaElementsError(`${operation}: ${member} is ${require_errors.printValue(variant)}; pass "light" or "dark".`);
811
+ return found;
812
+ };
813
+ const terrainVariantOfStyle = (terrain, style) => {
814
+ const matching = TERRAIN_VARIANTS.filter((variant) => terrain.variants[variant].style.url === style);
815
+ return matching.length === 1 ? matching[0] : void 0;
816
+ };
817
+ const baseMapOf = (terrains, slug, variant) => {
818
+ const terrain = slug === null ? terrains[0] : terrains.find((listed) => listed.slug === slug);
819
+ return terrain === void 0 ? void 0 : {
820
+ slug: terrain.slug,
821
+ style: terrain.variants[variant].style.url
822
+ };
823
+ };
824
+ const MAPLIBRE_WORKER_VERSION = "6.20.0";
825
+ let settled = false;
826
+ const specifierBesideOurBuild = /(\/elements(?:@[^/]+)?\/dist\/)@mountaya\/elements\/(maplibre-worker\.mjs)$/;
827
+ const workerBesideBuild = (href) => href.replace(specifierBesideOurBuild, "$1$2");
828
+ const ensureMapLibreWorker = () => {
829
+ if (settled) return;
830
+ settled = true;
831
+ if ((0, maplibre_gl.getWorkerUrl)()) return;
832
+ let workerUrl;
833
+ try {
834
+ workerUrl = workerBesideBuild(new URL("@mountaya/elements/maplibre-worker.mjs", void 0).href);
835
+ (0, maplibre_gl.setWorkerUrl)(workerUrl);
836
+ } catch {
837
+ return;
838
+ }
839
+ warnOnUnrewrittenWorker(workerUrl);
840
+ const resolved = (0, maplibre_gl.getVersion)();
841
+ if (resolved !== "6.20.0") console.warn(`[@mountaya/elements] bundled MapLibre worker is ${MAPLIBRE_WORKER_VERSION} but maplibre-gl resolved to ${resolved}. Tiles should still render; if they do not, either align the versions or call maplibre-gl's setWorkerUrl() yourself to use your own copy.`);
842
+ };
843
+ const SWAP_MARKER_SOURCE = "mountaya-swap";
844
+ const withoutSwapMarker = (transformStyle, onThrow) => (previous, next) => {
845
+ const before = previous?.sources["mountaya-swap"] === void 0 ? previous : {
846
+ ...previous,
847
+ sources: Object.fromEntries(Object.entries(previous.sources).filter(([id]) => id !== SWAP_MARKER_SOURCE))
848
+ };
849
+ try {
850
+ return transformStyle(before, next);
851
+ } catch (thrown) {
852
+ onThrow(thrown, before !== void 0);
853
+ return before ?? next;
854
+ }
855
+ };
856
+ const STYLE_LOAD = "style.load";
857
+ const BASE_MAP_ASKED_AGAIN = "The base map asked for again as the WebGL context returned with no style failed. Check what the transformStyle handed to setStyle throws.";
858
+ const REFUSED_BASE_MAP_ASKED_AGAIN = "The base map asked for again under the credential the client sends, its document having been refused under one it replaced, failed. Check what the transformStyle handed to setStyle throws.";
859
+ const switchNeverMade = () => new require_errors.MountayaElementsError("The map was destroyed while a base-map switch waited for its WebGL context to return, so the switch was not made. Ask the map built next for the base map.");
860
+ var BaseMapSwitchEngine = class {
861
+ host;
862
+ styleParsed;
863
+ waits = /* @__PURE__ */ new Set();
864
+ askedBaseMap = null;
865
+ shownBaseMap = null;
866
+ swapCount = 0;
867
+ styleArrived = false;
868
+ styleRebuilding = false;
869
+ refusedSwap;
870
+ awaitedBaseMap;
871
+ lateBaseMap;
872
+ askedAgain = null;
873
+ firstStyleSettled = false;
874
+ endFirstStyleWait;
875
+ liveBeforeSwap = null;
876
+ lostContext = null;
877
+ contextWait = null;
878
+ interruptedSwap;
879
+ endSwapWait;
880
+ constructor(host, shown) {
881
+ this.host = host;
882
+ this.shownBaseMap = shown;
883
+ this.askedBaseMap = shown;
884
+ this.styleParsed = host.raw.isStyleLoaded() === true;
885
+ }
886
+ askedTerrain() {
887
+ return this.askedBaseMap?.terrain ?? null;
888
+ }
889
+ askedStyle() {
890
+ return this.askedBaseMap?.style ?? null;
891
+ }
892
+ asksOwnStyle() {
893
+ return this.askedBaseMap !== null && this.askedBaseMap.terrain === null;
894
+ }
895
+ ask(baseMap) {
896
+ this.askedBaseMap = baseMap;
897
+ }
898
+ isAsking(terrain, style) {
899
+ const asked = this.askedBaseMap;
900
+ return asked?.terrain === terrain && asked.style === style && this.lateBaseMap === void 0;
901
+ }
902
+ askAgain(style) {
903
+ const refused = [this.askedBaseMap, this.lateBaseMap].find((baseMap) => baseMap?.style === style);
904
+ if (refused === void 0 || refused === null || refused === this.askedAgain) return;
905
+ this.askedAgain = refused;
906
+ this.askedBaseMap = refused;
907
+ this.swap(refused.style, refused.transformStyle, refused.terrain).catch((error) => {
908
+ this.host.reportError(require_errors.errorFrom(error, REFUSED_BASE_MAP_ASKED_AGAIN));
909
+ });
910
+ }
911
+ heldLive() {
912
+ return this.liveBeforeSwap;
913
+ }
914
+ lost() {
915
+ return this.lostContext;
916
+ }
917
+ isRebuilding() {
918
+ return this.styleRebuilding;
919
+ }
920
+ noteError() {
921
+ if (!this.hasFirstStyleSettled()) {
922
+ this.firstStyleSettled = true;
923
+ this.shownBaseMap = null;
924
+ }
925
+ if (!this.hasStyleParsed()) this.styleRebuilding = false;
926
+ }
927
+ destroy() {
928
+ for (const settle of [...this.waits]) settle();
929
+ const wait = this.contextWait;
930
+ this.contextWait = null;
931
+ wait?.refuse(switchNeverMade());
932
+ }
933
+ async swap(style, transformStyle, terrain) {
934
+ const swap = ++this.swapCount;
935
+ if (!this.hasFirstStyleSettled()) {
936
+ await this.whenFirstStyleSettles();
937
+ if (this.host.isDestroyed() || swap !== this.swapCount) return;
938
+ }
939
+ for (;;) {
940
+ if (this.lostContext !== null) {
941
+ if (swap !== this.swapCount) return;
942
+ if (this.host.isDestroyed()) throw switchNeverMade();
943
+ this.host.events.beginStyleReload({ endsOnFailure: false });
944
+ await this.whenContextReturns();
945
+ if (swap !== this.swapCount) return;
946
+ if (this.host.isDestroyed()) throw switchNeverMade();
947
+ const shown = this.shownBaseMap;
948
+ if (terrain !== null && terrain === shown?.terrain && style === shown.style) {
949
+ this.host.events.cancelStyleReload();
950
+ return;
951
+ }
952
+ }
953
+ if (await this.makeSwap(swap, style, transformStyle, terrain)) return;
954
+ }
955
+ }
956
+ async makeSwap(swap, style, transformStyle, terrain) {
957
+ this.liveBeforeSwap ??= this.host.liveState();
958
+ this.host.emptyLive();
959
+ this.styleArrived = false;
960
+ this.refusedSwap = void 0;
961
+ let refusal;
962
+ const earlier = this.awaitedBaseMap ?? this.lateBaseMap;
963
+ const asked = {
964
+ style,
965
+ terrain,
966
+ transformStyle
967
+ };
968
+ this.awaitedBaseMap = asked;
969
+ this.lateBaseMap = void 0;
970
+ this.host.events.beginStyleReload();
971
+ try {
972
+ this.markSwap();
973
+ if (transformStyle !== void 0 && !this.hasStyleParsed() && !this.styleRebuilding) this.host.raw.setStyle(null);
974
+ const callers = transformStyle === void 0 ? void 0 : withoutSwapMarker(transformStyle, (thrown, handedBack) => {
975
+ refusal ??= { thrown };
976
+ if (handedBack && swap === this.swapCount) this.refusedSwap = swap;
977
+ });
978
+ const carry = this.hasStyleParsed() && !this.styleRebuilding ? this.host.carryOwnLayers() : void 0;
979
+ const hook = carry === void 0 || callers === void 0 ? callers ?? carry : (previous, next) => {
980
+ const answer = callers(previous, next);
981
+ return answer.layers === previous?.layers ? answer : carry(previous, answer);
982
+ };
983
+ this.host.raw.setStyle(style, hook === void 0 ? void 0 : { transformStyle: hook });
984
+ } catch (error) {
985
+ this.keepStyle();
986
+ this.lateBaseMap = earlier;
987
+ this.host.events.cancelStyleReload();
988
+ throw error;
989
+ }
990
+ await this.whenSwapStyleLoaded();
991
+ if (this.host.isDestroyed() || swap !== this.swapCount) {
992
+ if (refusal !== void 0) throw refusal.thrown;
993
+ return true;
994
+ }
995
+ if (this.interruptedSwap === swap) {
996
+ this.interruptedSwap = void 0;
997
+ return false;
998
+ }
999
+ if (refusal !== void 0) {
1000
+ if (!this.styleArrived) this.keepStyle();
1001
+ await this.host.replay();
1002
+ throw refusal.thrown;
1003
+ }
1004
+ if (!this.styleArrived) {
1005
+ this.keepStyle();
1006
+ this.lateBaseMap = asked;
1007
+ }
1008
+ await this.host.replay();
1009
+ return true;
1010
+ }
1011
+ whenContextReturns() {
1012
+ this.contextWait?.resume();
1013
+ return new Promise((resolve, reject) => {
1014
+ this.contextWait = {
1015
+ refuse: reject,
1016
+ resume: resolve
1017
+ };
1018
+ });
1019
+ }
1020
+ whenSwapStyleLoaded() {
1021
+ if (this.host.isDestroyed()) return Promise.resolve();
1022
+ return new Promise((resolve) => {
1023
+ const settle = () => {
1024
+ this.waits.delete(settle);
1025
+ if (this.endSwapWait === settle) this.endSwapWait = void 0;
1026
+ resolve();
1027
+ };
1028
+ this.endSwapWait = settle;
1029
+ this.waits.add(settle);
1030
+ this.host.events.afterStyleLoad(settle);
1031
+ });
1032
+ }
1033
+ keepReloadOpenForSwitch() {
1034
+ const interrupted = this.interruptedSwap !== void 0 && this.interruptedSwap === this.swapCount;
1035
+ if (this.contextWait !== null || interrupted) this.host.events.beginStyleReload({ endsOnFailure: false });
1036
+ }
1037
+ markSwap() {
1038
+ if (this.host.raw.isStyleLoaded() === void 0) return;
1039
+ try {
1040
+ if (this.host.raw.getSource("mountaya-swap") === void 0) this.host.raw.addSource(SWAP_MARKER_SOURCE, {
1041
+ data: {
1042
+ features: [],
1043
+ type: "FeatureCollection"
1044
+ },
1045
+ type: "geojson"
1046
+ });
1047
+ } catch {}
1048
+ }
1049
+ unmarkSwap() {
1050
+ try {
1051
+ if (this.host.raw.getSource("mountaya-swap") !== void 0) this.host.raw.removeSource(SWAP_MARKER_SOURCE);
1052
+ } catch {}
1053
+ }
1054
+ hasFirstStyleSettled() {
1055
+ this.firstStyleSettled ||= this.host.raw.isStyleLoaded() === true;
1056
+ return this.firstStyleSettled;
1057
+ }
1058
+ async whenFirstStyleSettles() {
1059
+ await new Promise((resolve) => {
1060
+ let stopListening = () => {};
1061
+ const settle = () => {
1062
+ stopListening();
1063
+ this.waits.delete(settle);
1064
+ if (this.endFirstStyleWait === settle) this.endFirstStyleWait = void 0;
1065
+ resolve();
1066
+ };
1067
+ this.endFirstStyleWait = settle;
1068
+ stopListening = this.host.events.on("error", settle);
1069
+ this.waits.add(settle);
1070
+ this.host.events.afterStyleLoad(settle);
1071
+ });
1072
+ this.firstStyleSettled = true;
1073
+ }
1074
+ noteStyleArrival() {
1075
+ const late = this.awaitedBaseMap === void 0;
1076
+ const arrived = late ? this.lateBaseMap : this.awaitedBaseMap;
1077
+ if (arrived === void 0) return false;
1078
+ this.shownBaseMap = arrived;
1079
+ this.awaitedBaseMap = void 0;
1080
+ this.lateBaseMap = void 0;
1081
+ this.liveBeforeSwap = null;
1082
+ this.styleArrived = true;
1083
+ this.host.forgetLive();
1084
+ if (late) this.askedBaseMap = arrived;
1085
+ return late;
1086
+ }
1087
+ keepStyle() {
1088
+ const held = this.liveBeforeSwap;
1089
+ this.liveBeforeSwap = null;
1090
+ this.awaitedBaseMap = void 0;
1091
+ this.askedBaseMap = this.shownBaseMap;
1092
+ this.unmarkSwap();
1093
+ if (held === null) return;
1094
+ this.host.keepLive(held);
1095
+ }
1096
+ returnFromLostContext(lost) {
1097
+ this.liveBeforeSwap = null;
1098
+ this.host.returnFromLostContext(lost);
1099
+ }
1100
+ bindStyleEvents() {
1101
+ let stopReadingStyle = () => {};
1102
+ if (!this.styleParsed) stopReadingStyle = this.host.events.on("styledata", () => {
1103
+ if (!this.host.events.isStyleReloading() && this.hasStyleParsed()) stopReadingStyle();
1104
+ });
1105
+ this.host.events.on("styledataloading", () => {
1106
+ this.styleRebuilding = true;
1107
+ if (!this.host.events.isStyleReloading()) this.host.events.beginStyleReload();
1108
+ });
1109
+ this.host.events.on(STYLE_LOAD, () => {
1110
+ this.firstStyleSettled = true;
1111
+ this.styleParsed = true;
1112
+ this.styleRebuilding = false;
1113
+ stopReadingStyle();
1114
+ const lost = this.lostContext;
1115
+ if (lost !== null) {
1116
+ if (!lost.restored) {
1117
+ this.keepReloadOpenForSwitch();
1118
+ return;
1119
+ }
1120
+ this.lostContext = null;
1121
+ this.lateBaseMap = void 0;
1122
+ this.refusedSwap = void 0;
1123
+ this.returnFromLostContext(lost);
1124
+ this.keepReloadOpenForSwitch();
1125
+ const wait = this.contextWait;
1126
+ this.contextWait = null;
1127
+ wait?.resume();
1128
+ }
1129
+ if (this.refusedSwap !== void 0) {
1130
+ const stayed = this.refusedSwap === this.swapCount;
1131
+ this.refusedSwap = void 0;
1132
+ if (stayed) {
1133
+ this.keepStyle();
1134
+ this.host.placePendingLayers();
1135
+ return;
1136
+ }
1137
+ }
1138
+ const late = lost === null && this.noteStyleArrival();
1139
+ this.host.applyLanguage();
1140
+ this.host.placePendingLayers();
1141
+ if (late) this.host.replayUnawaited();
1142
+ this.host.reportStyleLoad();
1143
+ });
1144
+ }
1145
+ bindContextEvents() {
1146
+ this.host.events.on("webglcontextlost", (event) => {
1147
+ this.lateBaseMap = void 0;
1148
+ if (!this.firstStyleSettled) {
1149
+ this.firstStyleSettled = true;
1150
+ this.endFirstStyleWait?.();
1151
+ }
1152
+ if (this.awaitedBaseMap !== void 0) {
1153
+ this.awaitedBaseMap = void 0;
1154
+ this.interruptedSwap = this.swapCount;
1155
+ this.endSwapWait?.();
1156
+ }
1157
+ this.lostContext ??= {
1158
+ coveragePaint: void 0,
1159
+ edited: /* @__PURE__ */ new Map(),
1160
+ hidden: this.host.hiddenLayers(),
1161
+ live: this.liveBeforeSwap ?? this.host.liveState(),
1162
+ removed: /* @__PURE__ */ new Set(),
1163
+ restored: false
1164
+ };
1165
+ this.lostContext.restored = false;
1166
+ this.styleRebuilding = false;
1167
+ this.host.reportError(new require_errors.MountayaElementsError("The map lost its WebGL context, so its canvas is blank. The browser restores a lost context on its own when it can, and the map redraws then; if it stays blank, destroy the map and build it again.", { cause: event.originalEvent }));
1168
+ });
1169
+ this.host.events.on("webglcontextrestored", () => {
1170
+ const lost = this.lostContext;
1171
+ if (lost === null) return;
1172
+ lost.restored = true;
1173
+ if (!this.styleRebuilding) this.returnWithNoStyleKept(lost);
1174
+ });
1175
+ }
1176
+ returnWithNoStyleKept(lost) {
1177
+ this.host.events.noteStyleDropped();
1178
+ this.lostContext = null;
1179
+ this.lateBaseMap = void 0;
1180
+ this.refusedSwap = void 0;
1181
+ this.liveBeforeSwap = null;
1182
+ const shown = this.shownBaseMap;
1183
+ this.shownBaseMap = null;
1184
+ const interrupted = this.interruptedSwap !== void 0 && this.interruptedSwap === this.swapCount;
1185
+ const wait = this.contextWait;
1186
+ this.contextWait = null;
1187
+ if (wait === null && !interrupted) {
1188
+ if (shown === null) this.host.events.cancelStyleReload();
1189
+ else this.swap(shown.style, shown.transformStyle, shown.terrain).catch((error) => {
1190
+ this.host.reportError(require_errors.errorFrom(error, BASE_MAP_ASKED_AGAIN));
1191
+ });
1192
+ }
1193
+ if (lost.coveragePaint !== void 0) this.host.showCoverage(lost.coveragePaint);
1194
+ wait?.resume();
1195
+ }
1196
+ hasStyleParsed() {
1197
+ this.styleParsed ||= this.host.raw.isStyleLoaded() === true;
1198
+ return this.styleParsed;
1199
+ }
1200
+ };
1201
+ const headerOf = (headers, name) => {
1202
+ const wanted = name.toLowerCase();
1203
+ return Object.entries(headers).find(([stated]) => stated.toLowerCase() === wanted)?.[1];
1204
+ };
1205
+ const sentCredentialOf = (request) => {
1206
+ const headers = request.headers ?? {};
1207
+ const credential = {
1208
+ publishableKey: headerOf(headers, "X-API-Key"),
1209
+ sessionToken: headerOf(headers, "X-Session-Token"),
1210
+ shareToken: headerOf(headers, "X-Share-Token")
1211
+ };
1212
+ return credential.publishableKey === void 0 && credential.sessionToken === void 0 && credential.shareToken === void 0 ? void 0 : credential;
1213
+ };
1214
+ const isSameCredential = (a, b) => a.publishableKey === b.publishableKey && a.sessionToken === b.sessionToken && a.shareToken === b.shareToken;
1215
+ var SentCredentialsEngine = class {
1216
+ claim;
1217
+ sent = /* @__PURE__ */ new Map();
1218
+ transform;
1219
+ constructor(claim) {
1220
+ this.claim = claim;
1221
+ this.transform = (url, resourceType) => {
1222
+ const request = claim(url, resourceType);
1223
+ this.keep(url, request);
1224
+ return request;
1225
+ };
1226
+ }
1227
+ isSuperseded(url) {
1228
+ const sent = this.sent.get(url);
1229
+ if (sent === void 0) return false;
1230
+ const now = this.sentNow(url);
1231
+ return now !== void 0 && !isSameCredential(sent.credential, now);
1232
+ }
1233
+ askedFor(url) {
1234
+ return this.sent.get(url)?.asked;
1235
+ }
1236
+ sentNow(url) {
1237
+ try {
1238
+ return sentCredentialOf(this.claim(url));
1239
+ } catch {
1240
+ return;
1241
+ }
1242
+ }
1243
+ keep(asked, request) {
1244
+ const credential = sentCredentialOf(request);
1245
+ if (credential === void 0) return;
1246
+ this.sent.delete(request.url);
1247
+ this.sent.set(request.url, {
1248
+ asked,
1249
+ credential
1250
+ });
1251
+ if (this.sent.size > 1024) {
1252
+ const oldest = this.sent.keys().next();
1253
+ if (oldest.done !== true) this.sent.delete(oldest.value);
1254
+ }
1255
+ }
1256
+ };
1257
+ var SlotRequestEngine = class {
1258
+ onChange;
1259
+ desired = /* @__PURE__ */ new Map();
1260
+ slotRequests = /* @__PURE__ */ new Map();
1261
+ slotRequestCount = 0;
1262
+ pendingMounts = /* @__PURE__ */ new Map();
1263
+ supersededRequests = /* @__PURE__ */ new Map();
1264
+ constructor(onChange) {
1265
+ this.onChange = onChange;
1266
+ }
1267
+ asked(slot) {
1268
+ return this.desired.get(slot);
1269
+ }
1270
+ isAsked(slot) {
1271
+ return this.desired.has(slot);
1272
+ }
1273
+ ask(slot, content) {
1274
+ this.desired.set(slot, content);
1275
+ }
1276
+ forget(slot) {
1277
+ this.desired.delete(slot);
1278
+ }
1279
+ askedSlots() {
1280
+ return this.desired.keys();
1281
+ }
1282
+ askedContent() {
1283
+ return this.desired.values();
1284
+ }
1285
+ entries() {
1286
+ return this.desired.entries();
1287
+ }
1288
+ requestedSlots() {
1289
+ return this.slotRequests.keys();
1290
+ }
1291
+ tokenOf(slot) {
1292
+ return this.slotRequests.get(slot);
1293
+ }
1294
+ release(slot) {
1295
+ this.slotRequests.delete(slot);
1296
+ }
1297
+ waitsToRegain(token) {
1298
+ return this.supersededRequests.has(token);
1299
+ }
1300
+ pending(slot) {
1301
+ return this.pendingMounts.get(slot);
1302
+ }
1303
+ beginMount(slot, token, content) {
1304
+ const pending = {
1305
+ displaced: this.desired.get(slot),
1306
+ endWait: void 0,
1307
+ token
1308
+ };
1309
+ this.pendingMounts.set(slot, pending);
1310
+ this.desired.set(slot, content);
1311
+ return pending;
1312
+ }
1313
+ endMount(slot) {
1314
+ this.pendingMounts.delete(slot);
1315
+ }
1316
+ abandon() {
1317
+ this.slotRequests.clear();
1318
+ this.pendingMounts.clear();
1319
+ }
1320
+ settleSuperseded() {
1321
+ const superseded = [...this.supersededRequests.values()];
1322
+ this.supersededRequests.clear();
1323
+ for (const request of superseded) request.settle();
1324
+ }
1325
+ take(slot, withdrawable = false) {
1326
+ const before = this.desired.get(slot);
1327
+ this.withdrawMount(slot);
1328
+ if (!withdrawable) this.endSupersessions(slot);
1329
+ this.slotRequestCount += 1;
1330
+ this.slotRequests.set(slot, this.slotRequestCount);
1331
+ return {
1332
+ before,
1333
+ token: this.slotRequestCount
1334
+ };
1335
+ }
1336
+ claim(slot, withdrawable = false) {
1337
+ const { before, token } = this.take(slot, withdrawable);
1338
+ const after = this.desired.get(slot);
1339
+ this.onChange(before, after);
1340
+ return {
1341
+ before: after,
1342
+ token
1343
+ };
1344
+ }
1345
+ withdrawMount(slot) {
1346
+ const pending = this.pendingMounts.get(slot);
1347
+ if (pending === void 0) return;
1348
+ this.pendingMounts.delete(slot);
1349
+ if (pending.displaced === void 0) this.desired.delete(slot);
1350
+ else this.desired.set(slot, pending.displaced);
1351
+ pending.endWait?.();
1352
+ }
1353
+ supersede(slot) {
1354
+ const token = this.slotRequests.get(slot);
1355
+ if (token === void 0) return;
1356
+ const mount = this.pendingMounts.get(slot);
1357
+ const desired = this.desired.get(slot);
1358
+ let settle = () => {};
1359
+ const settled = new Promise((resolve) => {
1360
+ settle = resolve;
1361
+ });
1362
+ const superseded = {
1363
+ settle,
1364
+ settled,
1365
+ slot,
1366
+ token,
1367
+ waiting: mount === void 0 || desired === void 0 ? void 0 : {
1368
+ desired,
1369
+ mount
1370
+ }
1371
+ };
1372
+ this.supersededRequests.set(token, superseded);
1373
+ return superseded;
1374
+ }
1375
+ giveBack(slot, token, superseded) {
1376
+ if (!this.owns(slot, token)) {
1377
+ this.endSupersession(this.supersededRequests.get(token));
1378
+ return;
1379
+ }
1380
+ const asked = this.desired.get(slot);
1381
+ this.withdrawMount(slot);
1382
+ const regaining = superseded !== void 0 && this.supersededRequests.get(superseded.token) === superseded ? superseded : void 0;
1383
+ if (regaining === void 0) this.slotRequests.delete(slot);
1384
+ else {
1385
+ this.slotRequests.set(slot, regaining.token);
1386
+ if (regaining.waiting !== void 0) {
1387
+ this.pendingMounts.set(slot, regaining.waiting.mount);
1388
+ this.desired.set(slot, regaining.waiting.desired);
1389
+ }
1390
+ }
1391
+ this.onChange(asked, this.desired.get(slot));
1392
+ this.endSupersession(superseded);
1393
+ }
1394
+ endSupersession(superseded) {
1395
+ if (superseded === void 0) return;
1396
+ if (this.supersededRequests.get(superseded.token) === superseded) this.supersededRequests.delete(superseded.token);
1397
+ superseded.settle();
1398
+ }
1399
+ endSupersessions(slot) {
1400
+ for (const superseded of [...this.supersededRequests.values()]) if (superseded.slot === slot) this.endSupersession(superseded);
1401
+ }
1402
+ async regains(slot, token) {
1403
+ let superseded = this.supersededRequests.get(token);
1404
+ while (superseded !== void 0) {
1405
+ await superseded.settled;
1406
+ if (this.owns(slot, token)) return true;
1407
+ const next = this.supersededRequests.get(token);
1408
+ superseded = next === superseded ? void 0 : next;
1409
+ }
1410
+ return this.owns(slot, token);
1411
+ }
1412
+ owns(slot, token) {
1413
+ return this.slotRequests.get(slot) === token;
1414
+ }
1415
+ };
1416
+ const slots = {
1417
+ COLLECTION: "collection",
1418
+ EMPHASIS: "emphasis",
1419
+ HIGHLIGHT: "highlight",
1420
+ ITINERARIES: "itineraries",
1421
+ ITINERARY: "itinerary",
1422
+ OVERLAY: "overlay",
1423
+ PREVIEW: "preview",
1424
+ SEARCH_HIGHLIGHT: "search-highlight",
1425
+ ZONES: "zones"
1426
+ };
1427
+ const ZOOM_EASE_MS = 250;
1428
+ const RESET_NORTH_MS = 1e3;
1429
+ const ATTRIBUTION_CONTROL_CLASS = "maplibregl-ctrl-attrib";
1430
+ const ATTRIBUTION_SHOWN_CLASS = "maplibregl-compact-show";
1431
+ const unawaitedFailures = {
1432
+ baseMap: "The base map the map was built to show did not arrive: the read of the layers manifest failed. Check what the client's transport rejects with.",
1433
+ ownLayer: "A layer of your own that waited on the style was refused as it was placed. Check the layer handed to addLayer.",
1434
+ onMounted: "An onMounted hook failed as its slot was drawn again. Check what the hook throws or rejects with.",
1435
+ redraw: "A Data API result held on the map failed to draw again. Check the result handed to the map.",
1436
+ renderer: "The renderer reported an error with a value that is no Error: a validation report of the style, or what a sprite load or a protocol of your own rejected with. Check the value this error holds as its cause.",
1437
+ replay: "The map failed to draw its content again onto the style that loaded.",
1438
+ searchHighlight: "The map failed to draw the search result it was asked to highlight. Check the result handed to setSearchHighlight."
1439
+ };
1440
+ const STREETVIEW_COVERAGE_SOURCE = "sv-coverage";
1441
+ const STREETVIEW_COVERAGE_LAYER = "sv-coverage-layer";
1442
+ const STREETVIEW_COVERAGE_TILES = "https://mts1.googleapis.com/vt?hl=en-US&lyrs=svv&style=40,18&x={x}&y={y}&z={z}";
1443
+ const unwrap = (envelope, what) => {
1444
+ if (envelope.data === void 0) throw new require_errors.MountayaElementsError(`The ${what} response carried no data.`);
1445
+ return envelope.data;
1446
+ };
1447
+ const organizationClosedError = () => new require_errors.MountayaElementsError("loadOrganization: the map is closed and holds no organization; read it from a map that is open.");
1448
+ const sameContent = (before, after) => before === after || before?.kind === "tiles" && after?.kind === "tiles" && before.specification.sources === after.specification.sources;
1449
+ const pointerLngLat = (event) => [require_longitude.wrapLongitudePastRange(event.lngLat.lng), event.lngLat.lat];
1450
+ var MountayaMap = class {
1451
+ raw;
1452
+ geolocation;
1453
+ icons;
1454
+ client;
1455
+ container;
1456
+ requests = new SlotRequestEngine((before, after) => {
1457
+ this.reportSlotChange(before, after);
1458
+ });
1459
+ mounted = /* @__PURE__ */ new Map();
1460
+ layerRankById = /* @__PURE__ */ new Map();
1461
+ pendingLayers = /* @__PURE__ */ new Map();
1462
+ ownLayers = /* @__PURE__ */ new Map();
1463
+ carriedLayers = /* @__PURE__ */ new Map();
1464
+ markers = /* @__PURE__ */ new Map();
1465
+ hiddenLayerIds = /* @__PURE__ */ new Set();
1466
+ accessRestrictionsVisible = true;
1467
+ pinned = [];
1468
+ geometrySlots = emptyGeometrySlots;
1469
+ searchHighlightAsked = 0;
1470
+ events;
1471
+ eventEngine;
1472
+ analyses = /* @__PURE__ */ new Map();
1473
+ analysisAborts = /* @__PURE__ */ new Map();
1474
+ analysisSeq = 0;
1475
+ listeners = /* @__PURE__ */ new Map();
1476
+ instant = null;
1477
+ terrainVariant;
1478
+ manifest = null;
1479
+ resolvedManifest;
1480
+ layersOrganization = null;
1481
+ terrainRequest;
1482
+ terrainLastAsked;
1483
+ baseMap;
1484
+ baseMapRequestCount = 0;
1485
+ displayAnswers = /* @__PURE__ */ new Map();
1486
+ language;
1487
+ hoverPosition = null;
1488
+ hoverFrame = null;
1489
+ destroyed = false;
1490
+ organization = null;
1491
+ refusals = /* @__PURE__ */ new Set();
1492
+ sentCredentials;
1493
+ styleWaits = /* @__PURE__ */ new Set();
1494
+ paint;
1495
+ constructor(options) {
1496
+ this.client = options.client;
1497
+ this.container = typeof options.container === "string" ? globalThis.document?.getElementById(options.container) ?? null : options.container;
1498
+ this.paint = require_roadAccessColors.resolveMapPaint(options.paint);
1499
+ this.geolocation = options.geolocation ?? require_geolocation.browserGeolocation();
1500
+ this.icons = options.icons ?? require_lucideMarkers_gen.lucideIconProvider;
1501
+ this.terrainVariant = readTerrainVariant(options.terrainVariant ?? "light", "new MountayaMap", "terrainVariant");
1502
+ this.language = options.language ?? require_language$1.clampMapLanguage(options.client.transport.requestLanguage ?? globalThis.navigator?.language);
1503
+ require_slotNames.refuseNonFiniteAmong(options.maplibre, "new MountayaMap", "maplibre");
1504
+ const constraints = options.constraints;
1505
+ const view = require_slotNames.readCameraPose({
1506
+ bearing: options.bearing,
1507
+ center: options.center,
1508
+ pitch: options.pitch,
1509
+ zoom: options.zoom
1510
+ }, "new MountayaMap");
1511
+ const zoomLimits = require_slotNames.readZoomLimits(constraints?.zoom, {
1512
+ max: options.maplibre?.maxZoom ?? 22,
1513
+ min: options.maplibre?.minZoom ?? -2
1514
+ }, "new MountayaMap({ constraints })");
1515
+ const lock = constraints?.maxBounds == null ? constraints?.maxBounds : readMaxBounds(constraints.maxBounds);
1516
+ ensureMapLibreWorker();
1517
+ this.raw = new maplibre_gl.Map({
1518
+ attributionControl: {
1519
+ customAttribution: require_language.BASEMAP_ATTRIBUTION,
1520
+ ...options.compactAttribution === void 0 ? {} : { compact: options.compactAttribution !== false }
1521
+ },
1522
+ ...options.maplibre,
1523
+ ...view,
1524
+ ...zoomLimits.max === void 0 ? {} : { maxZoom: zoomLimits.max },
1525
+ ...zoomLimits.min === void 0 ? {} : { minZoom: zoomLimits.min },
1526
+ container: options.container,
1527
+ style: options.style ?? {
1528
+ layers: [],
1529
+ sources: {},
1530
+ version: 8
1531
+ },
1532
+ transformRequest: options.transformRequest ?? this.buildTransformRequest(options)
1533
+ });
1534
+ this.eventEngine = new require_slotNames.MapEventEngine(this.raw);
1535
+ this.events = this.eventEngine;
1536
+ this.eventEngine.setMissingImageResolver((id) => id.startsWith("road-access-stripe-") ? Promise.resolve().then(() => require("./chunk-DXABHjLa.cjs")).then(({ answerRoadAccessStripe }) => {
1537
+ answerRoadAccessStripe(this.raw, id);
1538
+ }, () => void 0) : Promise.resolve().then(() => require("./chunk-CJVoSaAE.cjs")).then(({ answerMarkerImage }) => answerMarkerImage(this.raw, id, this.icons), () => void 0));
1539
+ this.eventEngine.afterStyleLoad(() => {});
1540
+ this.baseMap = new BaseMapSwitchEngine({
1541
+ applyLanguage: () => {
1542
+ this.applyLanguage();
1543
+ },
1544
+ carryOwnLayers: () => this.ownLayersCarrier(),
1545
+ emptyLive: () => {
1546
+ this.mounted.clear();
1547
+ this.layerRankById.clear();
1548
+ },
1549
+ events: this.eventEngine,
1550
+ forgetLive: () => {
1551
+ this.forgetLive();
1552
+ },
1553
+ hiddenLayers: () => new Set(this.hiddenLayerIds),
1554
+ isDestroyed: () => this.destroyed,
1555
+ keepLive: (held) => {
1556
+ this.keepLive(held);
1557
+ },
1558
+ liveState: () => ({
1559
+ mounted: new Map(this.mounted),
1560
+ ranks: new Map(this.layerRankById)
1561
+ }),
1562
+ placePendingLayers: () => {
1563
+ this.placePendingLayers();
1564
+ },
1565
+ raw: this.raw,
1566
+ replay: () => this.replay(),
1567
+ replayUnawaited: () => {
1568
+ this.replay().catch((error) => {
1569
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.replay) });
1570
+ });
1571
+ },
1572
+ reportError: (error) => {
1573
+ this.emit("error", { error });
1574
+ },
1575
+ reportStyleLoad: () => {
1576
+ this.emit("styleload", void 0);
1577
+ },
1578
+ returnFromLostContext: (lost) => {
1579
+ this.returnFromLostContext(lost);
1580
+ },
1581
+ showCoverage: (paint) => {
1582
+ this.setStreetviewCoverage(true, paint);
1583
+ }
1584
+ }, options.style === void 0 ? null : {
1585
+ style: options.style,
1586
+ terrain: null,
1587
+ transformStyle: void 0
1588
+ });
1589
+ this.bindMapEvents();
1590
+ if (options.compactAttribution === "collapsed") this.collapseCredits();
1591
+ if (lock !== void 0) this.raw.setMaxBounds(lock);
1592
+ if (options.style === void 0) this.setTerrain(options.terrain ?? null).catch((error) => {
1593
+ this.reportBaseMapFailure(error);
1594
+ });
1595
+ }
1596
+ async setItinerary(itinerary, options = {}) {
1597
+ if (this.destroyed) return { drawn: false };
1598
+ const fit = require_slotNames.readFit(options.fit, "setItinerary({ fit })");
1599
+ if (fit !== void 0 && itinerary !== null && typeof itinerary !== "string") throw new require_errors.MountayaElementsError("setItinerary: fit frames an itinerary named by its id, whose geometry the map reads through its client, and an itinerary's specification states no bounds. Pass the itinerary's id, or leave fit out and frame the itinerary with fitBounds.");
1600
+ let bounds = null;
1601
+ return { drawn: await this.setSlot(slots.ITINERARY, itinerary, async (id, signal) => {
1602
+ const [specification, spanned] = await Promise.all([this.client.tiles.getItinerarySpecification({ itinerary_id: id }, { signal }), fit === void 0 ? null : this.itineraryBounds(id, signal)]);
1603
+ bounds = spanned;
1604
+ return unwrap(specification, "itinerary");
1605
+ }, options.signal, () => {
1606
+ if (fit !== void 0 && bounds !== null) this.fitBounds(bounds, fit);
1607
+ }) };
1608
+ }
1609
+ async setCollection(collection, options = {}) {
1610
+ if (this.destroyed) return { drawn: false };
1611
+ const fit = require_slotNames.readFit(options.fit, "setCollection({ fit })");
1612
+ let bounds = collection === null || typeof collection === "string" ? null : require_camera.specificationBounds(collection.bbox ?? null);
1613
+ return { drawn: await this.setSlot(slots.COLLECTION, collection, async (id, signal) => {
1614
+ const specification = unwrap(await this.client.tiles.getCollectionSpecification({ collection_id: id }, { signal }), "collection");
1615
+ bounds = require_camera.specificationBounds(specification.bbox ?? null);
1616
+ return specification;
1617
+ }, options.signal, () => {
1618
+ if (fit !== void 0 && bounds !== null) this.fitBounds(bounds, fit);
1619
+ }) };
1620
+ }
1621
+ clearItinerary() {
1622
+ this.unmount(slots.ITINERARY);
1623
+ }
1624
+ clearCollection() {
1625
+ this.unmount(slots.COLLECTION);
1626
+ }
1627
+ clearOverlay() {
1628
+ this.unmount(slots.OVERLAY);
1629
+ }
1630
+ async setItineraries(on) {
1631
+ await this.toggleSlot(slots.ITINERARIES, on, async () => unwrap(await this.client.tiles.getItinerariesSpecification(), "itineraries"));
1632
+ }
1633
+ async setZones(on) {
1634
+ await this.toggleSlot(slots.ZONES, on, async () => unwrap(await this.client.tiles.getZonesSpecification(), "zones"));
1635
+ }
1636
+ async setTerrain(slug) {
1637
+ if (this.destroyed) return;
1638
+ const request = ++this.baseMapRequestCount;
1639
+ const asked = { slug };
1640
+ this.terrainRequest = asked;
1641
+ this.terrainLastAsked = asked;
1642
+ let terrain;
1643
+ try {
1644
+ const layers = await this.loadLayers();
1645
+ const found = baseMapOf(layers.terrains, slug, this.terrainVariant);
1646
+ if (found === void 0) {
1647
+ if (this.terrainLastAsked === asked) this.terrainLastAsked = void 0;
1648
+ throw new require_errors.MountayaElementsNotFoundError(slug === null ? "The layers manifest lists no terrains, so there is no base map to show." : `No terrain named "${slug}". Available: ${layers.terrains.map((t) => t.slug).join(", ")}.`);
1649
+ }
1650
+ terrain = found;
1651
+ } finally {
1652
+ if (request === this.baseMapRequestCount) this.terrainRequest = void 0;
1653
+ }
1654
+ if (request !== this.baseMapRequestCount) return;
1655
+ const { style } = terrain;
1656
+ if (this.baseMap.isAsking(terrain.slug, style)) return;
1657
+ this.baseMap.ask({
1658
+ style,
1659
+ terrain: terrain.slug,
1660
+ transformStyle: void 0
1661
+ });
1662
+ await this.baseMap.swap(style, void 0, terrain.slug);
1663
+ }
1664
+ async setStyle(style, options = {}) {
1665
+ if (this.destroyed) return;
1666
+ this.baseMap.ask({
1667
+ style,
1668
+ terrain: null,
1669
+ transformStyle: options.transformStyle
1670
+ });
1671
+ this.terrainRequest = void 0;
1672
+ this.terrainLastAsked = void 0;
1673
+ this.baseMapRequestCount += 1;
1674
+ await this.baseMap.swap(style, options.transformStyle, null);
1675
+ }
1676
+ getTerrain() {
1677
+ return this.baseMap.askedTerrain();
1678
+ }
1679
+ async setTerrainVariant(variant) {
1680
+ const read = readTerrainVariant(variant, "setTerrainVariant", "variant");
1681
+ if (this.destroyed) return;
1682
+ this.terrainVariant = read;
1683
+ const asked = this.terrainToAskAgain();
1684
+ if (asked !== void 0) await this.setTerrain(asked.slug);
1685
+ }
1686
+ getTerrainVariant() {
1687
+ const slug = this.baseMap.askedTerrain();
1688
+ const terrain = slug === null ? void 0 : this.resolvedManifest?.terrains.find((listed) => listed.slug === slug);
1689
+ return (terrain === void 0 ? void 0 : terrainVariantOfStyle(terrain, this.baseMap.askedStyle())) ?? this.terrainVariant;
1690
+ }
1691
+ getCredits() {
1692
+ if (this.destroyed) return require_language.mapCredits([]);
1693
+ const style = this.raw.getStyle();
1694
+ return require_language.mapCredits(require_language.creditedSourcesOf(style, this.raw.getZoom(), (id) => this.raw.getSource(id)?.attribution));
1695
+ }
1696
+ terrainToAskAgain() {
1697
+ if (this.terrainRequest !== void 0) return this.terrainRequest;
1698
+ const shown = this.baseMap.askedTerrain();
1699
+ if (shown !== null) return { slug: shown };
1700
+ return this.baseMap.asksOwnStyle() ? void 0 : this.terrainLastAsked;
1701
+ }
1702
+ async setOverlay(slug) {
1703
+ if (this.destroyed) return;
1704
+ if (slug === null) {
1705
+ this.unmount(slots.OVERLAY);
1706
+ return;
1707
+ }
1708
+ if (this.resolvedManifest !== void 0) {
1709
+ await this.setOverlaySpecification(requireOverlay(this.resolvedManifest, slug, "classic"));
1710
+ return;
1711
+ }
1712
+ const overlay = await this.readOverlayForSlot(slots.OVERLAY, slug, "classic");
1713
+ if (overlay !== null) await this.setOverlaySpecification(overlay);
1714
+ }
1715
+ async setOverlaySpecification(overlay, options = {}) {
1716
+ if (this.destroyed) return;
1717
+ const specification = { sources: overlay.sources };
1718
+ if (await this.mount(slots.OVERLAY, {
1719
+ kind: "tiles",
1720
+ onMounted: options.onMounted,
1721
+ overlay,
1722
+ specification
1723
+ })) this.easeIntoZoomRange(specification);
1724
+ }
1725
+ async addEnrichment(slug) {
1726
+ if (this.destroyed) return;
1727
+ if (this.resolvedManifest !== void 0) {
1728
+ await this.addEnrichmentSpecification(requireOverlay(this.resolvedManifest, slug, "enrichment"));
1729
+ return;
1730
+ }
1731
+ const overlay = await this.readOverlayForSlot(`${require_slotNames.ENRICHMENT_SLOT_PREFIX}${slug}`, slug, "enrichment");
1732
+ if (overlay !== null) await this.addEnrichmentSpecification(overlay);
1733
+ }
1734
+ async addEnrichmentSpecification(overlay, options = {}) {
1735
+ if (this.destroyed) return;
1736
+ const specification = { sources: overlay.sources };
1737
+ if (await this.mount(`enrichment:${overlay.slug}`, {
1738
+ kind: "tiles",
1739
+ onMounted: options.onMounted,
1740
+ specification
1741
+ })) this.easeIntoZoomRange(specification);
1742
+ }
1743
+ removeEnrichment(slug) {
1744
+ this.unmount(`${require_slotNames.ENRICHMENT_SLOT_PREFIX}${slug}`);
1745
+ }
1746
+ clearEnrichments() {
1747
+ for (const slot of /* @__PURE__ */ new Set([...this.requests.askedSlots(), ...this.requests.requestedSlots()])) if (slot.startsWith("enrichment:")) this.unmount(slot);
1748
+ }
1749
+ getEnrichments() {
1750
+ return this.displayAnswer("enrichments", () => [...this.requests.askedSlots()].filter((slot) => slot.startsWith(require_slotNames.ENRICHMENT_SLOT_PREFIX)).map((slot) => slot.slice(require_slotNames.ENRICHMENT_SLOT_PREFIX.length)));
1751
+ }
1752
+ async setInstant(instant) {
1753
+ if (this.destroyed) return;
1754
+ const pinnedMs = instant === null ? NaN : instant.getTime();
1755
+ const pinned = Number.isNaN(pinnedMs) ? null : new Date(pinnedMs);
1756
+ const moved = (this.instant?.getTime() ?? null) !== (pinned?.getTime() ?? null);
1757
+ this.instant = pinned;
1758
+ if (moved) this.stampDrawnOverlay();
1759
+ }
1760
+ getInstant() {
1761
+ return this.instant === null ? null : new Date(this.instant.getTime());
1762
+ }
1763
+ stampDrawnOverlay() {
1764
+ const drawn = this.liveOf(slots.OVERLAY)?.drawn;
1765
+ if (drawn?.kind !== "tiles" || drawn.overlay?.capabilities.server.timestamp !== true) return;
1766
+ for (const source of this.stampedSpecification(drawn).sources) {
1767
+ const onStyle = this.raw.getSource(source.id);
1768
+ if (onStyle !== void 0 && "setTiles" in onStyle) onStyle.setTiles([...source.tiles]);
1769
+ }
1770
+ }
1771
+ async setSpecification(name, specification, options = {}) {
1772
+ if (this.destroyed) return;
1773
+ await this.mount(this.specificationSlot(name), {
1774
+ kind: "tiles",
1775
+ onMounted: options.onMounted,
1776
+ specification
1777
+ });
1778
+ }
1779
+ removeSpecification(name) {
1780
+ if (this.destroyed) return;
1781
+ this.unmount(this.specificationSlot(name));
1782
+ }
1783
+ clearSpecifications() {
1784
+ for (const slot of [...this.requests.askedSlots()]) if (slot.startsWith("specification:")) this.unmount(slot);
1785
+ }
1786
+ getSpecifications() {
1787
+ return this.displayAnswer("specifications", () => [...this.requests.askedSlots()].filter((slot) => slot.startsWith(require_slotNames.SPECIFICATION_SLOT_PREFIX)).map((slot) => slot.slice(require_slotNames.SPECIFICATION_SLOT_PREFIX.length)));
1788
+ }
1789
+ addLayer(layer, rank) {
1790
+ if (this.destroyed) return;
1791
+ this.pendingLayers.delete(layer.id);
1792
+ if (!this.baseMap.hasStyleParsed() || this.baseMap.isRebuilding()) {
1793
+ this.pendingLayers.set(layer.id, {
1794
+ layer,
1795
+ rank
1796
+ });
1797
+ this.ownLayers.set(layer.id, rank);
1798
+ return;
1799
+ }
1800
+ this.placePendingLayers();
1801
+ const moved = this.placeLayer(layer, rank);
1802
+ this.ownLayers.set(layer.id, rank);
1803
+ if (moved) this.reportDisplayChange();
1804
+ }
1805
+ removeLayer(id) {
1806
+ if (this.destroyed) return;
1807
+ this.pendingLayers.delete(id);
1808
+ this.ownLayers.delete(id);
1809
+ this.carriedLayers.delete(id);
1810
+ this.baseMap.lost()?.removed.add(id);
1811
+ if (this.dropLayer(id)) this.reportDisplayChange();
1812
+ }
1813
+ editLayer(id, patch) {
1814
+ const edit = statedLayerPatch(patch, "editLayer");
1815
+ if (this.destroyed) return;
1816
+ const waiting = this.pendingLayers.get(id);
1817
+ if (waiting !== void 0) {
1818
+ this.pendingLayers.set(id, {
1819
+ ...waiting,
1820
+ edit: waiting.edit === void 0 ? edit : layerPatchesMerged(waiting.edit, edit)
1821
+ });
1822
+ return;
1823
+ }
1824
+ const lost = this.baseMap.lost();
1825
+ if (lost !== null && this.raw.getLayer(id) === void 0 && lost.live.ranks.has(id) && !lost.removed.has(id)) {
1826
+ const held = lost.edited.get(id);
1827
+ lost.edited.set(id, held === void 0 ? edit : layerPatchesMerged(held, edit));
1828
+ return;
1829
+ }
1830
+ if (!(this.layerRankById.has(id) || (this.baseMap.heldLive()?.ranks.has(id) ?? false)) || this.raw.getLayer(id) === void 0) throw new require_errors.MountayaElementsNotFoundError(`editLayer: the map places no layer under ${require_errors.printValue(id)}. Add it with addLayer first; a layer of the base map's own is set on map.raw.`);
1831
+ this.writeLayerPatch(id, edit);
1832
+ }
1833
+ setStreetviewCoverage(visible, paint = {}) {
1834
+ if (this.destroyed) return;
1835
+ this.eventEngine.afterStyleLoad(() => {
1836
+ const lost = this.baseMap.lost();
1837
+ if (!visible) {
1838
+ if (lost !== null) {
1839
+ lost.removed.add(STREETVIEW_COVERAGE_LAYER);
1840
+ lost.coveragePaint = void 0;
1841
+ }
1842
+ this.dropLayer(STREETVIEW_COVERAGE_LAYER);
1843
+ if (this.raw.getSource("sv-coverage") !== void 0) this.raw.removeSource(STREETVIEW_COVERAGE_SOURCE);
1844
+ return;
1845
+ }
1846
+ if (lost !== null) {
1847
+ if (!(lost.live.ranks.has("sv-coverage-layer") && !lost.removed.has("sv-coverage-layer"))) lost.coveragePaint ??= paint;
1848
+ return;
1849
+ }
1850
+ this.placeStreetviewCoverage(paint);
1851
+ });
1852
+ }
1853
+ placeStreetviewCoverage(paint) {
1854
+ if (this.raw.getSource("sv-coverage") !== void 0) return;
1855
+ this.raw.addSource(STREETVIEW_COVERAGE_SOURCE, {
1856
+ tileSize: 256,
1857
+ tiles: [STREETVIEW_COVERAGE_TILES],
1858
+ type: "raster"
1859
+ });
1860
+ this.placeLayer({
1861
+ id: STREETVIEW_COVERAGE_LAYER,
1862
+ paint: {
1863
+ "raster-fade-duration": 0,
1864
+ "raster-opacity": .75,
1865
+ ...statedMembers(paint)
1866
+ },
1867
+ source: STREETVIEW_COVERAGE_SOURCE,
1868
+ type: "raster"
1869
+ }, 30);
1870
+ }
1871
+ async addDirections(input, options = {}) {
1872
+ return this.addAnalysis("directions", input, options);
1873
+ }
1874
+ async editDirections(id, patch, options = {}) {
1875
+ return this.editAnalysis("directions", id, patch, options);
1876
+ }
1877
+ removeDirections(id) {
1878
+ this.removeAnalysis(id);
1879
+ }
1880
+ clearDirections() {
1881
+ this.clearAnalysis("directions");
1882
+ }
1883
+ async addSuggestions(input, options = {}) {
1884
+ return this.addAnalysis("suggestions", input, options);
1885
+ }
1886
+ async editSuggestions(id, patch = {}, options = {}) {
1887
+ return this.editAnalysis("suggestions", id, patch, options);
1888
+ }
1889
+ removeSuggestions(id) {
1890
+ this.removeAnalysis(id);
1891
+ }
1892
+ clearSuggestions() {
1893
+ this.clearAnalysis("suggestions");
1894
+ }
1895
+ async addIsochrones(input, options = {}) {
1896
+ return this.addAnalysis("isochrones", input, options);
1897
+ }
1898
+ async editIsochrones(id, patch, options = {}) {
1899
+ return this.editAnalysis("isochrones", id, patch, options);
1900
+ }
1901
+ removeIsochrones(id) {
1902
+ this.removeAnalysis(id);
1903
+ }
1904
+ clearIsochrones() {
1905
+ this.clearAnalysis("isochrones");
1906
+ }
1907
+ async addPlaces(input, options = {}) {
1908
+ return this.addAnalysis("places", input, options);
1909
+ }
1910
+ async editPlaces(id, patch, options = {}) {
1911
+ return this.editAnalysis("places", id, patch, options);
1912
+ }
1913
+ removePlaces(id) {
1914
+ this.removeAnalysis(id);
1915
+ }
1916
+ clearPlaces() {
1917
+ this.clearAnalysis("places");
1918
+ }
1919
+ async addMatrix(input, options = {}) {
1920
+ if (!this.destroyed && isAnalysisResult("matrix", input)) throw new require_errors.MountayaElementsError("addMatrix: a matrix is drawn between the locations of its input, and a result holds none. Pass the input, with the result you hold as `options.result`.");
1921
+ const { result, ...draw } = options;
1922
+ return this.addAnalysis("matrix", input, draw, void 0, result);
1923
+ }
1924
+ async editMatrix(id, patch, options = {}) {
1925
+ return this.editAnalysis("matrix", id, patch, options);
1926
+ }
1927
+ removeMatrix(id) {
1928
+ this.removeAnalysis(id);
1929
+ }
1930
+ clearMatrix() {
1931
+ this.clearAnalysis("matrix");
1932
+ }
1933
+ async setPointsOfInterest(input, options = {}) {
1934
+ return (await this.addAnalysis("pois", input, options, POI_QUERY_SLOT)).result;
1935
+ }
1936
+ async editPointsOfInterest(patch, options = {}) {
1937
+ return this.editAnalysis("pois", POI_QUERY_SLOT, patch, options);
1938
+ }
1939
+ clearPointsOfInterest() {
1940
+ this.removeAnalysis(POI_QUERY_SLOT);
1941
+ }
1942
+ setPreview(geometry, options = {}) {
1943
+ if (this.destroyed) return;
1944
+ this.writeGeometrySlot({
1945
+ change: "set",
1946
+ color: options.color,
1947
+ geometry,
1948
+ slot: slots.PREVIEW
1949
+ });
1950
+ }
1951
+ editPreview(patch) {
1952
+ if (this.destroyed) return;
1953
+ this.writeGeometrySlot({
1954
+ change: "edit",
1955
+ color: patch.color,
1956
+ geometry: patch.geometry ?? void 0,
1957
+ slot: slots.PREVIEW
1958
+ });
1959
+ }
1960
+ clearPreview() {
1961
+ if (this.destroyed) return;
1962
+ this.writeGeometrySlot({
1963
+ change: "clear",
1964
+ slot: slots.PREVIEW
1965
+ });
1966
+ }
1967
+ setHighlight(feature, options = {}) {
1968
+ if (this.destroyed) return;
1969
+ this.writeGeometrySlot({
1970
+ change: "set",
1971
+ color: options.color,
1972
+ geometry: feature?.geometry ?? null,
1973
+ slot: slots.HIGHLIGHT
1974
+ });
1975
+ }
1976
+ editHighlight(patch) {
1977
+ if (this.destroyed) return;
1978
+ this.writeGeometrySlot({
1979
+ change: "edit",
1980
+ color: patch.color,
1981
+ geometry: patch.feature?.geometry,
1982
+ slot: slots.HIGHLIGHT
1983
+ });
1984
+ }
1985
+ clearHighlight() {
1986
+ if (this.destroyed) return;
1987
+ this.writeGeometrySlot({
1988
+ change: "clear",
1989
+ slot: slots.HIGHLIGHT
1990
+ });
1991
+ }
1992
+ setSearchHighlight(payload) {
1993
+ if (this.destroyed) return;
1994
+ this.searchHighlightAsked += 1;
1995
+ const asked = this.searchHighlightAsked;
1996
+ if (payload === null) {
1997
+ this.unmount(slots.SEARCH_HIGHLIGHT);
1998
+ return;
1999
+ }
2000
+ Promise.all([Promise.resolve().then(() => require("./chunk-BfzQb0EK.cjs")), Promise.resolve().then(() => require("./chunk-DrudttCC.cjs"))]).then(([{ searchHighlightLayers, searchHighlightStyle }, { accentHexAt }]) => {
2001
+ if (this.destroyed || asked !== this.searchHighlightAsked) return;
2002
+ const { data, layers, rank, sourceId } = searchHighlightLayers(payload, {
2003
+ accent: accentHexAt(this.raw.getContainer()),
2004
+ hasPointGlyph: this.icons.has(searchHighlightStyle.placeGlyph)
2005
+ });
2006
+ this.drawGeoJsonSlot(slots.SEARCH_HIGHLIGHT, {
2007
+ data,
2008
+ kind: "geojson",
2009
+ layers,
2010
+ rank,
2011
+ sourceId
2012
+ });
2013
+ }).catch((error) => {
2014
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.searchHighlight) });
2015
+ });
2016
+ }
2017
+ setEmphasis(feature, options = {}) {
2018
+ if (this.destroyed) return;
2019
+ this.writeGeometrySlot({
2020
+ change: "set",
2021
+ color: options.color,
2022
+ geometry: feature?.geometry ?? null,
2023
+ slot: slots.EMPHASIS
2024
+ });
2025
+ }
2026
+ clearEmphasis() {
2027
+ if (this.destroyed) return;
2028
+ this.writeGeometrySlot({
2029
+ change: "clear",
2030
+ slot: slots.EMPHASIS
2031
+ });
2032
+ }
2033
+ getGeometry(slot) {
2034
+ const { color, geometry } = this.geometrySlots[readGeometrySlot(slot, "getGeometry")];
2035
+ return {
2036
+ color,
2037
+ geometry
2038
+ };
2039
+ }
2040
+ addMarker(marker) {
2041
+ if (this.destroyed) return;
2042
+ const pinned = markersAdded(this.pinned, marker);
2043
+ this.pinMarker(pinned, marker.id, false);
2044
+ }
2045
+ pinMarker(pinned, id, keepsPlace) {
2046
+ const entry = pinned.find((held) => held.marker.id === id);
2047
+ if (entry === void 0) return;
2048
+ const { lngLat, marker } = entry;
2049
+ const element = this.markerElement(marker);
2050
+ const instance = new maplibre_gl.Marker({ element }).setLngLat([...lngLat]).addTo(this.raw);
2051
+ if (marker.label !== void 0) instance.setPopup(new maplibre_gl.Popup({ offset: 24 }).setText(marker.label));
2052
+ const replaced = this.markers.get(id);
2053
+ if (replaced !== void 0) {
2054
+ if (keepsPlace) replaced.getElement().replaceWith(element);
2055
+ replaced.remove();
2056
+ }
2057
+ this.markers.set(id, instance);
2058
+ this.pinned = pinned;
2059
+ }
2060
+ editMarker(id, patch) {
2061
+ if (this.destroyed) return;
2062
+ this.pinMarker(markersEdited(this.pinned, id, patch), id, true);
2063
+ }
2064
+ removeMarker(id) {
2065
+ if (this.destroyed) return;
2066
+ this.markers.get(id)?.remove();
2067
+ this.markers.delete(id);
2068
+ this.pinned = markersRemoved(this.pinned, id);
2069
+ }
2070
+ clearMarkers() {
2071
+ if (this.destroyed) return;
2072
+ this.dropMarkers();
2073
+ }
2074
+ getCamera() {
2075
+ const center = this.raw.getCenter();
2076
+ return {
2077
+ bearing: this.raw.getBearing(),
2078
+ center: [center.lng, center.lat],
2079
+ pitch: this.raw.getPitch(),
2080
+ zoom: this.raw.getZoom()
2081
+ };
2082
+ }
2083
+ getZoomLimits() {
2084
+ return {
2085
+ max: this.raw.getMaxZoom(),
2086
+ min: this.raw.getMinZoom()
2087
+ };
2088
+ }
2089
+ jumpTo(pose) {
2090
+ if (this.destroyed) return;
2091
+ this.raw.jumpTo(require_slotNames.readCameraPose(pose, "jumpTo"));
2092
+ }
2093
+ flyTo(pose) {
2094
+ if (this.destroyed) return;
2095
+ this.raw.flyTo(require_slotNames.readCameraPose(pose, "flyTo"));
2096
+ }
2097
+ easeTo(pose) {
2098
+ if (this.destroyed) return;
2099
+ this.raw.easeTo(require_slotNames.readCameraPose(pose, "easeTo"));
2100
+ }
2101
+ fitBounds(bounds, options = {}) {
2102
+ if (this.destroyed) return;
2103
+ const { duration, ...fit } = require_slotNames.readFitBoundsOptions(options, "fitBounds");
2104
+ const camera = require_slotNames.fitCameraOn(this.raw, readFitBox(bounds, "fitBounds"), {
2105
+ ...fit,
2106
+ window: this.getZoomLimits()
2107
+ });
2108
+ if (camera !== null) this.raw.flyTo(duration === void 0 ? camera : {
2109
+ ...camera,
2110
+ duration
2111
+ });
2112
+ }
2113
+ easeIntoZoomRange(target) {
2114
+ if (this.destroyed) return;
2115
+ const range = "sources" in target ? require_geoJson.paintZoomRange(target.sources) : target;
2116
+ const zoom = range === null ? null : require_geoJson.zoomIntoRange(this.raw.getZoom(), range);
2117
+ if (zoom !== null) this.raw.easeTo({
2118
+ duration: 250,
2119
+ zoom
2120
+ });
2121
+ }
2122
+ zoomIn() {
2123
+ this.controlMove("zoom-in");
2124
+ }
2125
+ zoomOut() {
2126
+ this.controlMove("zoom-out");
2127
+ }
2128
+ resetNorth() {
2129
+ this.controlMove("reset-north");
2130
+ }
2131
+ setConstraints(constraints) {
2132
+ if (this.destroyed) return;
2133
+ const held = this.getZoomLimits();
2134
+ const zoom = require_slotNames.readZoomLimits(constraints.zoom, held, "setConstraints");
2135
+ const lock = constraints.maxBounds == null ? constraints.maxBounds : readMaxBounds(constraints.maxBounds);
2136
+ const { moved, window } = require_slotNames.zoomWindowAfter(held, zoom);
2137
+ this.applyConstraints(zoom, lock);
2138
+ if (moved) this.emit("zoomlimitschange", window);
2139
+ }
2140
+ setLanguage(language) {
2141
+ if (this.destroyed) return;
2142
+ this.language = require_language$1.clampMapLanguage(language);
2143
+ this.applyLanguage();
2144
+ }
2145
+ getLanguage() {
2146
+ return this.language;
2147
+ }
2148
+ async loadOrganization() {
2149
+ if (this.destroyed) {
2150
+ if (this.organization === null) throw organizationClosedError();
2151
+ return this.organization;
2152
+ }
2153
+ const publishableKey = this.client.transport.mapCredential.publishableKey;
2154
+ if (publishableKey === void 0 || publishableKey === "") throw new require_errors.MountayaElementsError("loadOrganization: the map's client holds no publishable key, so the map reads no organization; build the client with a publishable key to read one.");
2155
+ const organization = await require_language.OrganizationReadEngine.shared.read(this.client, publishableKey);
2156
+ if (this.destroyed) throw organizationClosedError();
2157
+ this.organization = organization;
2158
+ return organization;
2159
+ }
2160
+ getOrganization() {
2161
+ return this.organization;
2162
+ }
2163
+ project(lngLat) {
2164
+ if (this.destroyed) return [NaN, NaN];
2165
+ const point = this.raw.project(lngLat);
2166
+ return [point.x, point.y];
2167
+ }
2168
+ unproject(point) {
2169
+ if (this.destroyed) return [NaN, NaN];
2170
+ const lngLat = this.raw.unproject(point);
2171
+ return [lngLat.lng, lngLat.lat];
2172
+ }
2173
+ featuresAt(point) {
2174
+ return this.queryAt("features", point);
2175
+ }
2176
+ poisAt(point) {
2177
+ return this.queryAt("pois", point);
2178
+ }
2179
+ zonesAt(point) {
2180
+ return this.queryAt("zones", point);
2181
+ }
2182
+ itinerariesAt(point) {
2183
+ return this.queryAt("itineraries", point);
2184
+ }
2185
+ async elevationAt(lngLat) {
2186
+ return (await this.client.data.terrainSamples({ locations: [[...lngLat]] }, { select: { samples: { elevation: true } } })).samples[0]?.elevation ?? null;
2187
+ }
2188
+ async search(input, options = {}) {
2189
+ return this.client.data.search(input, { signal: options.signal });
2190
+ }
2191
+ async locate(options = {}) {
2192
+ if (this.destroyed) throw new require_errors.MountayaElementsError("Geolocation is unavailable: the map is destroyed.");
2193
+ const fix = await this.geolocation.locate(options);
2194
+ if (!fix.ok) throw new require_errors.MountayaElementsError(`Geolocation is unavailable: ${fix.reason}.`);
2195
+ const radius = Number.isFinite(fix.accuracyMeters) ? Math.max(fix.accuracyMeters, 0) : 0;
2196
+ this.fitBounds(require_camera.accuracyBounds(fix.position, radius), { maxZoom: 16 });
2197
+ return fix.position;
2198
+ }
2199
+ setLayerVisibility(layerId, visible) {
2200
+ if (this.destroyed) return;
2201
+ if (this.writeLayerVisibility(layerId, visible)) this.reportDisplayChange();
2202
+ }
2203
+ isLayerVisible(layerId) {
2204
+ return !this.hiddenLayerIds.has(layerId);
2205
+ }
2206
+ drawnLayerKeys(rank) {
2207
+ return this.displayAnswer(`keys:${rank ?? ""}`, () => drawnKeys(this.drawnSpecifications(), this.paint.layerRanks, rank));
2208
+ }
2209
+ layerIdsForKey(key) {
2210
+ return this.displayAnswer(`ids:${key}`, () => keyLayerIds(this.drawnSpecifications(), key));
2211
+ }
2212
+ drawnSpecifications() {
2213
+ return [...this.requests.askedContent()].flatMap((desired) => desired.kind === "tiles" ? [desired.specification] : []);
2214
+ }
2215
+ setKeyVisibility(key, visible) {
2216
+ if (this.destroyed) return;
2217
+ let changed = false;
2218
+ for (const id of this.layerIdsForKey(key)) changed = this.writeLayerVisibility(id, visible) || changed;
2219
+ if (changed) this.reportDisplayChange();
2220
+ }
2221
+ isKeyVisible(key) {
2222
+ return this.layerIdsForKey(key).every((id) => this.isLayerVisible(id));
2223
+ }
2224
+ setAccessRestrictionsVisibility(visible) {
2225
+ if (this.destroyed || this.accessRestrictionsVisible === visible) return;
2226
+ this.accessRestrictionsVisible = visible;
2227
+ const ids = this.drawnSpecifications().flatMap((specification) => specification.sources.flatMap((source) => require_roadAccessLine.roadAccessLayersOf(source).map(({ layer }) => layer.id)));
2228
+ this.eventEngine.afterStyleLoad(() => {
2229
+ for (const id of ids) this.applyVisibility(id, visible && !this.hiddenLayerIds.has(id) ? "visible" : "none");
2230
+ });
2231
+ }
2232
+ isAccessRestrictionsVisible() {
2233
+ return this.accessRestrictionsVisible;
2234
+ }
2235
+ loadLayers() {
2236
+ if (this.destroyed) return this.resolvedManifest === void 0 ? Promise.reject(new require_errors.MountayaElementsError("loadLayers: the map is destroyed and holds no layers manifest, and a destroyed map reads none. Read it through the client with client.tiles.getTileLayers.")) : Promise.resolve(this.resolvedManifest);
2237
+ if (this.manifest !== null) return this.manifest;
2238
+ const organization = this.layersOrganization;
2239
+ const read = this.client.tiles.getTileLayers(organization === null ? {} : { query: { organization_id: organization } }).then((envelope) => {
2240
+ if (this.manifest !== read) return this.loadLayers();
2241
+ const layers = unwrap(envelope, "layers manifest");
2242
+ this.resolvedManifest = layers;
2243
+ this.emit("layerschange", void 0);
2244
+ return layers;
2245
+ }, (error) => {
2246
+ if (this.manifest !== read) return this.loadLayers();
2247
+ throw error;
2248
+ });
2249
+ this.manifest = read;
2250
+ read.catch(() => {
2251
+ if (this.manifest === read) this.manifest = null;
2252
+ });
2253
+ return read;
2254
+ }
2255
+ getLayers() {
2256
+ return this.resolvedManifest;
2257
+ }
2258
+ setLayersOrganization(organizationId) {
2259
+ if (this.destroyed) return;
2260
+ const next = organizationId === "" ? null : organizationId;
2261
+ if (next === this.layersOrganization) return;
2262
+ this.layersOrganization = next;
2263
+ const held = this.resolvedManifest !== void 0;
2264
+ this.manifest = null;
2265
+ this.resolvedManifest = void 0;
2266
+ if (held) this.emit("layerschange", void 0);
2267
+ }
2268
+ isAccessRequired() {
2269
+ return this.refusals.size > 0;
2270
+ }
2271
+ async whenReady() {
2272
+ if (this.destroyed || this.raw.isStyleLoaded()) return;
2273
+ await this.whenStyleLoaded();
2274
+ }
2275
+ on(event, handler) {
2276
+ if (this.destroyed) return () => {};
2277
+ let set = this.listeners.get(event);
2278
+ if (set === void 0) {
2279
+ set = /* @__PURE__ */ new Set();
2280
+ this.listeners.set(event, set);
2281
+ }
2282
+ const erased = handler;
2283
+ set.add(erased);
2284
+ return () => {
2285
+ set.delete(erased);
2286
+ };
2287
+ }
2288
+ destroy() {
2289
+ if (this.destroyed) return;
2290
+ this.destroyed = true;
2291
+ this.requests.abandon();
2292
+ this.pendingLayers.clear();
2293
+ this.carriedLayers.clear();
2294
+ this.baseMapRequestCount += 1;
2295
+ this.cancelFeatureHover();
2296
+ this.dropMarkers();
2297
+ this.listeners.clear();
2298
+ this.eventEngine.dispose();
2299
+ this.raw.remove();
2300
+ for (const settle of [...this.styleWaits]) settle();
2301
+ this.baseMap.destroy();
2302
+ this.requests.settleSuperseded();
2303
+ }
2304
+ buildTransformRequest(options) {
2305
+ const transport = options.client.transport;
2306
+ if (options.credential !== void 0) assertMapCredential(options.credential, "credential.", "new MountayaMap");
2307
+ const credential = options.credential ?? {
2308
+ ...transport.mapCredential,
2309
+ sessionToken: () => transport.mapCredential.sessionToken
2310
+ };
2311
+ let claim;
2312
+ try {
2313
+ claim = createTransformRequest({
2314
+ ...credential,
2315
+ language: transport.requestLanguage ?? "*",
2316
+ origins: [transport.tilesBaseUrl]
2317
+ });
2318
+ } catch (cause) {
2319
+ const stated = transport.tilesBaseUrl;
2320
+ const quoted = typeof stated === "string" && stated.includes("@") ? "holds an \"@\" and is not quoted, since a password may stand before it" : `is ${require_errors.printValue(stated)}`;
2321
+ throw new require_errors.MountayaElementsError(`new MountayaMap: the client's Tile API address (client.transport.tilesBaseUrl) ${quoted}, which names no place a request can be matched against, so the map cannot tell which requests carry the credential. Build the client with a \`baseUrls.tiles\` that is an http or https URL, or a path of the page's own origin, or hand the map a \`transformRequest\` of your own.`, { cause });
2322
+ }
2323
+ this.sentCredentials = new SentCredentialsEngine(claim);
2324
+ return this.sentCredentials.transform;
2325
+ }
2326
+ bindMapEvents() {
2327
+ this.eventEngine.on("click", (event) => {
2328
+ this.onceDispatched(event, () => {
2329
+ const lngLat = pointerLngLat(event);
2330
+ const point = [event.point.x, event.point.y];
2331
+ this.emit("click", {
2332
+ lngLat,
2333
+ point
2334
+ });
2335
+ if (!this.listening("featureclick")) return;
2336
+ const features = this.featuresAt(point);
2337
+ if (features.length > 0) this.emit("featureclick", {
2338
+ features,
2339
+ lngLat
2340
+ });
2341
+ });
2342
+ });
2343
+ this.eventEngine.on("contextmenu", (event) => {
2344
+ this.onceDispatched(event, () => {
2345
+ this.emit("contextmenu", {
2346
+ lngLat: pointerLngLat(event),
2347
+ point: [event.point.x, event.point.y]
2348
+ });
2349
+ });
2350
+ });
2351
+ this.eventEngine.on("mousemove", (event) => {
2352
+ if (!this.listening("featurehover")) return;
2353
+ this.hoverPosition = {
2354
+ lngLat: pointerLngLat(event),
2355
+ point: [event.point.x, event.point.y]
2356
+ };
2357
+ if (this.hoverFrame === null) this.hoverFrame = requestAnimationFrame(() => {
2358
+ this.hoverFrame = null;
2359
+ this.reportFeatureHover();
2360
+ });
2361
+ });
2362
+ this.eventEngine.on("mouseout", (event) => {
2363
+ this.cancelFeatureHover();
2364
+ if (this.listening("featurehover")) this.emit("featurehover", {
2365
+ features: [],
2366
+ lngLat: pointerLngLat(event)
2367
+ });
2368
+ });
2369
+ this.eventEngine.on("move", () => {
2370
+ this.emit("move", this.getCamera());
2371
+ });
2372
+ this.eventEngine.on("moveend", () => {
2373
+ this.emit("moveend", this.getCamera());
2374
+ });
2375
+ this.baseMap.bindStyleEvents();
2376
+ this.eventEngine.on("error", (event) => {
2377
+ this.baseMap.noteError();
2378
+ const error = event.error;
2379
+ const status = require_slotNames.accessRefusalStatus(error);
2380
+ if (status !== null) {
2381
+ const url = require_slotNames.accessRefusalUrl(error);
2382
+ const superseded = this.sentCredentials?.isSuperseded(url) ?? false;
2383
+ if (!this.refusalHeard(status, url, require_slotNames.accessRefusalSource(event), superseded)) {
2384
+ require_slotNames.tellNobodyOf(error);
2385
+ const asked = this.sentCredentials?.askedFor(url);
2386
+ if (asked !== void 0) this.baseMap.askAgain(asked);
2387
+ }
2388
+ return;
2389
+ }
2390
+ this.emit("error", { error: error === void 0 ? /* @__PURE__ */ new Error("The map reported an error.") : require_errors.errorFrom(error, unawaitedFailures.renderer) });
2391
+ });
2392
+ this.eventEngine.on("sourcedata", (event) => {
2393
+ if (event.tile !== void 0) this.answerAccess({
2394
+ kind: "tile",
2395
+ source: event.sourceId
2396
+ });
2397
+ });
2398
+ this.eventEngine.on("style.load", () => {
2399
+ this.answerAccess({ kind: "style" });
2400
+ });
2401
+ this.baseMap.bindContextEvents();
2402
+ this.eventEngine.on("load", () => {
2403
+ warnOnMissingStylesheet(this.raw.getCanvas());
2404
+ if (this.container !== null) warnOnCollapsedContainer(this.container);
2405
+ });
2406
+ }
2407
+ onceDispatched(event, report) {
2408
+ queueMicrotask(() => {
2409
+ if (!event.defaultPrevented && !this.destroyed) report();
2410
+ });
2411
+ }
2412
+ reportFeatureHover() {
2413
+ const position = this.hoverPosition;
2414
+ this.hoverPosition = null;
2415
+ if (position === null || !this.listening("featurehover")) return;
2416
+ this.emit("featurehover", {
2417
+ features: this.itinerariesAt(position.point),
2418
+ lngLat: position.lngLat
2419
+ });
2420
+ }
2421
+ refusalHeard(status, url, source, superseded) {
2422
+ if (require_slotNames.refusesSupersededCredential(status, superseded)) return false;
2423
+ this.answerAccess({
2424
+ kind: "refused",
2425
+ source
2426
+ });
2427
+ this.emit("accessrequired", {
2428
+ status,
2429
+ url
2430
+ });
2431
+ return true;
2432
+ }
2433
+ answerAccess(answer) {
2434
+ const { restored, standing } = require_slotNames.accessStandingAfter(this.refusals, answer, (id) => this.raw.getSource(id) !== void 0);
2435
+ this.refusals = standing;
2436
+ if (restored) this.emit("accessrestored", void 0);
2437
+ }
2438
+ cancelFeatureHover() {
2439
+ if (this.hoverFrame !== null) {
2440
+ cancelAnimationFrame(this.hoverFrame);
2441
+ this.hoverFrame = null;
2442
+ }
2443
+ this.hoverPosition = null;
2444
+ }
2445
+ reportBaseMapFailure(error) {
2446
+ const status = require_slotNames.accessRefusalStatus(error);
2447
+ if (status !== null) {
2448
+ this.refusalHeard(status, layersManifestAddress(this.client.transport.tilesBaseUrl), null, false);
2449
+ return;
2450
+ }
2451
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.baseMap) });
2452
+ }
2453
+ collapseCredits() {
2454
+ const close = () => {
2455
+ const credits = this.raw.getContainer().querySelector(`.${ATTRIBUTION_CONTROL_CLASS}`);
2456
+ if (credits === null || !credits.classList.contains(ATTRIBUTION_SHOWN_CLASS)) return false;
2457
+ credits.classList.remove(ATTRIBUTION_SHOWN_CLASS);
2458
+ return true;
2459
+ };
2460
+ if (close()) return;
2461
+ const releases = [];
2462
+ const closeOnce = () => {
2463
+ if (close()) for (const release of releases) release();
2464
+ };
2465
+ releases.push(this.eventEngine.on("styledata", closeOnce), this.eventEngine.on("sourcedata", closeOnce), this.eventEngine.on("terrain", closeOnce));
2466
+ }
2467
+ applyConstraints(zoom, lock) {
2468
+ if (zoom.ceilingFirst && zoom.max !== void 0) this.raw.setMaxZoom(zoom.max);
2469
+ if (zoom.min !== void 0) this.raw.setMinZoom(zoom.min);
2470
+ if (!zoom.ceilingFirst && zoom.max !== void 0) this.raw.setMaxZoom(zoom.max);
2471
+ if (lock !== void 0) this.raw.setMaxBounds(lock);
2472
+ }
2473
+ placeLayer(layer, rank) {
2474
+ const placement = placeRanked(this.raw.getLayersOrder(), this.layerRankById, layer.id, rank);
2475
+ if (placement === null) {
2476
+ if (this.hiddenLayerIds.has(layer.id)) this.applyVisibility(layer.id, "none");
2477
+ return false;
2478
+ }
2479
+ if (this.layerRankById.get(layer.id) !== rank) this.layerRankById.delete(layer.id);
2480
+ this.layerRankById.set(layer.id, rank);
2481
+ if (this.raw.getLayer(layer.id) === void 0) this.raw.addLayer(layer, placement.beforeId);
2482
+ else this.raw.moveLayer(layer.id, placement.beforeId);
2483
+ if (this.hiddenLayerIds.has(layer.id)) this.applyVisibility(layer.id, "none");
2484
+ return true;
2485
+ }
2486
+ placePendingLayers() {
2487
+ if (this.pendingLayers.size === 0) return;
2488
+ const waiting = [...this.pendingLayers.values()];
2489
+ this.pendingLayers.clear();
2490
+ let moved = false;
2491
+ for (const { edit, layer, rank } of waiting) try {
2492
+ moved = this.placeLayer(layer, rank) || moved;
2493
+ if (edit !== void 0) this.writeLayerPatch(layer.id, edit);
2494
+ } catch (error) {
2495
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.ownLayer) });
2496
+ }
2497
+ if (moved) this.reportDisplayChange();
2498
+ }
2499
+ ownLayersCarrier() {
2500
+ const carried = [...this.ownLayers.keys()].filter((id) => this.raw.getLayer(id) !== void 0 || this.carriedLayers.has(id));
2501
+ if (carried.length === 0) return;
2502
+ return (previous, next) => {
2503
+ const landed = carryOwnLayers(previous, next, {
2504
+ held: this.carriedLayers,
2505
+ mapSources: this.drawnSources(),
2506
+ own: new Set(carried.filter((id) => this.ownLayers.has(id)))
2507
+ });
2508
+ this.carriedLayers = new Map(landed.layers.map((layer) => [layer.id, layer]));
2509
+ return landed.style;
2510
+ };
2511
+ }
2512
+ drawnSources() {
2513
+ const slots = [...this.mounted.values(), ...this.baseMap.heldLive()?.mounted.values() ?? []];
2514
+ return /* @__PURE__ */ new Set([STREETVIEW_COVERAGE_SOURCE, ...slots.flatMap(({ sourceIds }) => sourceIds)]);
2515
+ }
2516
+ placeCarriedLayers() {
2517
+ const carried = [...this.carriedLayers.values()];
2518
+ this.carriedLayers = /* @__PURE__ */ new Map();
2519
+ for (const layer of carried) {
2520
+ const rank = this.ownLayers.get(layer.id);
2521
+ const source = "source" in layer ? layer.source : void 0;
2522
+ if (rank === void 0 || source !== void 0 && this.raw.getSource(source) === void 0) continue;
2523
+ try {
2524
+ this.placeLayer(layer, rank);
2525
+ } catch (error) {
2526
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.ownLayer) });
2527
+ }
2528
+ }
2529
+ }
2530
+ dropLayer(id) {
2531
+ const placed = this.raw.getLayer(id) !== void 0;
2532
+ if (placed) this.raw.removeLayer(id);
2533
+ const ranked = this.layerRankById.delete(id);
2534
+ const hidden = this.hiddenLayerIds.delete(id);
2535
+ return placed || ranked || hidden;
2536
+ }
2537
+ reportDisplayChange() {
2538
+ this.displayAnswers.clear();
2539
+ this.emit("displaychange", void 0);
2540
+ }
2541
+ displayAnswer(key, read) {
2542
+ const held = this.displayAnswers.get(key);
2543
+ if (held !== void 0) return held;
2544
+ const answer = Object.freeze(read());
2545
+ this.displayAnswers.set(key, answer);
2546
+ return answer;
2547
+ }
2548
+ writeLayerVisibility(layerId, visible) {
2549
+ const changed = this.hiddenLayerIds.has(layerId) === visible;
2550
+ if (visible) this.hiddenLayerIds.delete(layerId);
2551
+ else this.hiddenLayerIds.add(layerId);
2552
+ this.eventEngine.afterStyleLoad(() => {
2553
+ this.applyVisibility(layerId, visible ? "visible" : "none");
2554
+ });
2555
+ return changed;
2556
+ }
2557
+ writeLayerPatch(id, edit) {
2558
+ for (const property of patchedProperties(edit.paint)) this.raw.setPaintProperty(id, property, edit.paint[property]);
2559
+ for (const property of patchedProperties(edit.layout)) this.raw.setLayoutProperty(id, property, edit.layout[property]);
2560
+ }
2561
+ dropMarkers() {
2562
+ for (const marker of this.markers.values()) marker.remove();
2563
+ this.markers.clear();
2564
+ this.pinned = [];
2565
+ }
2566
+ listening(event) {
2567
+ const set = this.listeners.get(event);
2568
+ return set !== void 0 && set.size > 0;
2569
+ }
2570
+ emit(event, payload) {
2571
+ const set = this.listeners.get(event);
2572
+ if (set === void 0) return;
2573
+ require_listeners.notifyListeners(set, payload);
2574
+ }
2575
+ whenStyleLoaded() {
2576
+ if (this.destroyed) return Promise.resolve();
2577
+ return new Promise((resolve) => {
2578
+ const settle = () => {
2579
+ this.styleWaits.delete(settle);
2580
+ resolve();
2581
+ };
2582
+ this.styleWaits.add(settle);
2583
+ this.eventEngine.afterStyleLoad(settle);
2584
+ });
2585
+ }
2586
+ async whenStyleTakes(pending) {
2587
+ if (this.destroyed || this.raw.isStyleLoaded()) return true;
2588
+ const taken = await new Promise((resolve) => {
2589
+ pending.endWait = () => {
2590
+ resolve(false);
2591
+ };
2592
+ this.whenStyleLoaded().then(() => {
2593
+ resolve(true);
2594
+ });
2595
+ });
2596
+ pending.endWait = void 0;
2597
+ return taken;
2598
+ }
2599
+ hasNoStyleToWriteTo() {
2600
+ return !this.destroyed && this.eventEngine.isStyleReloading() && this.raw.isStyleLoaded() !== true;
2601
+ }
2602
+ async setSlot(slot, renderable, fetchById, signal, onDrawn) {
2603
+ if (this.destroyed) return false;
2604
+ signal?.throwIfAborted();
2605
+ if (renderable === null) {
2606
+ this.unmount(slot);
2607
+ return false;
2608
+ }
2609
+ const superseded = signal === void 0 ? void 0 : this.requests.supersede(slot);
2610
+ const withdrawable = signal !== void 0;
2611
+ const claim = typeof renderable === "string" ? this.requests.claim(slot, withdrawable) : this.requests.take(slot, withdrawable);
2612
+ const withdraw = () => {
2613
+ this.requests.giveBack(slot, claim.token, superseded);
2614
+ };
2615
+ signal?.addEventListener("abort", withdraw, { once: true });
2616
+ try {
2617
+ let specification = renderable;
2618
+ if (typeof specification === "string") {
2619
+ specification = await fetchById(specification, signal);
2620
+ signal?.throwIfAborted();
2621
+ if (!this.requests.owns(slot, claim.token) && (!this.requests.waitsToRegain(claim.token) || !await this.requests.regains(slot, claim.token))) {
2622
+ signal?.throwIfAborted();
2623
+ return false;
2624
+ }
2625
+ }
2626
+ const drawn = await this.mount(slot, {
2627
+ kind: "tiles",
2628
+ specification
2629
+ }, claim, () => {
2630
+ signal?.removeEventListener("abort", withdraw);
2631
+ onDrawn?.();
2632
+ });
2633
+ if (!drawn) signal?.throwIfAborted();
2634
+ return drawn;
2635
+ } finally {
2636
+ signal?.removeEventListener("abort", withdraw);
2637
+ this.requests.endSupersession(superseded);
2638
+ }
2639
+ }
2640
+ async itineraryBounds(id, signal) {
2641
+ const itinerary = unwrap(await this.client.studio.itineraries.getItinerary({ itinerary_id: id }, { signal }), "itinerary");
2642
+ const geometry = require_adapt.itineraryGeometry(itinerary);
2643
+ return geometry === null ? null : require_geometry.boundsOf([geometry]);
2644
+ }
2645
+ async toggleSlot(slot, on, fetchSpecification) {
2646
+ if (this.destroyed) return;
2647
+ if (!on) {
2648
+ this.unmount(slot);
2649
+ return;
2650
+ }
2651
+ if (this.requests.isAsked(slot)) return;
2652
+ const claim = this.requests.claim(slot);
2653
+ const specification = await fetchSpecification();
2654
+ if (!this.requests.owns(slot, claim.token)) return;
2655
+ await this.mount(slot, {
2656
+ kind: "tiles",
2657
+ specification
2658
+ }, claim);
2659
+ }
2660
+ reportSlotChange(before, after) {
2661
+ if ((before ?? after)?.kind === "tiles" && !sameContent(before, after)) this.reportDisplayChange();
2662
+ }
2663
+ async mount(slot, desired, claim = this.requests.take(slot), onDrawn) {
2664
+ const { before, token } = claim;
2665
+ const pending = this.requests.beginMount(slot, token, desired);
2666
+ this.reportSlotChange(before, desired);
2667
+ let taken = await this.whenStyleTakes(pending);
2668
+ while (!this.requests.owns(slot, token) || this.hasNoStyleToWriteTo() || !taken) {
2669
+ if (!this.requests.owns(slot, token) && (!this.requests.waitsToRegain(token) || !await this.requests.regains(slot, token))) return false;
2670
+ taken = await this.whenStyleTakes(pending);
2671
+ }
2672
+ this.requests.endMount(slot);
2673
+ if (desired.kind === "tiles") this.unmount(slot, { keepDesired: true });
2674
+ this.mounted.set(slot, this.draw(desired, this.liveOf(slot)));
2675
+ onDrawn?.();
2676
+ if (desired.kind === "tiles" && desired.onMounted !== void 0) await desired.onMounted(this.mountedSpecification(slot, desired));
2677
+ return true;
2678
+ }
2679
+ mountedSpecification(slot, desired) {
2680
+ const live = this.mounted.get(slot);
2681
+ return {
2682
+ layerIds: live?.layerIds ?? [],
2683
+ sourceIds: live?.sourceIds ?? [],
2684
+ specification: desired.specification
2685
+ };
2686
+ }
2687
+ draw(desired, live) {
2688
+ return desired.kind === "tiles" ? {
2689
+ ...this.applyRanked(this.stampedSpecification(desired)),
2690
+ drawn: desired
2691
+ } : this.applyGeoJson(desired, live);
2692
+ }
2693
+ stampedSpecification(desired) {
2694
+ if (desired.overlay === void 0 || this.instant === null) return desired.specification;
2695
+ const stamped = new Map(require_geoJson.stampedSources(desired.overlay, this.instant).map(({ sourceId, tiles }) => [sourceId, tiles]));
2696
+ if (stamped.size === 0) return desired.specification;
2697
+ return { sources: desired.specification.sources.map((source) => {
2698
+ const tiles = stamped.get(source.id);
2699
+ return tiles === void 0 ? source : {
2700
+ ...source,
2701
+ tiles
2702
+ };
2703
+ }) };
2704
+ }
2705
+ applyRanked(specification) {
2706
+ const drawn = require_language.applySpecification(this.raw, specification, {
2707
+ anchorFor: (layer) => {
2708
+ const rank = require_order.rankForTileLayer(layer, this.paint.layerRanks);
2709
+ const anchor = beforeIdForRank(this.raw, this.layerRankById, rank);
2710
+ this.layerRankById.set(layer.id, rank);
2711
+ return anchor;
2712
+ },
2713
+ hidden: this.hiddenLayerIds
2714
+ });
2715
+ const layerIds = [...drawn.layerIds];
2716
+ for (const source of specification.sources) for (const { layer, rank } of require_roadAccessLine.roadAccessLayersOf(source, {
2717
+ hidden: this.hiddenLayerIds,
2718
+ visible: this.accessRestrictionsVisible
2719
+ })) {
2720
+ if (this.raw.getLayer(layer.id) === void 0) {
2721
+ const anchor = beforeIdForRank(this.raw, this.layerRankById, rank);
2722
+ this.raw.addLayer(layer, anchor);
2723
+ }
2724
+ this.layerRankById.set(layer.id, rank);
2725
+ layerIds.push(layer.id);
2726
+ }
2727
+ return {
2728
+ layerIds,
2729
+ sourceIds: drawn.sourceIds
2730
+ };
2731
+ }
2732
+ applyGeoJson(desired, live) {
2733
+ const drawn = live?.drawn.kind === "geojson" ? live.drawn : void 0;
2734
+ const source = this.raw.getSource(desired.sourceId);
2735
+ if (source === void 0) this.raw.addSource(desired.sourceId, {
2736
+ data: desired.data,
2737
+ type: "geojson"
2738
+ });
2739
+ else if (drawn?.data !== desired.data) source.setData(desired.data);
2740
+ const layerIds = [];
2741
+ for (const spec of desired.layers) {
2742
+ const before = drawn?.layers.find((layer) => layer.id === spec.id);
2743
+ const placed = this.raw.getLayer(spec.id) !== void 0;
2744
+ if (placed && before !== void 0 && sameButPaint(before, spec)) this.repaint(spec, before);
2745
+ else {
2746
+ if (placed) this.raw.removeLayer(spec.id);
2747
+ this.layerRankById.delete(spec.id);
2748
+ this.raw.addLayer(spec, beforeIdForRank(this.raw, this.layerRankById, desired.rank));
2749
+ if (this.hiddenLayerIds.has(spec.id)) this.applyVisibility(spec.id, "none");
2750
+ }
2751
+ this.layerRankById.set(spec.id, desired.rank);
2752
+ layerIds.push(spec.id);
2753
+ }
2754
+ for (const id of live?.layerIds ?? []) if (!layerIds.includes(id)) {
2755
+ if (this.raw.getLayer(id) !== void 0) this.raw.removeLayer(id);
2756
+ this.layerRankById.delete(id);
2757
+ }
2758
+ return {
2759
+ drawn: desired,
2760
+ layerIds,
2761
+ sourceIds: [desired.sourceId]
2762
+ };
2763
+ }
2764
+ repaint(next, before) {
2765
+ const paint = paintOf(next);
2766
+ const painted = paintOf(before);
2767
+ for (const property of paintProperties(paint)) if (!sameValue(painted[property], paint[property])) this.raw.setPaintProperty(next.id, property, paint[property]);
2768
+ for (const property of paintProperties(painted)) if (!(property in paint)) this.raw.setPaintProperty(next.id, property, void 0);
2769
+ }
2770
+ unmount(slot, options = {}) {
2771
+ if (this.destroyed) return;
2772
+ if (options.keepDesired !== true) {
2773
+ this.requests.release(slot);
2774
+ this.requests.pending(slot)?.endWait?.();
2775
+ this.requests.endMount(slot);
2776
+ this.requests.endSupersessions(slot);
2777
+ }
2778
+ for (const live of [this.mounted.get(slot), this.baseMap.heldLive()?.mounted.get(slot)]) {
2779
+ if (live === void 0) continue;
2780
+ require_language.removeSpecification(this.raw, live);
2781
+ for (const id of live.layerIds) {
2782
+ this.layerRankById.delete(id);
2783
+ if (options.keepDesired !== true) this.hiddenLayerIds.delete(id);
2784
+ }
2785
+ }
2786
+ this.mounted.delete(slot);
2787
+ if (options.keepDesired !== true) {
2788
+ const cleared = this.requests.asked(slot);
2789
+ this.requests.forget(slot);
2790
+ this.reportSlotChange(cleared, void 0);
2791
+ }
2792
+ }
2793
+ async addAnalysis(kind, input, options, slot, answered) {
2794
+ if (!this.destroyed) require_slotNames.readFit(options.fit, `${analysisMethods[kind].add}({ fit })`);
2795
+ return this.drawAnswer(kind, input, options, slot ?? `${analysisSlotPrefix(kind)}${this.analysisSeq++}`, answered);
2796
+ }
2797
+ async drawAnswer(kind, input, options, slot, answered) {
2798
+ const token = this.destroyed ? void 0 : this.requests.claim(slot).token;
2799
+ let query;
2800
+ let result;
2801
+ if (isAnalysisResult(kind, input)) result = input;
2802
+ else {
2803
+ query = input;
2804
+ result = answered ?? await this.runAnalysis(kind, slot, input);
2805
+ }
2806
+ if (token === void 0 || !this.requests.owns(slot, token)) return {
2807
+ id: slot,
2808
+ result
2809
+ };
2810
+ this.analyses.set(slot, {
2811
+ input: query,
2812
+ kind,
2813
+ options,
2814
+ result
2815
+ });
2816
+ await this.drawAnalysis(kind, slot, result, query, options, token);
2817
+ return {
2818
+ id: slot,
2819
+ result
2820
+ };
2821
+ }
2822
+ async editAnalysis(kind, id, patch, options) {
2823
+ const held = heldAnalysisOf(this.analyses, kind, id);
2824
+ if (!this.destroyed) require_slotNames.readFit(options.fit, `${analysisMethods[kind].edit}({ fit })`);
2825
+ const edit = analysisEditOf(held, id, patch, options);
2826
+ const { restyle } = edit;
2827
+ if (edit.input === void 0) {
2828
+ if (this.destroyed) return held.result;
2829
+ this.analyses.set(id, {
2830
+ ...held,
2831
+ options: edit.options
2832
+ });
2833
+ await this.drawAnalysis(kind, id, held.result, held.input, edit.options, this.requests.tokenOf(id));
2834
+ return held.result;
2835
+ }
2836
+ const withdrawsWaitingDraw = this.requests.pending(id) !== void 0;
2837
+ const token = this.destroyed ? void 0 : this.requests.claim(id).token;
2838
+ const { input } = edit;
2839
+ let result;
2840
+ try {
2841
+ result = await this.runAnalysis(kind, id, input);
2842
+ } catch (cause) {
2843
+ const kept = this.analyses.get(id);
2844
+ if (withdrawsWaitingDraw && token !== void 0 && this.requests.owns(id, token) && kept) this.drawAnalysis(kind, id, held.result, held.input, kept.options, token).catch((error) => {
2845
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.redraw) });
2846
+ });
2847
+ throw cause;
2848
+ }
2849
+ if (token === void 0 || !this.requests.owns(id, token)) return result;
2850
+ const restyled = {
2851
+ ...this.analyses.get(id)?.options ?? held.options,
2852
+ ...restyle
2853
+ };
2854
+ this.analyses.set(id, {
2855
+ input,
2856
+ kind,
2857
+ options: restyled,
2858
+ result
2859
+ });
2860
+ await this.drawAnalysis(kind, id, result, input, restyled, token);
2861
+ return result;
2862
+ }
2863
+ async runAnalysis(kind, slot, input) {
2864
+ this.analysisAborts.get(slot)?.abort();
2865
+ const controller = new AbortController();
2866
+ this.analysisAborts.set(slot, controller);
2867
+ try {
2868
+ const run = analysisOperations[kind];
2869
+ return await run(this.client, input, controller.signal);
2870
+ } finally {
2871
+ if (this.analysisAborts.get(slot) === controller) this.analysisAborts.delete(slot);
2872
+ }
2873
+ }
2874
+ async drawAnalysis(kind, slot, result, input, options, token) {
2875
+ const spec = analysisSpecs[kind];
2876
+ const sourceId = `mountaya-${slot}`;
2877
+ const data = spec.toGeoJson(result, input, options.chosen ?? 0);
2878
+ if (!await this.mount(slot, {
2879
+ data,
2880
+ kind: "geojson",
2881
+ layers: spec.layers(sourceId, this.paint),
2882
+ rank: spec.rank,
2883
+ sourceId
2884
+ }, token === void 0 ? void 0 : {
2885
+ before: this.requests.asked(slot),
2886
+ token
2887
+ })) return;
2888
+ if (options.fit === true || options.fit !== void 0 && options.fit !== false) {
2889
+ const bounds = require_geometry.boundsOf(data.features.map((feature) => feature.geometry));
2890
+ if (bounds !== null) this.fitBounds(bounds, options.fit === true ? {} : options.fit);
2891
+ }
2892
+ }
2893
+ removeAnalysis(id) {
2894
+ if (this.destroyed) return;
2895
+ this.analysisAborts.get(id)?.abort();
2896
+ this.analysisAborts.delete(id);
2897
+ this.analyses.delete(id);
2898
+ this.unmount(id);
2899
+ }
2900
+ clearAnalysis(kind) {
2901
+ const slots = [...this.analyses.keys(), ...this.requests.requestedSlots()];
2902
+ for (const slot of analysisSlotsOfKind(kind, slots, this.analyses)) this.removeAnalysis(slot);
2903
+ }
2904
+ async replay() {
2905
+ const drawn = /* @__PURE__ */ new Set();
2906
+ for (const [slot, desired] of this.requests.entries()) {
2907
+ if (this.mounted.get(slot)?.drawn === desired) continue;
2908
+ this.mounted.set(slot, this.draw(desired, this.mounted.get(slot)));
2909
+ this.requests.endMount(slot);
2910
+ drawn.add(slot);
2911
+ }
2912
+ this.placeCarriedLayers();
2913
+ for (const layerId of this.hiddenLayerIds) this.applyVisibility(layerId, "none");
2914
+ for (const [slot, desired] of this.requests.entries()) {
2915
+ if (!drawn.has(slot) || desired.kind !== "tiles" || desired.onMounted === void 0) continue;
2916
+ try {
2917
+ await desired.onMounted(this.mountedSpecification(slot, desired));
2918
+ } catch (error) {
2919
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.onMounted) });
2920
+ }
2921
+ }
2922
+ await Promise.resolve();
2923
+ }
2924
+ forgetLive() {
2925
+ this.mounted.clear();
2926
+ for (const id of [...this.layerRankById.keys()]) if (this.raw.getLayer(id) === void 0) this.layerRankById.delete(id);
2927
+ }
2928
+ keepLive(held) {
2929
+ for (const [slot, live] of held.mounted) {
2930
+ const asked = this.requests.asked(slot);
2931
+ if (asked === live.drawn) {
2932
+ this.mounted.set(slot, live);
2933
+ continue;
2934
+ }
2935
+ if (asked !== void 0 && this.mounted.get(slot)?.drawn === asked) continue;
2936
+ require_language.removeSpecification(this.raw, live);
2937
+ }
2938
+ for (const [id, rank] of held.ranks) if (!this.layerRankById.has(id) && this.raw.getLayer(id) !== void 0) this.layerRankById.set(id, rank);
2939
+ }
2940
+ returnFromLostContext(lost) {
2941
+ this.mounted.clear();
2942
+ this.layerRankById.clear();
2943
+ for (const id of lost.removed) if (this.raw.getLayer(id) !== void 0) this.raw.removeLayer(id);
2944
+ for (const [id, edit] of lost.edited) if (this.raw.getLayer(id) !== void 0) this.writeLayerPatch(id, edit);
2945
+ if (lost.removed.has("sv-coverage-layer") && this.raw.getSource("sv-coverage") !== void 0) this.raw.removeSource(STREETVIEW_COVERAGE_SOURCE);
2946
+ for (const [slot, live] of lost.live.mounted) if (this.requests.asked(slot) === live.drawn) this.mounted.set(slot, live);
2947
+ else require_language.removeSpecification(this.raw, live);
2948
+ for (const [id, rank] of lost.live.ranks) if (this.raw.getLayer(id) !== void 0) this.layerRankById.set(id, rank);
2949
+ for (const id of lost.hidden) if (!this.hiddenLayerIds.has(id)) this.applyVisibility(id, "visible");
2950
+ if (lost.coveragePaint !== void 0) this.placeStreetviewCoverage(lost.coveragePaint);
2951
+ this.replay().catch((error) => {
2952
+ this.emit("error", { error: require_errors.errorFrom(error, unawaitedFailures.replay) });
2953
+ });
2954
+ }
2955
+ liveOf(slot) {
2956
+ return this.mounted.get(slot) ?? this.baseMap.heldLive()?.mounted.get(slot);
2957
+ }
2958
+ applyVisibility(layerId, visibility) {
2959
+ if (this.raw.getLayer(layerId) === void 0) return;
2960
+ this.raw.setLayoutProperty(layerId, "visibility", visibility);
2961
+ }
2962
+ async readOverlayForSlot(slot, slug, kind) {
2963
+ const superseded = this.requests.supersede(slot);
2964
+ const claim = this.requests.claim(slot, true);
2965
+ try {
2966
+ const overlay = requireOverlay(await this.loadLayers(), slug, kind);
2967
+ return this.requests.owns(slot, claim.token) ? overlay : null;
2968
+ } catch (error) {
2969
+ this.requests.giveBack(slot, claim.token, superseded);
2970
+ throw error;
2971
+ } finally {
2972
+ this.requests.endSupersession(superseded);
2973
+ }
2974
+ }
2975
+ writeGeometrySlot(write) {
2976
+ this.geometrySlots = geometrySlotsAfter(this.geometrySlots, write);
2977
+ const { color, geometry } = this.geometrySlots[write.slot];
2978
+ this.setGeoJsonSlot(write.slot, geometry, color);
2979
+ }
2980
+ setGeoJsonSlot(slot, geometry, color) {
2981
+ if (this.destroyed) return;
2982
+ if (geometry === null) {
2983
+ this.unmount(slot);
2984
+ return;
2985
+ }
2986
+ const held = this.requests.asked(slot);
2987
+ const data = held?.kind === "geojson" && held.data.features[0]?.geometry === geometry ? held.data : {
2988
+ features: [{
2989
+ geometry,
2990
+ properties: {},
2991
+ type: "Feature"
2992
+ }],
2993
+ type: "FeatureCollection"
2994
+ };
2995
+ const { layers, rank, sourceId } = geometrySlotLayers(slot, color, this.paint);
2996
+ this.drawGeoJsonSlot(slot, {
2997
+ data,
2998
+ kind: "geojson",
2999
+ layers,
3000
+ rank,
3001
+ sourceId
3002
+ });
3003
+ }
3004
+ drawGeoJsonSlot(slot, desired) {
3005
+ this.requests.ask(slot, desired);
3006
+ const write = () => {
3007
+ if (this.requests.asked(slot) === desired) this.mounted.set(slot, this.applyGeoJson(desired, this.liveOf(slot)));
3008
+ };
3009
+ if (this.eventEngine.isStyleReloading() && !this.hasNoStyleToWriteTo()) {
3010
+ write();
3011
+ return;
3012
+ }
3013
+ this.eventEngine.afterStyleLoad(write);
3014
+ }
3015
+ markerElement(marker) {
3016
+ if (marker.render !== void 0) {
3017
+ const custom = marker.render();
3018
+ if (marker.onClick !== void 0) custom.addEventListener("click", marker.onClick);
3019
+ return custom;
3020
+ }
3021
+ const spec = markerPinSpec(marker, this.icons);
3022
+ const element = document.createElement("div");
3023
+ element.className = "mountaya-marker";
3024
+ element.style.setProperty("--mountaya-marker-color", markerPinColor(spec.fill));
3025
+ let svg = null;
3026
+ const glyph = "glyph" in spec.centre ? this.icons.markup(spec.centre.glyph) : void 0;
3027
+ if (glyph !== void 0) {
3028
+ svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3029
+ svg.setAttribute("viewBox", `0 0 ${this.icons.viewBox} ${this.icons.viewBox}`);
3030
+ for (const [name, value] of Object.entries(require_glyphNode.paintAttributes(require_paint.glyphPaint(this.icons), "currentColor"))) svg.setAttribute(name, value);
3031
+ require_glyphNode.appendGlyph(svg, glyph);
3032
+ element.append(svg);
3033
+ }
3034
+ styleMarkerPin(element, spec, svg, marker.onClick !== void 0);
3035
+ if (marker.onClick !== void 0) element.addEventListener("click", marker.onClick);
3036
+ return element;
3037
+ }
3038
+ specificationSlot(name) {
3039
+ if (name.trim() === "") throw new require_errors.MountayaElementsError("A specification is drawn under a name, which is how it is replaced and removed. This one is empty.");
3040
+ return `${require_slotNames.SPECIFICATION_SLOT_PREFIX}${name}`;
3041
+ }
3042
+ applyLanguage() {
3043
+ require_language.applyLanguageToStyle(this.raw, this.language, { skip: (layerId) => this.layerRankById.has(layerId) });
3044
+ }
3045
+ queryAt(query, point) {
3046
+ if (this.destroyed) return [];
3047
+ const layers = queryLayerIds(query, this.layerRankById, (id) => this.raw.getLayer(id) !== void 0);
3048
+ return layers === null ? [] : this.raw.queryRenderedFeatures(point, { layers: [...layers] }).map(queriedFeature);
3049
+ }
3050
+ controlMove(move) {
3051
+ if (this.destroyed) return;
3052
+ const target = controlMoveTarget(this.getCamera(), this.getZoomLimits(), move);
3053
+ this.raw.easeTo(move === "reset-north" ? {
3054
+ bearing: target.bearing,
3055
+ duration: RESET_NORTH_MS,
3056
+ pitch: target.pitch,
3057
+ roll: 0
3058
+ } : { zoom: target.zoom });
3059
+ }
3060
+ };
3061
+ Object.defineProperty(exports, "MountayaMap", {
3062
+ enumerable: true,
3063
+ get: function() {
3064
+ return MountayaMap;
3065
+ }
3066
+ });
3067
+ Object.defineProperty(exports, "STREETVIEW_COVERAGE_LAYER", {
3068
+ enumerable: true,
3069
+ get: function() {
3070
+ return STREETVIEW_COVERAGE_LAYER;
3071
+ }
3072
+ });
3073
+ Object.defineProperty(exports, "STREETVIEW_COVERAGE_SOURCE", {
3074
+ enumerable: true,
3075
+ get: function() {
3076
+ return STREETVIEW_COVERAGE_SOURCE;
3077
+ }
3078
+ });
3079
+ Object.defineProperty(exports, "STREETVIEW_COVERAGE_TILES", {
3080
+ enumerable: true,
3081
+ get: function() {
3082
+ return STREETVIEW_COVERAGE_TILES;
3083
+ }
3084
+ });
3085
+ Object.defineProperty(exports, "ZOOM_EASE_MS", {
3086
+ enumerable: true,
3087
+ get: function() {
3088
+ return ZOOM_EASE_MS;
3089
+ }
3090
+ });
3091
+ Object.defineProperty(exports, "beforeIdForRank", {
3092
+ enumerable: true,
3093
+ get: function() {
3094
+ return beforeIdForRank;
3095
+ }
3096
+ });
3097
+ Object.defineProperty(exports, "createTransformRequest", {
3098
+ enumerable: true,
3099
+ get: function() {
3100
+ return createTransformRequest;
3101
+ }
3102
+ });
3103
+ Object.defineProperty(exports, "ensureMapLibreWorker", {
3104
+ enumerable: true,
3105
+ get: function() {
3106
+ return ensureMapLibreWorker;
3107
+ }
3108
+ });
3109
+ Object.defineProperty(exports, "placeRanked", {
3110
+ enumerable: true,
3111
+ get: function() {
3112
+ return placeRanked;
3113
+ }
3114
+ });
3115
+ Object.defineProperty(exports, "statedMembers", {
3116
+ enumerable: true,
3117
+ get: function() {
3118
+ return statedMembers;
3119
+ }
3120
+ });
3121
+
3122
+ //# sourceMappingURL=chunk-gWmB1l3A.cjs.map