@webquark/core 1.0.2 → 1.1.0-dev.2

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 (770) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +111 -98
  3. package/dist/cjs/Leaflet.GoogleMutant-BCs2oiE0.js +769 -0
  4. package/dist/cjs/action.props-hpMla743.js +35 -0
  5. package/dist/cjs/chevron-up-B76247zT.js +30 -0
  6. package/dist/cjs/collection-identity-CV5HLD9Z.js +141 -0
  7. package/dist/cjs/data-table-cell-BAv6IIYx.js +46 -0
  8. package/dist/cjs/{dom-CTqgGpWA.js → dom-Dk77oFF6.js} +15 -6
  9. package/dist/cjs/form-control-validity-D1ukC0_e.js +49 -0
  10. package/dist/cjs/{index-CLlvFbDw.js → index-Vzfd3Ljg.js} +58 -3
  11. package/dist/cjs/index.cjs.js +24 -2
  12. package/dist/cjs/leaflet-maplibre-gl-RCEffFEM.js +434 -0
  13. package/dist/cjs/leaflet-src-B0ls4IKq.js +14522 -0
  14. package/dist/cjs/leaflet-src-BX4jwTf5.js +33 -0
  15. package/dist/cjs/loader.cjs.js +2 -2
  16. package/dist/cjs/map.types-DNrz8rJh.js +24 -0
  17. package/dist/cjs/q-alert.cjs.entry.js +52 -0
  18. package/dist/cjs/q-avatar.cjs.entry.js +101 -0
  19. package/dist/cjs/q-button_2.cjs.entry.js +375 -0
  20. package/dist/cjs/q-card.cjs.entry.js +31 -9
  21. package/dist/cjs/q-carousel.cjs.entry.js +121 -78
  22. package/dist/cjs/q-chip.cjs.entry.js +124 -0
  23. package/dist/cjs/q-conversation-bubble.cjs.entry.js +70 -0
  24. package/dist/cjs/q-data-table.cjs.entry.js +470 -118
  25. package/dist/cjs/q-dialog.cjs.entry.js +136 -22
  26. package/dist/cjs/q-dropdown.cjs.entry.js +318 -64
  27. package/dist/cjs/q-form.cjs.entry.js +509 -0
  28. package/dist/cjs/q-icon.cjs.entry.js +290 -99
  29. package/dist/cjs/q-input_2.cjs.entry.js +363 -0
  30. package/dist/cjs/q-link.cjs.entry.js +80 -0
  31. package/dist/cjs/q-map.cjs.entry.js +3328 -0
  32. package/dist/cjs/q-navbar.cjs.entry.js +194 -0
  33. package/dist/cjs/q-pagination.cjs.entry.js +68 -0
  34. package/dist/cjs/q-panel.cjs.entry.js +67 -0
  35. package/dist/cjs/q-quantity-selector.cjs.entry.js +112 -93
  36. package/dist/cjs/q-radio-group.cjs.entry.js +217 -0
  37. package/dist/cjs/q-reel.cjs.entry.js +86 -33
  38. package/dist/cjs/q-scrollable.cjs.entry.js +449 -0
  39. package/dist/cjs/q-sidepanel.cjs.entry.js +562 -114
  40. package/dist/cjs/q-step-diagram-item.cjs.entry.js +11 -17
  41. package/dist/cjs/q-step-diagram.cjs.entry.js +9 -10
  42. package/dist/cjs/q-syntax-box.cjs.entry.js +381 -173
  43. package/dist/cjs/q-tabs.cjs.entry.js +155 -0
  44. package/dist/cjs/q-textarea.cjs.entry.js +69 -9
  45. package/dist/cjs/q-thumbnail.cjs.entry.js +18 -11
  46. package/dist/cjs/q-toast.cjs.entry.js +400 -0
  47. package/dist/cjs/q-toggle.cjs.entry.js +57 -26
  48. package/dist/cjs/q-toolbar.cjs.entry.js +29 -0
  49. package/dist/cjs/registry-BhkCNgxt.js +179 -0
  50. package/dist/cjs/toast-controller-CIXagxbV.js +111 -0
  51. package/dist/cjs/webquark.cjs.js +2 -2
  52. package/dist/collection/assets/icons/braces.svg +14 -14
  53. package/dist/collection/assets/icons/check.svg +1 -1
  54. package/dist/collection/assets/icons/chevron-down.svg +1 -1
  55. package/dist/collection/assets/icons/chevron-left.svg +1 -1
  56. package/dist/collection/assets/icons/chevron-right.svg +1 -1
  57. package/dist/collection/assets/icons/chevron-up.svg +1 -1
  58. package/dist/collection/assets/icons/copy.svg +4 -4
  59. package/dist/collection/assets/icons/eye-off.svg +1 -1
  60. package/dist/collection/assets/icons/eye.svg +1 -1
  61. package/dist/collection/assets/icons/minus.svg +1 -1
  62. package/dist/collection/assets/icons/play.svg +1 -1
  63. package/dist/collection/assets/icons/plus.svg +1 -1
  64. package/dist/collection/assets/icons/search.svg +1 -1
  65. package/dist/collection/assets/icons/spinner.svg +1 -1
  66. package/dist/collection/assets/icons/trash-2.svg +1 -1
  67. package/dist/collection/assets/icons/x.svg +1 -1
  68. package/dist/collection/collection-manifest.json +37 -21
  69. package/dist/collection/components/actions/action.props.js +130 -0
  70. package/dist/collection/components/{button → actions/button}/button.css +191 -174
  71. package/dist/collection/components/{button → actions/button}/button.js +243 -89
  72. package/dist/collection/components/actions/button/button.types.js +1 -0
  73. package/dist/collection/components/actions/button/button.utils.js +9 -0
  74. package/dist/collection/components/actions/button/button.utils.unit.test.js +44 -0
  75. package/dist/collection/components/actions/chip/chip.css +219 -0
  76. package/dist/collection/components/actions/chip/chip.js +381 -0
  77. package/dist/collection/components/actions/chip/chip.types.js +1 -0
  78. package/dist/collection/components/actions/link/link.css +102 -0
  79. package/dist/collection/components/actions/link/link.js +313 -0
  80. package/dist/collection/components/actions/link/link.types.js +1 -0
  81. package/dist/collection/components/data-display/alert/alert.css +118 -0
  82. package/dist/collection/components/data-display/alert/alert.js +208 -0
  83. package/dist/collection/components/data-display/alert/alert.types.js +1 -0
  84. package/dist/collection/components/data-display/conversation-bubble/conversation-bubble.css +154 -0
  85. package/dist/collection/components/data-display/conversation-bubble/conversation-bubble.js +207 -0
  86. package/dist/collection/components/data-display/conversation-bubble/conversation-bubble.types.js +1 -0
  87. package/dist/collection/components/data-display/data-table/data-table-cell.js +40 -0
  88. package/dist/collection/components/{data-table → data-display/data-table}/data-table.css +356 -219
  89. package/dist/collection/components/data-display/data-table/data-table.js +748 -0
  90. package/dist/collection/components/data-display/data-table/data-table.types.js +1 -0
  91. package/dist/collection/components/data-display/data-table/internals/data-access.js +43 -0
  92. package/dist/collection/components/data-display/data-table/internals/render-row-actions.js +22 -0
  93. package/dist/collection/components/data-display/data-table/internals/render-sort-indicator.js +5 -0
  94. package/dist/collection/components/data-display/data-table/internals/render-table-body.js +47 -0
  95. package/dist/collection/components/data-display/data-table/internals/render-table-head.js +42 -0
  96. package/dist/collection/components/data-display/data-table/internals/render-toolbar.js +6 -0
  97. package/dist/collection/components/data-display/data-table/internals/row-events.js +27 -0
  98. package/dist/collection/components/data-display/data-table/internals/selection.js +31 -0
  99. package/dist/collection/components/data-display/data-table/internals/sort.js +57 -0
  100. package/dist/collection/components/data-display/data-table/internals/table-model.js +84 -0
  101. package/dist/collection/components/data-display/map/internals/base-layer.js +140 -0
  102. package/dist/collection/components/data-display/map/internals/bounds.js +66 -0
  103. package/dist/collection/components/data-display/map/internals/buffered-tile-layer.js +128 -0
  104. package/dist/collection/components/data-display/map/internals/cluster-collision.js +73 -0
  105. package/dist/collection/components/data-display/map/internals/google-maps.js +117 -0
  106. package/dist/collection/components/data-display/map/internals/google-mutant.js +51 -0
  107. package/dist/collection/components/data-display/map/internals/maplibre.js +50 -0
  108. package/dist/collection/components/data-display/map/internals/marker-cluster-index.js +136 -0
  109. package/dist/collection/components/data-display/map/internals/marker-controller.js +403 -0
  110. package/dist/collection/components/data-display/map/internals/marker-presentation.js +217 -0
  111. package/dist/collection/components/data-display/map/internals/marker-visibility.js +158 -0
  112. package/dist/collection/components/data-display/map/internals/markers.js +176 -0
  113. package/dist/collection/components/data-display/map/internals/tile-layer-readiness.js +67 -0
  114. package/dist/collection/components/data-display/map/internals/tile-preload-buffer.js +8 -0
  115. package/dist/collection/components/data-display/map/internals/vector-padding.js +8 -0
  116. package/dist/collection/components/data-display/map/map.css +711 -0
  117. package/dist/collection/components/data-display/map/map.js +1514 -0
  118. package/dist/collection/components/data-display/map/map.types.js +12 -0
  119. package/dist/collection/components/data-display/map/test/map.cmp.test.js +748 -0
  120. package/dist/collection/components/data-display/pagination/pagination.css +81 -0
  121. package/dist/collection/components/data-display/pagination/pagination.js +240 -0
  122. package/dist/collection/components/data-display/pagination/test/pagination.cmp.test.js +57 -0
  123. package/dist/collection/components/data-display/syntax-box/internals/clipboard.js +9 -0
  124. package/dist/collection/components/data-display/syntax-box/internals/editor-key-action.js +14 -0
  125. package/dist/collection/components/data-display/syntax-box/internals/value-sync.js +27 -0
  126. package/dist/collection/components/{syntax-box → data-display/syntax-box}/syntax-box.css +202 -206
  127. package/dist/collection/components/data-display/syntax-box/syntax-box.js +623 -0
  128. package/dist/collection/components/data-display/syntax-box/syntax-box.types.js +1 -0
  129. package/dist/collection/components/data-display/syntax-box/syntax-box.utils.js +1 -0
  130. package/dist/collection/components/indicators/progress/progress.css +223 -0
  131. package/dist/collection/components/indicators/progress/progress.js +275 -0
  132. package/dist/collection/components/indicators/progress/progress.types.js +1 -0
  133. package/dist/collection/components/{step-diagram → indicators/step-diagram}/step-diagram.css +21 -21
  134. package/dist/collection/components/{step-diagram → indicators/step-diagram}/step-diagram.js +42 -12
  135. package/dist/collection/components/indicators/step-diagram/step-diagram.types.js +1 -0
  136. package/dist/collection/components/{step-diagram-item → indicators/step-diagram-item}/step-diagram-item.css +252 -253
  137. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.js +153 -0
  138. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.types.js +1 -0
  139. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.utils.js +3 -0
  140. package/dist/collection/components/{dropdown → inputs/dropdown}/dropdown.css +344 -292
  141. package/dist/collection/components/inputs/dropdown/dropdown.js +986 -0
  142. package/dist/collection/components/inputs/dropdown/dropdown.types.js +1 -0
  143. package/dist/collection/components/inputs/dropdown/internals/options.js +30 -0
  144. package/dist/collection/components/inputs/dropdown/internals/position.js +35 -0
  145. package/dist/collection/components/inputs/dropdown/test/dropdown.cmp.test.js +62 -0
  146. package/dist/collection/components/{input → inputs/input}/input.css +264 -276
  147. package/dist/collection/components/{input → inputs/input}/input.js +242 -83
  148. package/dist/collection/components/inputs/input/input.types.js +1 -0
  149. package/dist/collection/components/inputs/input/input.utils.js +3 -0
  150. package/dist/collection/components/inputs/quantity-selector/internals/number-value.js +64 -0
  151. package/dist/collection/components/{quantity-selector → inputs/quantity-selector}/quantity-selector.css +131 -131
  152. package/dist/collection/components/{quantity-selector → inputs/quantity-selector}/quantity-selector.js +75 -109
  153. package/dist/collection/components/inputs/quantity-selector/quantity-selector.types.js +1 -0
  154. package/dist/collection/components/inputs/radio-group/radio-group.css +177 -0
  155. package/dist/collection/components/inputs/radio-group/radio-group.js +558 -0
  156. package/dist/collection/components/inputs/radio-group/radio-group.types.js +1 -0
  157. package/dist/collection/components/inputs/radio-group/radio-group.utils.js +18 -0
  158. package/dist/collection/components/{textarea → inputs/textarea}/textarea.css +88 -83
  159. package/dist/collection/components/{textarea → inputs/textarea}/textarea.js +162 -18
  160. package/dist/collection/components/inputs/textarea/textarea.types.js +1 -0
  161. package/dist/collection/components/{toggle → inputs/toggle}/toggle.css +220 -212
  162. package/dist/collection/components/{toggle → inputs/toggle}/toggle.js +158 -51
  163. package/dist/collection/components/inputs/toggle/toggle.types.js +1 -0
  164. package/dist/collection/components/inputs/toggle/toggle.utils.js +3 -0
  165. package/dist/collection/components/{card → layout/card}/card.css +93 -96
  166. package/dist/collection/components/{card → layout/card}/card.js +40 -19
  167. package/dist/collection/components/layout/card/card.types.js +1 -0
  168. package/dist/collection/components/layout/card/card.utils.js +15 -0
  169. package/dist/collection/components/{carousel → layout/carousel}/carousel.css +168 -177
  170. package/dist/collection/components/{carousel → layout/carousel}/carousel.js +103 -105
  171. package/dist/collection/components/layout/carousel/carousel.types.js +1 -0
  172. package/dist/collection/components/layout/carousel/carousel.utils.js +1 -0
  173. package/dist/collection/components/layout/carousel/internals/metrics.js +59 -0
  174. package/dist/collection/components/layout/form/form.css +49 -0
  175. package/dist/collection/components/layout/form/form.js +613 -0
  176. package/dist/collection/components/layout/form/form.types.js +1 -0
  177. package/dist/collection/components/layout/form/internals/controls.js +79 -0
  178. package/dist/collection/components/layout/form/internals/enter-behavior.js +36 -0
  179. package/dist/collection/components/layout/form/internals/values.js +176 -0
  180. package/dist/collection/components/layout/form/test/form.cmp.test.js +157 -0
  181. package/dist/collection/components/layout/navbar/navbar.css +465 -0
  182. package/dist/collection/components/layout/navbar/navbar.js +547 -0
  183. package/dist/collection/components/layout/navbar/navbar.types.js +1 -0
  184. package/dist/collection/components/layout/navbar/navbar.utils.js +13 -0
  185. package/dist/collection/components/layout/navbar/test/navbar.cmp.test.js +53 -0
  186. package/dist/collection/components/layout/panel/panel.css +113 -0
  187. package/dist/collection/components/layout/panel/panel.js +265 -0
  188. package/dist/collection/components/layout/panel/panel.types.js +1 -0
  189. package/dist/collection/components/layout/scrollable/internals/metrics.js +61 -0
  190. package/dist/collection/components/layout/scrollable/internals/native-scrollbar.js +41 -0
  191. package/dist/collection/components/{scrollable → layout/scrollable}/scrollable.css +123 -122
  192. package/dist/collection/components/{scrollable → layout/scrollable}/scrollable.js +165 -136
  193. package/dist/collection/components/layout/scrollable/scrollable.types.js +1 -0
  194. package/dist/collection/components/layout/sidepanel/internals/drawer.js +60 -0
  195. package/dist/collection/components/layout/sidepanel/internals/groups.js +56 -0
  196. package/dist/collection/components/layout/sidepanel/internals/nav-items.js +27 -0
  197. package/dist/collection/components/layout/sidepanel/sidepanel.css +881 -0
  198. package/dist/collection/components/layout/sidepanel/sidepanel.js +831 -0
  199. package/dist/collection/components/layout/sidepanel/sidepanel.types.js +1 -0
  200. package/dist/collection/components/layout/sidepanel/sidepanel.utils.js +17 -0
  201. package/dist/collection/components/layout/tabs/tabs.css +248 -0
  202. package/dist/collection/components/layout/tabs/tabs.js +322 -0
  203. package/dist/collection/components/layout/tabs/tabs.types.js +1 -0
  204. package/dist/collection/components/layout/tabs/tabs.utils.js +31 -0
  205. package/dist/collection/components/layout/tabs/test/tabs.cmp.test.js +165 -0
  206. package/dist/collection/components/layout/toolbar/toolbar.css +145 -0
  207. package/dist/collection/components/layout/toolbar/toolbar.js +173 -0
  208. package/dist/collection/components/layout/toolbar/toolbar.types.js +1 -0
  209. package/dist/collection/components/media/avatar/avatar.css +71 -0
  210. package/dist/collection/components/media/avatar/avatar.js +302 -0
  211. package/dist/collection/components/media/avatar/avatar.types.js +1 -0
  212. package/dist/collection/components/{icon → media/icon}/icon.css +42 -39
  213. package/dist/collection/components/media/icon/icon.js +449 -0
  214. package/dist/collection/components/media/icon/icon.types.js +1 -0
  215. package/dist/collection/components/media/icon/internals/constants.js +3 -0
  216. package/dist/collection/components/media/icon/internals/fetch-icon.js +18 -0
  217. package/dist/collection/components/media/icon/internals/registry.js +171 -0
  218. package/dist/collection/components/media/icon/internals/registry.unit.test.js +42 -0
  219. package/dist/collection/components/media/icon/internals/render-definition.js +24 -0
  220. package/dist/collection/components/media/icon/internals/sanitize-svg.js +63 -0
  221. package/dist/collection/components/media/icon/internals/size.js +12 -0
  222. package/dist/collection/components/media/icon/internals/url.js +48 -0
  223. package/dist/collection/components/{reel → media/reel}/reel.css +193 -185
  224. package/dist/collection/components/{reel → media/reel}/reel.js +99 -34
  225. package/dist/collection/components/media/reel/reel.types.js +1 -0
  226. package/dist/collection/components/{thumbnail → media/thumbnail}/thumbnail.css +111 -109
  227. package/dist/collection/components/{thumbnail → media/thumbnail}/thumbnail.js +32 -19
  228. package/dist/collection/components/media/thumbnail/thumbnail.types.js +1 -0
  229. package/dist/collection/components/{dialog → overlays/dialog}/dialog.css +248 -240
  230. package/dist/collection/components/{dialog → overlays/dialog}/dialog.js +190 -58
  231. package/dist/collection/components/overlays/dialog/dialog.types.js +1 -0
  232. package/dist/collection/components/overlays/dialog/internals/backdrop.js +9 -0
  233. package/dist/collection/components/overlays/dialog/internals/lifecycle.js +53 -0
  234. package/dist/collection/components/overlays/toast/internals/icons.js +25 -0
  235. package/dist/collection/components/overlays/toast/internals/queue.js +64 -0
  236. package/dist/collection/components/overlays/toast/internals/timers.js +75 -0
  237. package/dist/collection/components/overlays/toast/test/toast.cmp.test.js +38 -0
  238. package/dist/collection/components/overlays/toast/test/toast.unit.test.js +104 -0
  239. package/dist/collection/components/overlays/toast/toast-controller.js +105 -0
  240. package/dist/collection/components/overlays/toast/toast.css +141 -0
  241. package/dist/collection/components/overlays/toast/toast.js +556 -0
  242. package/dist/collection/components/overlays/toast/toast.types.js +1 -0
  243. package/dist/collection/components/overlays/tooltip/internals/aria.js +27 -0
  244. package/dist/collection/components/overlays/tooltip/internals/positioning.js +69 -0
  245. package/dist/collection/components/overlays/tooltip/internals/scroll-listeners.js +18 -0
  246. package/dist/collection/components/{tooltip → overlays/tooltip}/tooltip.css +65 -65
  247. package/dist/collection/components/overlays/tooltip/tooltip.js +190 -0
  248. package/dist/collection/components/overlays/tooltip/tooltip.types.js +1 -0
  249. package/dist/collection/index.js +5 -0
  250. package/dist/collection/playground/components/playground-event-log/playground-event-log.js +3 -3
  251. package/dist/collection/playground/components/playground-sidebar/playground-sidebar.js +42 -6
  252. package/dist/collection/playground/components/properties-panel/properties-panel.js +1 -1
  253. package/dist/collection/playground/components/sandbox-viewport/sandbox-panel.js +7 -3
  254. package/dist/collection/playground/components/sandbox-viewport/sandbox-viewport.js +4 -0
  255. package/dist/collection/playground/components/theme-designer/theme-designer.js +6 -4
  256. package/dist/collection/playground/logo.svg +8 -8
  257. package/dist/collection/playground/playground.bundled.js +949 -887
  258. package/dist/collection/utils/collection-identity.js +136 -0
  259. package/dist/collection/utils/collection-identity.unit.test.js +107 -0
  260. package/dist/collection/utils/dom.js +14 -6
  261. package/dist/collection/utils/form-control-validity.js +44 -0
  262. package/dist/collection/utils/formatter.unit.test.js +24 -24
  263. package/dist/components/index.js +1 -1
  264. package/dist/components/p-2bWqVyTo.js +1 -0
  265. package/dist/components/p-B6NJEaqd.js +1 -0
  266. package/dist/components/p-B6g9Pj3f.js +1 -0
  267. package/dist/components/p-BEBDDqVT.js +1 -0
  268. package/dist/components/p-BIIQL66b.js +1 -0
  269. package/dist/components/p-BJiYCN3i.js +1 -0
  270. package/dist/components/p-BeeM-7Ku.js +5 -0
  271. package/dist/components/p-Bj2RJb2E.js +1 -0
  272. package/dist/components/p-BnmIFx4N.js +1 -0
  273. package/dist/components/p-BvBRW3dl.js +1 -0
  274. package/dist/components/p-ByfrUWx1.js +1 -0
  275. package/dist/components/p-C7yQ3tON.js +1 -0
  276. package/dist/components/p-CDktnDug.js +13 -0
  277. package/dist/components/p-CGZPmEUB.js +1 -0
  278. package/dist/components/p-DAl7U6Ms.js +1 -0
  279. package/dist/components/p-DH-PVHhr.js +1 -0
  280. package/dist/components/p-DQhiqYeq.js +1 -0
  281. package/dist/components/p-DcsB8P_Y.js +1 -0
  282. package/dist/components/p-DmqVhVoj.js +1 -0
  283. package/dist/components/p-Dnud2v8F.js +1 -0
  284. package/dist/components/p-QHgICI4w.js +1 -0
  285. package/dist/components/p-WJHaLJS_.js +1 -0
  286. package/dist/components/{q-circular-progress.d.ts → q-alert.d.ts} +4 -4
  287. package/dist/components/q-alert.js +1 -0
  288. package/dist/components/q-avatar.d.ts +11 -0
  289. package/dist/components/q-avatar.js +1 -0
  290. package/dist/components/q-button.js +1 -1
  291. package/dist/components/q-card.js +1 -1
  292. package/dist/components/q-carousel.js +1 -1
  293. package/dist/components/q-chip.d.ts +11 -0
  294. package/dist/components/q-chip.js +1 -0
  295. package/dist/components/q-conversation-bubble.d.ts +11 -0
  296. package/dist/components/q-conversation-bubble.js +1 -0
  297. package/dist/components/q-data-table.js +1 -1
  298. package/dist/components/q-dialog.js +1 -1
  299. package/dist/components/q-dropdown.js +1 -1
  300. package/dist/components/q-form.d.ts +11 -0
  301. package/dist/components/q-form.js +1 -0
  302. package/dist/components/q-icon.js +1 -1
  303. package/dist/components/q-input.js +1 -1
  304. package/dist/components/q-link.d.ts +11 -0
  305. package/dist/components/q-link.js +1 -0
  306. package/dist/components/q-map.d.ts +11 -0
  307. package/dist/components/q-map.js +1 -0
  308. package/dist/components/q-navbar.d.ts +11 -0
  309. package/dist/components/q-navbar.js +1 -0
  310. package/dist/components/q-pagination.d.ts +11 -0
  311. package/dist/components/q-pagination.js +1 -0
  312. package/dist/components/q-panel.d.ts +11 -0
  313. package/dist/components/q-panel.js +1 -0
  314. package/dist/components/q-progress.d.ts +11 -0
  315. package/dist/components/q-progress.js +1 -0
  316. package/dist/components/q-quantity-selector.js +1 -1
  317. package/dist/components/q-radio-group.d.ts +11 -0
  318. package/dist/components/q-radio-group.js +1 -0
  319. package/dist/components/q-reel.js +1 -1
  320. package/dist/components/q-scrollable.js +1 -1
  321. package/dist/components/q-sidepanel.js +13 -1
  322. package/dist/components/q-step-diagram-item.js +1 -1
  323. package/dist/components/q-step-diagram.js +1 -1
  324. package/dist/components/q-syntax-box.js +13 -1
  325. package/dist/components/q-tabs.d.ts +11 -0
  326. package/dist/components/q-tabs.js +1 -0
  327. package/dist/components/q-textarea.js +1 -1
  328. package/dist/components/q-thumbnail.js +1 -1
  329. package/dist/components/q-toast.d.ts +11 -0
  330. package/dist/components/q-toast.js +1 -0
  331. package/dist/components/q-toggle.js +1 -1
  332. package/dist/components/q-toolbar.d.ts +11 -0
  333. package/dist/components/q-toolbar.js +1 -0
  334. package/dist/components/q-tooltip.js +1 -1
  335. package/dist/esm/Leaflet.GoogleMutant-BlvymWLE.js +767 -0
  336. package/dist/esm/action.props-BJWXy1Ec.js +32 -0
  337. package/dist/esm/chevron-up-CDktnDug.js +27 -0
  338. package/dist/esm/collection-identity-CGZPmEUB.js +138 -0
  339. package/dist/esm/data-table-cell-DmqVhVoj.js +42 -0
  340. package/dist/esm/{dom-DoQvrOHk.js → dom-ByfrUWx1.js} +15 -7
  341. package/dist/esm/form-control-validity-Bj2RJb2E.js +46 -0
  342. package/dist/esm/{index-CYoQ4Zv3.js → index-DweBlExe.js} +58 -4
  343. package/dist/esm/index.js +6 -1
  344. package/dist/esm/leaflet-maplibre-gl-Cgb-1z8Q.js +432 -0
  345. package/dist/esm/leaflet-src-BR13bdVA.js +30 -0
  346. package/dist/esm/leaflet-src-BeeM-7Ku.js +14520 -0
  347. package/dist/esm/loader.js +3 -3
  348. package/dist/esm/map.types-WJHaLJS_.js +14 -0
  349. package/dist/esm/q-alert.entry.js +50 -0
  350. package/dist/esm/q-avatar.entry.js +99 -0
  351. package/dist/esm/q-button_2.entry.js +372 -0
  352. package/dist/esm/q-card.entry.js +31 -9
  353. package/dist/esm/q-carousel.entry.js +121 -78
  354. package/dist/esm/q-chip.entry.js +122 -0
  355. package/dist/esm/q-conversation-bubble.entry.js +68 -0
  356. package/dist/esm/q-data-table.entry.js +470 -118
  357. package/dist/esm/q-dialog.entry.js +136 -22
  358. package/dist/esm/q-dropdown.entry.js +318 -64
  359. package/dist/esm/q-form.entry.js +507 -0
  360. package/dist/esm/q-icon.entry.js +290 -99
  361. package/dist/esm/q-input_2.entry.js +360 -0
  362. package/dist/esm/q-link.entry.js +78 -0
  363. package/dist/esm/q-map.entry.js +3326 -0
  364. package/dist/esm/q-navbar.entry.js +192 -0
  365. package/dist/esm/q-pagination.entry.js +66 -0
  366. package/dist/esm/q-panel.entry.js +65 -0
  367. package/dist/esm/q-quantity-selector.entry.js +112 -93
  368. package/dist/esm/q-radio-group.entry.js +215 -0
  369. package/dist/esm/q-reel.entry.js +86 -33
  370. package/dist/esm/q-scrollable.entry.js +447 -0
  371. package/dist/esm/q-sidepanel.entry.js +562 -114
  372. package/dist/esm/q-step-diagram-item.entry.js +11 -17
  373. package/dist/esm/q-step-diagram.entry.js +9 -10
  374. package/dist/esm/q-syntax-box.entry.js +381 -173
  375. package/dist/esm/q-tabs.entry.js +153 -0
  376. package/dist/esm/q-textarea.entry.js +69 -9
  377. package/dist/esm/q-thumbnail.entry.js +18 -11
  378. package/dist/esm/q-toast.entry.js +398 -0
  379. package/dist/esm/q-toggle.entry.js +57 -26
  380. package/dist/esm/q-toolbar.entry.js +27 -0
  381. package/dist/esm/registry-BvBRW3dl.js +173 -0
  382. package/dist/esm/toast-controller-BIIQL66b.js +107 -0
  383. package/dist/esm/webquark.js +3 -3
  384. package/dist/playground/assets/icons/braces.svg +14 -14
  385. package/dist/playground/assets/icons/check.svg +1 -1
  386. package/dist/playground/assets/icons/chevron-down.svg +1 -1
  387. package/dist/playground/assets/icons/chevron-left.svg +1 -1
  388. package/dist/playground/assets/icons/chevron-right.svg +1 -1
  389. package/dist/playground/assets/icons/chevron-up.svg +1 -1
  390. package/dist/playground/assets/icons/copy.svg +4 -4
  391. package/dist/playground/assets/icons/eye-off.svg +1 -1
  392. package/dist/playground/assets/icons/eye.svg +1 -1
  393. package/dist/playground/assets/icons/minus.svg +1 -1
  394. package/dist/playground/assets/icons/play.svg +1 -1
  395. package/dist/playground/assets/icons/plus.svg +1 -1
  396. package/dist/playground/assets/icons/search.svg +1 -1
  397. package/dist/playground/assets/icons/spinner.svg +1 -1
  398. package/dist/playground/assets/icons/trash-2.svg +1 -1
  399. package/dist/playground/assets/icons/x.svg +1 -1
  400. package/dist/playground/build/index.esm.js +1 -1
  401. package/dist/playground/build/p-06813183.entry.js +1 -0
  402. package/dist/playground/build/p-09d43469.entry.js +1 -0
  403. package/dist/playground/build/p-256d199a.entry.js +1 -0
  404. package/dist/playground/build/p-2bWqVyTo.js +1 -0
  405. package/dist/playground/build/p-2f0bbb67.entry.js +1 -0
  406. package/dist/playground/build/p-31d62bd0.entry.js +1 -0
  407. package/dist/playground/build/p-35c9fa4d.entry.js +1 -0
  408. package/dist/playground/build/p-3e4d2d19.entry.js +1 -0
  409. package/dist/playground/build/p-4b38c28f.entry.js +1 -0
  410. package/dist/playground/build/p-4f8ee3f7.entry.js +1 -0
  411. package/dist/playground/build/p-53a5c493.entry.js +1 -0
  412. package/dist/playground/build/p-721d2479.entry.js +1 -0
  413. package/dist/playground/build/p-7be7478a.entry.js +1 -0
  414. package/dist/playground/build/p-7c4e6512.entry.js +1 -0
  415. package/dist/playground/build/p-7c9d705e.entry.js +1 -0
  416. package/dist/playground/build/p-8ff218f7.entry.js +1 -0
  417. package/dist/playground/build/p-94eba9a9.entry.js +1 -0
  418. package/dist/playground/build/p-BEBDDqVT.js +1 -0
  419. package/dist/playground/build/p-BIIQL66b.js +1 -0
  420. package/dist/playground/build/p-BeeM-7Ku.js +5 -0
  421. package/dist/playground/build/p-Bj2RJb2E.js +1 -0
  422. package/dist/playground/build/p-BvBRW3dl.js +1 -0
  423. package/dist/playground/build/p-ByfrUWx1.js +1 -0
  424. package/dist/playground/build/p-CDktnDug.js +13 -0
  425. package/dist/playground/build/p-CGZPmEUB.js +1 -0
  426. package/dist/playground/build/p-DNFGt02p.js +1 -0
  427. package/dist/playground/build/p-DmqVhVoj.js +1 -0
  428. package/dist/playground/build/p-DweBlExe.js +2 -0
  429. package/dist/playground/build/p-Dxs6LLBG.js +1 -0
  430. package/dist/playground/build/p-WJHaLJS_.js +1 -0
  431. package/dist/playground/build/p-a0861b0e.entry.js +1 -0
  432. package/dist/playground/build/p-a2a3135f.entry.js +1 -0
  433. package/dist/playground/build/p-a7b90eef.entry.js +13 -0
  434. package/dist/playground/build/p-bc0a0428.entry.js +1 -0
  435. package/dist/playground/build/p-bc7d7cbf.entry.js +13 -0
  436. package/dist/playground/build/p-c4016e61.entry.js +1 -0
  437. package/dist/playground/build/p-c64be717.entry.js +1 -0
  438. package/dist/playground/build/p-d142bb86.entry.js +1 -0
  439. package/dist/playground/build/p-d22a876a.entry.js +1 -0
  440. package/dist/playground/build/p-d691a1aa.entry.js +1 -0
  441. package/dist/playground/build/p-dabaddcb.entry.js +1 -0
  442. package/dist/playground/build/p-dac913f9.entry.js +1 -0
  443. package/dist/playground/build/p-de7364cd.entry.js +1 -0
  444. package/dist/playground/build/p-e298fb31.entry.js +1 -0
  445. package/dist/playground/build/p-e354a398.entry.js +1 -0
  446. package/dist/playground/build/p-f1ab576a.entry.js +1 -0
  447. package/dist/playground/build/webquark.css +1 -1
  448. package/dist/playground/build/webquark.esm.js +1 -1
  449. package/dist/playground/css/base.css +122 -145
  450. package/dist/playground/index.html +29 -29
  451. package/dist/playground/logo.svg +8 -8
  452. package/dist/playground/playground/components.manifest.json +37 -20
  453. package/dist/playground/playground/specs/q-avatar.sandbox.json +24 -0
  454. package/dist/playground/playground/specs/q-button.sandbox.json +209 -198
  455. package/dist/playground/playground/specs/q-card.sandbox.json +144 -144
  456. package/dist/playground/playground/specs/q-carousel.sandbox.json +120 -120
  457. package/dist/playground/playground/specs/q-chip.sandbox.json +105 -0
  458. package/dist/playground/playground/specs/q-conversation-bubble.sandbox.json +26 -0
  459. package/dist/playground/playground/specs/q-data-table.sandbox.json +161 -108
  460. package/dist/playground/playground/specs/q-dialog.sandbox.json +108 -108
  461. package/dist/playground/playground/specs/q-dropdown.sandbox.json +121 -116
  462. package/dist/playground/playground/specs/q-form.sandbox.json +20 -0
  463. package/dist/playground/playground/specs/q-icon.sandbox.json +138 -138
  464. package/dist/playground/playground/specs/q-input.sandbox.json +192 -192
  465. package/dist/playground/playground/specs/q-link.sandbox.json +27 -0
  466. package/dist/playground/playground/specs/q-map.sandbox.json +203 -0
  467. package/dist/playground/playground/specs/q-navbar.sandbox.json +32 -0
  468. package/dist/playground/playground/specs/q-panel.sandbox.json +28 -0
  469. package/dist/playground/playground/specs/q-progress.sandbox.json +117 -0
  470. package/dist/playground/playground/specs/q-quantity-selector.sandbox.json +99 -99
  471. package/dist/playground/playground/specs/q-radio-group.sandbox.json +58 -0
  472. package/dist/playground/playground/specs/q-reel.sandbox.json +70 -70
  473. package/dist/playground/playground/specs/q-scrollable.sandbox.json +102 -102
  474. package/dist/playground/playground/specs/q-sidepanel.sandbox.json +152 -147
  475. package/dist/playground/playground/specs/q-step-diagram.sandbox.json +56 -56
  476. package/dist/playground/playground/specs/q-syntax-box.sandbox.json +160 -160
  477. package/dist/playground/playground/specs/q-textarea.sandbox.json +133 -133
  478. package/dist/playground/playground/specs/q-toast.sandbox.json +32 -0
  479. package/dist/playground/playground/specs/q-toggle.sandbox.json +196 -196
  480. package/dist/playground/playground/specs/q-toolbar.sandbox.json +26 -0
  481. package/dist/playground/playground/specs/q-tooltip.sandbox.json +65 -65
  482. package/dist/playground/playground.js +949 -887
  483. package/dist/types/components/actions/action.props.d.ts +19 -0
  484. package/dist/types/components/actions/button/button.d.ts +61 -0
  485. package/dist/types/components/actions/button/button.types.d.ts +5 -0
  486. package/dist/types/components/actions/button/button.utils.d.ts +8 -0
  487. package/dist/types/components/actions/button/button.utils.unit.test.d.ts +1 -0
  488. package/dist/types/components/actions/chip/chip.d.ts +55 -0
  489. package/dist/types/components/actions/chip/chip.types.d.ts +13 -0
  490. package/dist/types/components/actions/link/link.d.ts +43 -0
  491. package/dist/types/components/actions/link/link.types.d.ts +3 -0
  492. package/dist/types/components/data-display/alert/alert.d.ts +32 -0
  493. package/dist/types/components/data-display/alert/alert.types.d.ts +2 -0
  494. package/dist/types/components/data-display/conversation-bubble/conversation-bubble.d.ts +38 -0
  495. package/dist/types/components/data-display/conversation-bubble/conversation-bubble.types.d.ts +1 -0
  496. package/dist/types/components/data-display/data-table/data-table-cell.d.ts +5 -0
  497. package/dist/types/components/data-display/data-table/data-table.d.ts +78 -0
  498. package/dist/types/components/data-display/data-table/data-table.types.d.ts +53 -0
  499. package/dist/types/components/data-display/data-table/internals/data-access.d.ts +9 -0
  500. package/dist/types/components/data-display/data-table/internals/render-row-actions.d.ts +9 -0
  501. package/dist/types/components/data-display/data-table/internals/render-sort-indicator.d.ts +5 -0
  502. package/dist/types/components/data-display/data-table/internals/render-table-body.d.ts +12 -0
  503. package/dist/types/components/data-display/data-table/internals/render-table-head.d.ts +8 -0
  504. package/dist/types/components/data-display/data-table/internals/render-toolbar.d.ts +9 -0
  505. package/dist/types/components/data-display/data-table/internals/row-events.d.ts +1 -0
  506. package/dist/types/components/data-display/data-table/internals/selection.d.ts +10 -0
  507. package/dist/types/components/data-display/data-table/internals/sort.d.ts +3 -0
  508. package/dist/types/components/data-display/data-table/internals/table-model.d.ts +52 -0
  509. package/dist/types/components/data-display/map/internals/base-layer.d.ts +63 -0
  510. package/dist/types/components/data-display/map/internals/bounds.d.ts +23 -0
  511. package/dist/types/components/data-display/map/internals/buffered-tile-layer.d.ts +10 -0
  512. package/dist/types/components/data-display/map/internals/cluster-collision.d.ts +15 -0
  513. package/dist/types/components/data-display/map/internals/google-maps.d.ts +9 -0
  514. package/dist/types/components/data-display/map/internals/google-mutant-module.d.ts +11 -0
  515. package/dist/types/components/data-display/map/internals/google-mutant.d.ts +18 -0
  516. package/dist/types/components/data-display/map/internals/maplibre.d.ts +14 -0
  517. package/dist/types/components/data-display/map/internals/marker-cluster-index.d.ts +36 -0
  518. package/dist/types/components/data-display/map/internals/marker-controller.d.ts +55 -0
  519. package/dist/types/components/data-display/map/internals/marker-presentation.d.ts +8 -0
  520. package/dist/types/components/data-display/map/internals/marker-visibility.d.ts +10 -0
  521. package/dist/types/components/data-display/map/internals/markers.d.ts +4 -0
  522. package/dist/types/components/data-display/map/internals/tile-layer-readiness.d.ts +11 -0
  523. package/dist/types/components/data-display/map/internals/tile-preload-buffer.d.ts +4 -0
  524. package/dist/types/components/data-display/map/internals/vector-padding.d.ts +4 -0
  525. package/dist/types/components/data-display/map/map.d.ts +171 -0
  526. package/dist/types/components/data-display/map/map.types.d.ts +122 -0
  527. package/dist/types/components/data-display/map/test/map.cmp.test.d.ts +1 -0
  528. package/dist/types/components/data-display/pagination/pagination.d.ts +33 -0
  529. package/dist/types/components/data-display/pagination/test/pagination.cmp.test.d.ts +2 -0
  530. package/dist/types/components/data-display/syntax-box/internals/clipboard.d.ts +2 -0
  531. package/dist/types/components/data-display/syntax-box/internals/editor-key-action.d.ts +12 -0
  532. package/dist/types/components/data-display/syntax-box/internals/value-sync.d.ts +18 -0
  533. package/dist/types/components/data-display/syntax-box/syntax-box.d.ts +66 -0
  534. package/dist/types/components/data-display/syntax-box/syntax-box.types.d.ts +2 -0
  535. package/dist/types/components/data-display/syntax-box/syntax-box.utils.d.ts +1 -0
  536. package/dist/types/components/indicators/progress/progress.d.ts +30 -0
  537. package/dist/types/components/indicators/progress/progress.types.d.ts +3 -0
  538. package/dist/types/components/indicators/step-diagram/step-diagram.d.ts +16 -0
  539. package/dist/types/components/indicators/step-diagram/step-diagram.types.d.ts +1 -0
  540. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.d.ts +24 -0
  541. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.types.d.ts +3 -0
  542. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.utils.d.ts +1 -0
  543. package/dist/types/components/inputs/dropdown/dropdown.d.ts +90 -0
  544. package/dist/types/components/inputs/dropdown/dropdown.types.d.ts +8 -0
  545. package/dist/types/components/inputs/dropdown/internals/options.d.ts +6 -0
  546. package/dist/types/components/inputs/dropdown/internals/position.d.ts +26 -0
  547. package/dist/types/components/inputs/dropdown/test/dropdown.cmp.test.d.ts +1 -0
  548. package/dist/types/components/inputs/input/input.d.ts +77 -0
  549. package/dist/types/components/inputs/input/input.types.d.ts +2 -0
  550. package/dist/types/components/inputs/input/input.utils.d.ts +1 -0
  551. package/dist/types/components/inputs/quantity-selector/internals/number-value.d.ts +13 -0
  552. package/dist/types/components/{quantity-selector → inputs/quantity-selector}/quantity-selector.d.ts +10 -9
  553. package/dist/types/components/inputs/quantity-selector/quantity-selector.types.d.ts +1 -0
  554. package/dist/types/components/inputs/radio-group/radio-group.d.ts +60 -0
  555. package/dist/types/components/inputs/radio-group/radio-group.types.d.ts +11 -0
  556. package/dist/types/components/inputs/radio-group/radio-group.utils.d.ts +2 -0
  557. package/dist/types/components/inputs/textarea/textarea.d.ts +59 -0
  558. package/dist/types/components/inputs/textarea/textarea.types.d.ts +1 -0
  559. package/dist/types/components/inputs/toggle/toggle.d.ts +56 -0
  560. package/dist/types/components/inputs/toggle/toggle.types.d.ts +2 -0
  561. package/dist/types/components/inputs/toggle/toggle.utils.d.ts +1 -0
  562. package/dist/types/components/layout/card/card.d.ts +24 -0
  563. package/dist/types/components/layout/card/card.types.d.ts +1 -0
  564. package/dist/types/components/layout/card/card.utils.d.ts +5 -0
  565. package/dist/types/components/{carousel → layout/carousel}/carousel.d.ts +19 -7
  566. package/dist/types/components/layout/carousel/carousel.types.d.ts +5 -0
  567. package/dist/types/components/layout/carousel/carousel.utils.d.ts +1 -0
  568. package/dist/types/components/layout/carousel/internals/metrics.d.ts +23 -0
  569. package/dist/types/components/layout/form/form.d.ts +69 -0
  570. package/dist/types/components/layout/form/form.types.d.ts +38 -0
  571. package/dist/types/components/layout/form/internals/controls.d.ts +5 -0
  572. package/dist/types/components/layout/form/internals/enter-behavior.d.ts +2 -0
  573. package/dist/types/components/layout/form/internals/values.d.ts +5 -0
  574. package/dist/types/components/layout/form/test/form.cmp.test.d.ts +4 -0
  575. package/dist/types/components/layout/navbar/navbar.d.ts +66 -0
  576. package/dist/types/components/layout/navbar/navbar.types.d.ts +31 -0
  577. package/dist/types/components/layout/navbar/navbar.utils.d.ts +2 -0
  578. package/dist/types/components/layout/navbar/test/navbar.cmp.test.d.ts +1 -0
  579. package/dist/types/components/layout/panel/panel.d.ts +33 -0
  580. package/dist/types/components/layout/panel/panel.types.d.ts +2 -0
  581. package/dist/types/components/layout/scrollable/internals/metrics.d.ts +26 -0
  582. package/dist/types/components/layout/scrollable/internals/native-scrollbar.d.ts +4 -0
  583. package/dist/types/components/layout/scrollable/scrollable.d.ts +67 -0
  584. package/dist/types/components/layout/scrollable/scrollable.types.d.ts +6 -0
  585. package/dist/types/components/layout/sidepanel/internals/drawer.d.ts +2 -0
  586. package/dist/types/components/layout/sidepanel/internals/groups.d.ts +7 -0
  587. package/dist/types/components/layout/sidepanel/internals/nav-items.d.ts +2 -0
  588. package/dist/types/components/layout/sidepanel/sidepanel.d.ts +93 -0
  589. package/dist/types/components/layout/sidepanel/sidepanel.types.d.ts +39 -0
  590. package/dist/types/components/layout/sidepanel/sidepanel.utils.d.ts +2 -0
  591. package/dist/types/components/layout/tabs/tabs.d.ts +29 -0
  592. package/dist/types/components/layout/tabs/tabs.types.d.ts +14 -0
  593. package/dist/types/components/layout/tabs/tabs.utils.d.ts +4 -0
  594. package/dist/types/components/layout/tabs/test/tabs.cmp.test.d.ts +1 -0
  595. package/dist/types/components/layout/toolbar/toolbar.d.ts +23 -0
  596. package/dist/types/components/layout/toolbar/toolbar.types.d.ts +1 -0
  597. package/dist/types/components/media/avatar/avatar.d.ts +37 -0
  598. package/dist/types/components/media/avatar/avatar.types.d.ts +2 -0
  599. package/dist/types/components/media/icon/icon.d.ts +44 -0
  600. package/dist/types/components/media/icon/icon.types.d.ts +30 -0
  601. package/dist/types/components/media/icon/internals/constants.d.ts +3 -0
  602. package/dist/types/components/media/icon/internals/fetch-icon.d.ts +1 -0
  603. package/dist/types/components/media/icon/internals/registry.d.ts +11 -0
  604. package/dist/types/components/media/icon/internals/registry.unit.test.d.ts +1 -0
  605. package/dist/types/components/media/icon/internals/render-definition.d.ts +2 -0
  606. package/dist/types/components/media/icon/internals/sanitize-svg.d.ts +2 -0
  607. package/dist/types/components/media/icon/internals/size.d.ts +2 -0
  608. package/dist/types/components/media/icon/internals/url.d.ts +11 -0
  609. package/dist/types/components/media/reel/reel.d.ts +34 -0
  610. package/dist/types/components/media/reel/reel.types.d.ts +3 -0
  611. package/dist/types/components/media/thumbnail/thumbnail.d.ts +21 -0
  612. package/dist/types/components/media/thumbnail/thumbnail.types.d.ts +7 -0
  613. package/dist/types/components/overlays/dialog/dialog.d.ts +71 -0
  614. package/dist/types/components/overlays/dialog/dialog.types.d.ts +1 -0
  615. package/dist/types/components/overlays/dialog/internals/backdrop.d.ts +2 -0
  616. package/dist/types/components/overlays/dialog/internals/lifecycle.d.ts +21 -0
  617. package/dist/types/components/overlays/toast/internals/icons.d.ts +2 -0
  618. package/dist/types/components/overlays/toast/internals/queue.d.ts +19 -0
  619. package/dist/types/components/overlays/toast/internals/timers.d.ts +12 -0
  620. package/dist/types/components/overlays/toast/test/toast.cmp.test.d.ts +2 -0
  621. package/dist/types/components/overlays/toast/test/toast.unit.test.d.ts +1 -0
  622. package/dist/types/components/overlays/toast/toast-controller.d.ts +9 -0
  623. package/dist/types/components/overlays/toast/toast.d.ts +44 -0
  624. package/dist/types/components/overlays/toast/toast.types.d.ts +30 -0
  625. package/dist/types/components/overlays/tooltip/internals/aria.d.ts +13 -0
  626. package/dist/types/components/overlays/tooltip/internals/positioning.d.ts +7 -0
  627. package/dist/types/components/overlays/tooltip/internals/scroll-listeners.d.ts +2 -0
  628. package/dist/types/components/overlays/tooltip/tooltip.d.ts +28 -0
  629. package/dist/types/components/overlays/tooltip/tooltip.types.d.ts +1 -0
  630. package/dist/types/components.d.ts +3607 -568
  631. package/dist/types/declarations.d.ts +14 -9
  632. package/dist/types/index.d.ts +12 -0
  633. package/dist/types/playground/components/playground-sidebar/playground-sidebar.d.ts +2 -0
  634. package/dist/types/utils/collection-identity.d.ts +55 -0
  635. package/dist/types/utils/collection-identity.unit.test.d.ts +1 -0
  636. package/dist/types/utils/dom.d.ts +1 -1
  637. package/dist/types/utils/form-control-validity.d.ts +14 -0
  638. package/dist/webquark/index.esm.js +1 -1
  639. package/dist/webquark/p-06813183.entry.js +1 -0
  640. package/dist/webquark/p-09d43469.entry.js +1 -0
  641. package/dist/webquark/p-256d199a.entry.js +1 -0
  642. package/dist/webquark/p-2bWqVyTo.js +1 -0
  643. package/dist/webquark/p-2f0bbb67.entry.js +1 -0
  644. package/dist/webquark/p-31d62bd0.entry.js +1 -0
  645. package/dist/webquark/p-35c9fa4d.entry.js +1 -0
  646. package/dist/webquark/p-3e4d2d19.entry.js +1 -0
  647. package/dist/webquark/p-4b38c28f.entry.js +1 -0
  648. package/dist/webquark/p-4f8ee3f7.entry.js +1 -0
  649. package/dist/webquark/p-53a5c493.entry.js +1 -0
  650. package/dist/webquark/p-721d2479.entry.js +1 -0
  651. package/dist/webquark/p-7be7478a.entry.js +1 -0
  652. package/dist/webquark/p-7c4e6512.entry.js +1 -0
  653. package/dist/webquark/p-7c9d705e.entry.js +1 -0
  654. package/dist/webquark/p-8ff218f7.entry.js +1 -0
  655. package/dist/webquark/p-94eba9a9.entry.js +1 -0
  656. package/dist/webquark/p-BEBDDqVT.js +1 -0
  657. package/dist/webquark/p-BIIQL66b.js +1 -0
  658. package/dist/webquark/p-BeeM-7Ku.js +5 -0
  659. package/dist/webquark/p-Bj2RJb2E.js +1 -0
  660. package/dist/webquark/p-BvBRW3dl.js +1 -0
  661. package/dist/webquark/p-ByfrUWx1.js +1 -0
  662. package/dist/webquark/p-CDktnDug.js +13 -0
  663. package/dist/webquark/p-CGZPmEUB.js +1 -0
  664. package/dist/webquark/p-DNFGt02p.js +1 -0
  665. package/dist/webquark/p-DmqVhVoj.js +1 -0
  666. package/dist/webquark/p-DweBlExe.js +2 -0
  667. package/dist/webquark/p-Dxs6LLBG.js +1 -0
  668. package/dist/webquark/p-WJHaLJS_.js +1 -0
  669. package/dist/webquark/p-a0861b0e.entry.js +1 -0
  670. package/dist/webquark/p-a2a3135f.entry.js +1 -0
  671. package/dist/webquark/p-a7b90eef.entry.js +13 -0
  672. package/dist/webquark/p-bc0a0428.entry.js +1 -0
  673. package/dist/webquark/p-bc7d7cbf.entry.js +13 -0
  674. package/dist/webquark/p-c4016e61.entry.js +1 -0
  675. package/dist/webquark/p-c64be717.entry.js +1 -0
  676. package/dist/webquark/p-d142bb86.entry.js +1 -0
  677. package/dist/webquark/p-d22a876a.entry.js +1 -0
  678. package/dist/webquark/p-d691a1aa.entry.js +1 -0
  679. package/dist/webquark/p-dabaddcb.entry.js +1 -0
  680. package/dist/webquark/p-dac913f9.entry.js +1 -0
  681. package/dist/webquark/p-de7364cd.entry.js +1 -0
  682. package/dist/webquark/p-e298fb31.entry.js +1 -0
  683. package/dist/webquark/p-e354a398.entry.js +1 -0
  684. package/dist/webquark/p-f1ab576a.entry.js +1 -0
  685. package/dist/webquark/webquark.css +1 -1
  686. package/dist/webquark/webquark.esm.js +1 -1
  687. package/package.json +113 -84
  688. package/scripts/webquark-serve.js +0 -0
  689. package/dist/cjs/q-button_3.cjs.entry.js +0 -603
  690. package/dist/cjs/q-circular-progress_2.cjs.entry.js +0 -255
  691. package/dist/collection/components/circular-progress/circular-progress.css +0 -85
  692. package/dist/collection/components/circular-progress/circular-progress.js +0 -122
  693. package/dist/collection/components/data-table/data-table.js +0 -481
  694. package/dist/collection/components/dropdown/dropdown.js +0 -606
  695. package/dist/collection/components/icon/icon.js +0 -297
  696. package/dist/collection/components/sidepanel/sidepanel.css +0 -371
  697. package/dist/collection/components/sidepanel/sidepanel.js +0 -460
  698. package/dist/collection/components/step-diagram-item/step-diagram-item.js +0 -131
  699. package/dist/collection/components/syntax-box/syntax-box.js +0 -534
  700. package/dist/collection/components/tooltip/tooltip.js +0 -249
  701. package/dist/components/p-91lJS0-v.js +0 -1
  702. package/dist/components/p-B4IF9WVv.js +0 -1
  703. package/dist/components/p-BCSpNDGG.js +0 -1
  704. package/dist/components/p-DScvq41R.js +0 -1
  705. package/dist/components/p-DfTW9B7V.js +0 -1
  706. package/dist/components/p-DgaKWrjd.js +0 -1
  707. package/dist/components/p-Do2ppeKL.js +0 -1
  708. package/dist/components/p-DoQvrOHk.js +0 -1
  709. package/dist/components/q-circular-progress.js +0 -1
  710. package/dist/esm/q-button_3.entry.js +0 -599
  711. package/dist/esm/q-circular-progress_2.entry.js +0 -252
  712. package/dist/playground/build/p-095635d3.entry.js +0 -1
  713. package/dist/playground/build/p-1187e439.entry.js +0 -1
  714. package/dist/playground/build/p-389e2cd3.entry.js +0 -1
  715. package/dist/playground/build/p-38d9e75b.entry.js +0 -1
  716. package/dist/playground/build/p-4ce667f1.entry.js +0 -1
  717. package/dist/playground/build/p-66b0eb0f.entry.js +0 -1
  718. package/dist/playground/build/p-69d33f9d.entry.js +0 -1
  719. package/dist/playground/build/p-6dc7b987.entry.js +0 -1
  720. package/dist/playground/build/p-76e04a7f.entry.js +0 -1
  721. package/dist/playground/build/p-776a0eb6.entry.js +0 -1
  722. package/dist/playground/build/p-7c4532f3.entry.js +0 -1
  723. package/dist/playground/build/p-7d2144cf.entry.js +0 -1
  724. package/dist/playground/build/p-84185204.entry.js +0 -1
  725. package/dist/playground/build/p-938cd8a6.entry.js +0 -1
  726. package/dist/playground/build/p-CYoQ4Zv3.js +0 -2
  727. package/dist/playground/build/p-DoQvrOHk.js +0 -1
  728. package/dist/playground/build/p-a182b818.entry.js +0 -1
  729. package/dist/playground/build/p-aa017815.entry.js +0 -1
  730. package/dist/playground/build/p-d7607e11.entry.js +0 -1
  731. package/dist/playground/playground/specs/q-circular-progress.sandbox.json +0 -91
  732. package/dist/types/components/button/button.d.ts +0 -26
  733. package/dist/types/components/card/card.d.ts +0 -12
  734. package/dist/types/components/circular-progress/circular-progress.d.ts +0 -7
  735. package/dist/types/components/data-table/data-table.d.ts +0 -45
  736. package/dist/types/components/dialog/dialog.d.ts +0 -35
  737. package/dist/types/components/dropdown/dropdown.d.ts +0 -49
  738. package/dist/types/components/icon/icon.d.ts +0 -33
  739. package/dist/types/components/input/input.d.ts +0 -43
  740. package/dist/types/components/reel/reel.d.ts +0 -23
  741. package/dist/types/components/scrollable/scrollable.d.ts +0 -47
  742. package/dist/types/components/sidepanel/sidepanel.d.ts +0 -58
  743. package/dist/types/components/step-diagram/step-diagram.d.ts +0 -10
  744. package/dist/types/components/step-diagram-item/step-diagram-item.d.ts +0 -12
  745. package/dist/types/components/syntax-box/syntax-box.d.ts +0 -37
  746. package/dist/types/components/textarea/textarea.d.ts +0 -36
  747. package/dist/types/components/thumbnail/thumbnail.d.ts +0 -18
  748. package/dist/types/components/toggle/toggle.d.ts +0 -36
  749. package/dist/types/components/tooltip/tooltip.d.ts +0 -29
  750. package/dist/webquark/p-095635d3.entry.js +0 -1
  751. package/dist/webquark/p-1187e439.entry.js +0 -1
  752. package/dist/webquark/p-389e2cd3.entry.js +0 -1
  753. package/dist/webquark/p-38d9e75b.entry.js +0 -1
  754. package/dist/webquark/p-4ce667f1.entry.js +0 -1
  755. package/dist/webquark/p-66b0eb0f.entry.js +0 -1
  756. package/dist/webquark/p-69d33f9d.entry.js +0 -1
  757. package/dist/webquark/p-6dc7b987.entry.js +0 -1
  758. package/dist/webquark/p-76e04a7f.entry.js +0 -1
  759. package/dist/webquark/p-776a0eb6.entry.js +0 -1
  760. package/dist/webquark/p-7c4532f3.entry.js +0 -1
  761. package/dist/webquark/p-7d2144cf.entry.js +0 -1
  762. package/dist/webquark/p-84185204.entry.js +0 -1
  763. package/dist/webquark/p-938cd8a6.entry.js +0 -1
  764. package/dist/webquark/p-CYoQ4Zv3.js +0 -2
  765. package/dist/webquark/p-DoQvrOHk.js +0 -1
  766. package/dist/webquark/p-a182b818.entry.js +0 -1
  767. package/dist/webquark/p-aa017815.entry.js +0 -1
  768. package/dist/webquark/p-d7607e11.entry.js +0 -1
  769. /package/dist/cjs/{index-DGQOjEwT.js → utils-DGQOjEwT.js} +0 -0
  770. /package/dist/esm/{index-BJiYCN3i.js → utils-BJiYCN3i.js} +0 -0
@@ -0,0 +1 @@
1
+ import{r as t}from"./p-BeeM-7Ku.js";var e,i,n,s,r={exports:{}},o={exports:{}};i||(i=1,"undefined"!=typeof globalThis?globalThis:r.exports||self,r.exports=(n=t(),e||(e=1,o.exports=function(){var t={},e={};function i(i,n,s){if(e[i]=s,"index"===i){var r="var sharedModule = {}; ("+e.shared+")(sharedModule); ("+e.worker+")(sharedModule);",o={};return e.shared(o),e.index(t,o),"undefined"!=typeof window&&t.setWorkerUrl(window.URL.createObjectURL(new Blob([r],{type:"text/javascript"}))),t}}return i("shared",0,(function(t){function e(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{h(n.next(t))}catch(t){r(t)}}function a(t){try{h(n.throw(t))}catch(t){r(t)}}function h(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}h((n=n.apply(t,e||[])).next())}))}function i(t,e){this.x=t,this.y=e}function n(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var s,r;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(t){return this.clone()._add(t)},sub(t){return this.clone()._sub(t)},multByPoint(t){return this.clone()._multByPoint(t)},divByPoint(t){return this.clone()._divByPoint(t)},mult(t){return this.clone()._mult(t)},div(t){return this.clone()._div(t)},rotate(t){return this.clone()._rotate(t)},rotateAround(t,e){return this.clone()._rotateAround(t,e)},matMult(t){return this.clone()._matMult(t)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(t){return this.x===t.x&&this.y===t.y},dist(t){return Math.sqrt(this.distSqr(t))},distSqr(t){const e=t.x-this.x,i=t.y-this.y;return e*e+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith(t){return this.angleWithSep(t.x,t.y)},angleWithSep(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},_matMult(t){const e=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=e,this},_add(t){return this.x+=t.x,this.y+=t.y,this},_sub(t){return this.x-=t.x,this.y-=t.y,this},_mult(t){return this.x*=t,this.y*=t,this},_div(t){return this.x/=t,this.y/=t,this},_multByPoint(t){return this.x*=t.x,this.y*=t.y,this},_divByPoint(t){return this.x/=t.x,this.y/=t.y,this},_unit(){return this._div(this.mag()),this},_perp(){const t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){const e=Math.cos(t),i=Math.sin(t),n=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=n,this},_rotateAround(t,e){const i=Math.cos(t),n=Math.sin(t),s=e.y+n*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-n*(this.y-e.y),this.y=s,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(t){if(t instanceof i)return t;if(Array.isArray(t))return new i(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new i(+t.x,+t.y);throw new Error("Expected [x, y] or {x, y} point format")};var o=function(){if(r)return s;function t(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}return r=1,s=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var r=this.sampleCurveDerivativeX(i);if(Math.abs(r)<1e-6)break;i-=s/r}var o=0,a=1;for(i=t,n=0;n<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));n++)t>s?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},s}(),a=n(o);let h,l;function c(){return null!=h||(h="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),h}function u(){if(null==l&&(l=!1,c())){const t=5,e=new OffscreenCanvas(t,t).getContext("2d",{willReadFrequently:!0});if(e){for(let i=0;i<t*t;i++){const n=4*i;e.fillStyle=`rgb(${n},${n+1},${n+2})`,e.fillRect(i%t,Math.floor(i/t),1,1)}const i=e.getImageData(0,0,t,t).data;for(let e=0;e<t*t*4;e++)if(e%4!=3&&i[e]!==e){l=!0;break}}}return l||!1}var f=1e-6,d="undefined"!=typeof Float32Array?Float32Array:Array;function p(){var t=new d(9);return d!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function m(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function _(){var t=new d(3);return d!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function g(t){var e=t[0],i=t[1],n=t[2];return Math.sqrt(e*e+i*i+n*n)}function v(t,e,i){var n=new d(3);return n[0]=t,n[1]=e,n[2]=i,n}function y(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function w(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function b(t,e,i){var n=e[0],s=e[1],r=e[2],o=i[0],a=i[1],h=i[2];return t[0]=s*h-r*a,t[1]=r*o-n*h,t[2]=n*a-s*o,t}var x,M=g;function S(t,e,i){var n=e[0],s=e[1],r=e[2],o=e[3];return t[0]=i[0]*n+i[4]*s+i[8]*r+i[12]*o,t[1]=i[1]*n+i[5]*s+i[9]*r+i[13]*o,t[2]=i[2]*n+i[6]*s+i[10]*r+i[14]*o,t[3]=i[3]*n+i[7]*s+i[11]*r+i[15]*o,t}function z(){var t=new d(4);return d!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function T(t,e,i,n){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",r=Math.PI/360;e*=r,n*=r,i*=r;var o=Math.sin(e),a=Math.cos(e),h=Math.sin(i),l=Math.cos(i),c=Math.sin(n),u=Math.cos(n);switch(s){case"xyz":t[0]=o*l*u+a*h*c,t[1]=a*h*u-o*l*c,t[2]=a*l*c+o*h*u,t[3]=a*l*u-o*h*c;break;case"xzy":t[0]=o*l*u-a*h*c,t[1]=a*h*u-o*l*c,t[2]=a*l*c+o*h*u,t[3]=a*l*u+o*h*c;break;case"yxz":t[0]=o*l*u+a*h*c,t[1]=a*h*u-o*l*c,t[2]=a*l*c-o*h*u,t[3]=a*l*u+o*h*c;break;case"yzx":t[0]=o*l*u+a*h*c,t[1]=a*h*u+o*l*c,t[2]=a*l*c-o*h*u,t[3]=a*l*u-o*h*c;break;case"zxy":t[0]=o*l*u-a*h*c,t[1]=a*h*u+o*l*c,t[2]=a*l*c+o*h*u,t[3]=a*l*u-o*h*c;break;case"zyx":t[0]=o*l*u-a*h*c,t[1]=a*h*u+o*l*c,t[2]=a*l*c-o*h*u,t[3]=a*l*u+o*h*c;break;default:throw new Error("Unknown angle order "+s)}return t}function E(){var t=new d(2);return d!=Float32Array&&(t[0]=0,t[1]=0),t}function A(t,e){var i=new d(2);return i[0]=t,i[1]=e,i}_(),x=new d(4),d!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),_(),v(1,0,0),v(0,1,0),z(),z(),p(),E();const P=8192;function C(t,e,i){return e*(P/(t.tileSize*Math.pow(2,i-t.tileID.overscaledZ)))}function D(t){return t instanceof Error?t:new Error("string"==typeof t?t:String(t))}function F(t,e){return(t%e+e)%e}function I(t,e,i){return t*(1-i)+e*i}function k(t){if(t<=0)return 0;if(t>=1)return 1;const e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}function $(t,e,i,n){const s=new a(t,e,i,n);return t=>s.solve(t)}const O=$(.25,.1,.25,1);function j(t,e,i){return Math.min(i,Math.max(e,t))}function R(t,e,i){const n=i-e,s=((t-e)%n+n)%n+e;return s===e?i:s}function L(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}let B=1;function N(t,e){const i={};for(const n in t)i[n]=e.call(this,t[n],n,t);return i}function U(t,e){const i={};for(const n in t)e.call(this,t[n],n,t)&&(i[n]=t[n]);return i}function G(t){return Array.isArray(t)?t.map(G):"object"==typeof t&&t?N(t,G):t}const V={};function q(t){V[t]||("undefined"!=typeof console&&console.warn(t),V[t]=!0)}function Z(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function W(t){return"undefined"!=typeof WorkerGlobalScope&&void 0!==t&&t instanceof WorkerGlobalScope}let H=null;function Y(t){return"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap}const X="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function J(t,i,n,s,r){return e(this,void 0,void 0,(function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const e=new VideoFrame(t,{timestamp:0});try{const o=null==e?void 0:e.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw new Error(`Unrecognized format ${o}`);const a=o.startsWith("BGR"),h=new Uint8ClampedArray(s*r*4);if(yield e.copyTo(h,function(t,e,i,n,s){const r=4*Math.max(-e,0),o=(Math.max(0,i)-i)*n*4+r,a=4*n,h=Math.max(0,e),l=Math.max(0,i);return{rect:{x:h,y:l,width:Math.min(t.width,e+n)-h,height:Math.min(t.height,i+s)-l},layout:[{offset:o,stride:a}]}}(t,i,n,s,r)),a)for(let t=0;t<h.length;t+=4){const e=h[t];h[t]=h[t+2],h[t+2]=e}return h}finally{e.close()}}))}let K,Q;function tt(t,e,i,n){return t.addEventListener(e,i,n),{unsubscribe:()=>{t.removeEventListener(e,i,n)}}}function et(t){return t*Math.PI/180}function it(t){return t/Math.PI*180}const nt={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},st={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},rt="AbortError";class ot extends Error{constructor(t=rt){super(t instanceof Error?t.message:t),this.name=rt,t instanceof Error&&t.stack&&(this.stack=t.stack)}}function at(t){return t instanceof Error&&t.name===rt}function ht(t){if(t.aborted)throw new ot(t.reason)}const lt={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ct(t){return lt.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const ut="global-dispatcher";class ft extends Error{constructor(t,e,i,n){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=n}}const dt=()=>{var t;return W(self)?null===(t=self.worker)||void 0===t?void 0:t.referrer:("blob:"===window.location.protocol?window.parent:window).location.href},pt=function(t,i){return e(this,void 0,void 0,(function*(){var n,s;if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){const e=ct(t.url);if(e){const n=yield e(t,i);return n.data||"arrayBuffer"!==t.type?n:L(n,{data:new ArrayBuffer(0)})}if(W(self)&&(null===(n=self.worker)||void 0===n?void 0:n.actor))return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:ut},i)}if(!(t=>{var e;return t.startsWith("file:")||(null===(e=dt())||void 0===e?void 0:e.startsWith("file:"))&&!/^\w+:/.test(t)})(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return function(t,i){return e(this,void 0,void 0,(function*(){const e=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:dt(),referrerPolicy:t.referrerPolicy,signal:i.signal});let n,s;"json"!==t.type||e.headers.has("Accept")||e.headers.set("Accept","application/json");try{n=yield fetch(e)}catch(e){if(at(e))throw e;throw new ft(0,D(e).message,t.url,new Blob)}if(!n.ok){const e=yield n.blob();throw new ft(n.status,n.statusText,t.url,e)}s="arrayBuffer"===t.type||"image"===t.type?n.arrayBuffer():"json"===t.type?n.json():n.text();const r=yield s;return ht(i.signal),{data:r,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires"),etag:n.headers.get("ETag")}}))}(t,i);if(W(self)&&(null===(s=self.worker)||void 0===s?void 0:s.actor))return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:ut},i)}return function(t,e){return new Promise(((i,n)=>{var s;const r=new XMLHttpRequest;r.open(t.method||"GET",t.url,!0),"arrayBuffer"!==t.type&&"image"!==t.type||(r.responseType="arraybuffer");for(const e in t.headers)r.setRequestHeader(e,t.headers[e]);"json"===t.type&&(r.responseType="text",(null===(s=t.headers)||void 0===s?void 0:s.Accept)||r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===t.credentials,r.onerror=()=>{n(new Error(r.statusText))},r.onload=()=>{if(!e.signal.aborted)if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let e=r.response;if("json"===t.type)try{e=JSON.parse(r.response)}catch(t){return void n(t)}i({data:e,cacheControl:r.getResponseHeader("Cache-Control"),expires:r.getResponseHeader("Expires"),etag:r.getResponseHeader("ETag")})}else{const e=new Blob([r.response],{type:r.getResponseHeader("Content-Type")});n(new ft(r.status,r.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{r.abort(),n(new ot(e.signal.reason))})),r.send(t.body)}))}(t,i)}))};function mt(t){if(!t||t.indexOf("://")<=0||t.startsWith("data:image/")||t.startsWith("blob:"))return!0;const e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}function _t(t,e,i){var n;(null===(n=i[t])||void 0===n?void 0:n.includes(e))||(i[t]||(i[t]=[]),i[t].push(e))}function gt(t,e,i){if(null==i?void 0:i[t]){const n=i[t].indexOf(e);-1!==n&&i[t].splice(n,1)}}class vt{constructor(t,e={}){L(this,e),this.type=t}}class yt extends vt{constructor(t,e={}){super("error",L({error:t},e))}}class wt{on(t,e){return this._listeners||(this._listeners={}),_t(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return gt(t,e,this._listeners),gt(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||(this._oneTimeListeners={}),_t(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){var i,n;"string"==typeof t&&(t=new vt(t,e||{}));const s=t.type;if(this.listens(s)){t.target=this;const e=(null===(i=this._listeners)||void 0===i?void 0:i[s])?this._listeners[s].slice():[];for(const i of e)i.call(this,t);const r=(null===(n=this._oneTimeListeners)||void 0===n?void 0:n[s])?this._oneTimeListeners[s].slice():[];for(const e of r)gt(s,e,this._oneTimeListeners),e.call(this,t);const o=this._eventedParent;o&&(L(t,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),o.fire(t))}else t instanceof yt&&console.error(t.error);return this}listens(t){var e,i,n,s,r;return(null===(i=null===(e=this._listeners)||void 0===e?void 0:e[t])||void 0===i?void 0:i.length)>0||(null===(s=null===(n=this._oneTimeListeners)||void 0===n?void 0:n[t])||void 0===s?void 0:s.length)>0||(null===(r=this._eventedParent)||void 0===r?void 0:r.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}}var bt={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number",length:2},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"filter"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible",expression:{interpolated:!1,parameters:["global-state"]},"property-type":"data-constant"}},filter:{type:"boolean",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"expression_name",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"},resampling:{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}},interpolation:{type:"array",value:"interpolation_name",minimum:1},interpolation_name:{type:"enum",values:{linear:{syntax:{overloads:[{parameters:[],"output-type":"interpolation"}],parameters:[]}},exponential:{syntax:{overloads:[{parameters:["base"],"output-type":"interpolation"}],parameters:[{name:"base",type:"number literal"}]}},"cubic-bezier":{syntax:{overloads:[{parameters:["x1","y1","x2","y2"],"output-type":"interpolation"}],parameters:[{name:"x1",type:"number literal"},{name:"y1",type:"number literal"},{name:"x2",type:"number literal"},{name:"y2",type:"number literal"}]}}}}};const xt=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Mt(t,e){const i={};for(const e in t)"ref"!==e&&(i[e]=t[e]);return xt.forEach((t=>{t in e&&(i[t]=e[t])})),i}function St(t,e){if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!St(t[i],e[i]))return!1;return!0}if("object"==typeof t&&null!==t&&null!==e){if("object"!=typeof e)return!1;if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(!St(t[i],e[i]))return!1;return!0}return t===e}function zt(t,e){t.push(e)}function Tt(t,e,i){zt(i,{command:"addSource",args:[t,e[t]]})}function Et(t,e,i){zt(e,{command:"removeSource",args:[t]}),i[t]=!0}function At(t,e,i,n){Et(t,i,n),Tt(t,e,i)}function Pt(t,e,i){let n;for(n in t[i])if(Object.prototype.hasOwnProperty.call(t[i],n)&&"data"!==n&&!St(t[i][n],e[i][n]))return!1;for(n in e[i])if(Object.prototype.hasOwnProperty.call(e[i],n)&&"data"!==n&&!St(t[i][n],e[i][n]))return!1;return!0}function Ct(t,e,i,n,s,r){t=t||{},e=e||{};for(const o in t)Object.prototype.hasOwnProperty.call(t,o)&&(St(t[o],e[o])||i.push({command:r,args:[n,o,e[o],s]}));for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(St(t[o],e[o])||i.push({command:r,args:[n,o,e[o],s]}))}function Dt(t){return t.id}function Ft(t,e){return t[e.id]=e,t}class It{constructor(t,e,i,n){this.message=(t?`${t}: `:"")+i,n&&(this.identifier=n),null!=e&&e.__line__&&(this.line=e.__line__)}}function kt(t,...e){for(const i of e)for(const e in i)t[e]=i[e];return t}class $t extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}class Ot{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,i]of e)this.bindings[t]=i}concat(t){return new Ot(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}const jt={kind:"null"},Rt={kind:"number"},Lt={kind:"string"},Bt={kind:"boolean"},Nt={kind:"color"},Ut={kind:"projectionDefinition"},Gt={kind:"object"},Vt={kind:"value"},qt={kind:"collator"},Zt={kind:"formatted"},Wt={kind:"padding"},Ht={kind:"colorArray"},Yt={kind:"numberArray"},Xt={kind:"resolvedImage"},Jt={kind:"variableAnchorOffsetCollection"};function Kt(t,e){return{kind:"array",itemType:t,N:e}}function Qt(t){if("array"===t.kind){const e=Qt(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const te=[jt,Rt,Lt,Bt,Nt,Ut,Zt,Gt,Kt(Vt),Wt,Yt,Ht,Xt,Jt];function ee(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!ee(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of te)if(!ee(t,e))return null}return`Expected ${Qt(t)} but found ${Qt(e)} instead.`}function ie(t,e){return e.some((e=>e.kind===t.kind))}function ne(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}function se(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const re=.96422,oe=.82521,ae=4/29,he=6/29,le=3*he*he,ce=he*he*he,ue=Math.PI/180,fe=180/Math.PI;function de(t){return(t%=360)<0&&(t+=360),t}function pe([t,e,i,n]){let s,r;const o=_e((.2225045*(t=me(t))+.7168786*(e=me(e))+.0606169*(i=me(i)))/1);t===e&&e===i?s=r=o:(s=_e((.4360747*t+.3850649*e+.1430804*i)/re),r=_e((.0139322*t+.0971045*e+.7141733*i)/oe));const a=116*o-16;return[a<0?0:a,500*(s-o),200*(o-r),n]}function me(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function _e(t){return t>ce?Math.pow(t,1/3):t/le+ae}function ge([t,e,i,n]){let s=(t+16)/116,r=isNaN(e)?s:s+e/500,o=isNaN(i)?s:s-i/200;return s=1*ye(s),r=re*ye(r),o=oe*ye(o),[ve(3.1338561*r-1.6168667*s-.4906146*o),ve(-.9787684*r+1.9161415*s+.033454*o),ve(.0719453*r-.2289914*s+1.4052427*o),n]}function ve(t){return(t=t<=.00304?12.92*t:1.055*Math.pow(t,1/2.4)-.055)<0?0:t>1?1:t}function ye(t){return t>he?t*t*t:le*(t-ae)}const we=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function be(t,e){return we(t,e)?t[e]:void 0}function xe(t){return parseInt(t.padEnd(2,t),16)/255}function Me(t,e){return Se(e?t/100:t,0,1)}function Se(t,e,i){return Math.min(Math.max(e,t),i)}function ze(t){return!t.some(Number.isNaN)}const Te={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Ee(t,e,i){return t+i*(e-t)}function Ae(t,e,i){return t.map(((t,n)=>Ee(t,e[n],i)))}class Pe{constructor(t,e,i,n=1,s=!0){this.r=t,this.g=e,this.b=i,this.a=n,s||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[t,e,i,n]))}static parse(t){if(t instanceof Pe)return t;if("string"!=typeof t)return;const e=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];const e=be(Te,t);if(e){const[t,i,n]=e;return[t/255,i/255,n/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){const e=t.length<6?1:2;let i=1;return[xe(t.slice(i,i+=e)),xe(t.slice(i,i+=e)),xe(t.slice(i,i+=e)),xe(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){const e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){const[t,i,n,s,r,o,a,h,l,c,u,f]=e,d=[s||" ",a||" ",c].join("");if(" "===d||" /"===d||",,"===d||",,,"===d){const t=[n,o,l].join(""),e="%%%"===t?100:""===t?255:0;if(e){const t=[Se(+i/e,0,1),Se(+r/e,0,1),Se(+h/e,0,1),u?Me(+u,f):1];if(ze(t))return t}}return}}const i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[t,e,n,s,r,o,a,h,l]=i,c=[n||" ",r||" ",a].join("");if(" "===c||" /"===c||",,"===c||",,,"===c){const t=[+e,Se(+s,0,100),Se(+o,0,100),h?Me(+h,l):1];if(ze(t))return function([t,e,i,n]){function s(n){const s=(n+t/30)%12,r=e*Math.min(i,1-i);return i-r*Math.max(-1,Math.min(s-3,9-s,1))}return t=de(t),e/=100,i/=100,[s(0),s(8),s(4),n]}(t)}}}(t);return e?new Pe(...e,!1):void 0}get rgb(){const{r:t,g:e,b:i,a:n}=this,s=n||1/0;return this.overwriteGetter("rgb",[t/s,e/s,i/s,n])}get hcl(){return this.overwriteGetter("hcl",function(t){const[e,i,n,s]=pe(t),r=Math.sqrt(i*i+n*n);return[Math.round(1e4*r)?de(Math.atan2(n,i)*fe):NaN,r,e,s]}(this.rgb))}get lab(){return this.overwriteGetter("lab",pe(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){const[t,e,i,n]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${n})`}static interpolate(t,e,i,n="rgb"){switch(n){case"rgb":{const[n,s,r,o]=Ae(t.rgb,e.rgb,i);return new Pe(n,s,r,o,!1)}case"hcl":{const[n,s,r,o]=t.hcl,[a,h,l,c]=e.hcl;let u,f;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?u=NaN:(u=a,1!==r&&0!==r||(f=h)):(u=n,1!==l&&0!==l||(f=s));else{let t=a-n;a>n&&t>180?t-=360:a<n&&n-a>180&&(t+=360),u=n+i*t}const[d,p,m,_]=function([t,e,i,n]){return t=isNaN(t)?0:t*ue,ge([i,Math.cos(t)*e,Math.sin(t)*e,n])}([u,null!=f?f:Ee(s,h,i),Ee(r,l,i),Ee(o,c,i)]);return new Pe(d,p,m,_,!1)}case"lab":{const[n,s,r,o]=ge(Ae(t.lab,e.lab,i));return new Pe(n,s,r,o,!1)}}}}Pe.black=new Pe(0,0,0,1),Pe.white=new Pe(1,1,1,1),Pe.transparent=new Pe(0,0,0,0),Pe.red=new Pe(1,0,0,1);class Ce{constructor(t,e,i){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const De=["bottom","center","top"];class Fe{constructor(t,e,i,n,s,r){this.text=t,this.image=e,this.scale=i,this.fontStack=n,this.textColor=s,this.verticalAlign=r}}class Ie{constructor(t){this.sections=t}static fromString(t){return new Ie([new Fe(t,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Ie?t:Ie.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}}class ke{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof ke)return t;if("number"==typeof t)return new ke([t,t,t,t]);if(Array.isArray(t)&&!(t.length<1||t.length>4)){for(const e of t)if("number"!=typeof e)return;switch(t.length){case 1:t=[t[0],t[0],t[0],t[0]];break;case 2:t=[t[0],t[1],t[0],t[1]];break;case 3:t=[t[0],t[1],t[2],t[1]]}return new ke(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new ke(Ae(t.values,e.values,i))}}class $e{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof $e)return t;if("number"==typeof t)return new $e([t]);if(Array.isArray(t)){for(const e of t)if("number"!=typeof e)return;return new $e(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){return new $e(Ae(t.values,e.values,i))}}class Oe{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Oe)return t;if("string"==typeof t){const e=Pe.parse(t);if(!e)return;return new Oe([e])}if(!Array.isArray(t))return;const e=[];for(const i of t){if("string"!=typeof i)return;const t=Pe.parse(i);if(!t)return;e.push(t)}return new Oe(e)}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i,n="rgb"){const s=[];if(t.values.length!=e.values.length)throw new Error(`colorArray: Arrays have mismatched length (${t.values.length} vs. ${e.values.length}), cannot interpolate.`);for(let r=0;r<t.values.length;r++)s.push(Pe.interpolate(t.values[r],e.values[r],i,n));return new Oe(s)}}class je extends Error{constructor(t){super(t),this.name="RuntimeError"}toJSON(){return this.message}}const Re=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Le{constructor(t){this.values=t.slice()}static parse(t){if(t instanceof Le)return t;if(Array.isArray(t)&&!(t.length<1)&&t.length%2==0){for(let e=0;e<t.length;e+=2){const i=t[e],n=t[e+1];if("string"!=typeof i||!Re.has(i))return;if(!Array.isArray(n)||2!==n.length||"number"!=typeof n[0]||"number"!=typeof n[1])return}return new Le(t)}}toString(){return JSON.stringify(this.values)}static interpolate(t,e,i){const n=t.values,s=e.values;if(n.length!==s.length)throw new je(`Cannot interpolate values of different length. from: ${t.toString()}, to: ${e.toString()}`);const r=[];for(let t=0;t<n.length;t+=2){if(n[t]!==s[t])throw new je(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${n[t]}, to[${t}]: ${s[t]}`);r.push(n[t]);const[e,o]=n[t+1],[a,h]=s[t+1];r.push([Ee(e,a,i),Ee(o,h,i)])}return new Le(r)}}class Be{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Be({name:t,available:!1}):null}}class Ne{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}static interpolate(t,e,i){return new Ne(t,e,i)}static parse(t){return t instanceof Ne?t:Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]?new Ne(t[0],t[1],t[2]):"object"==typeof t&&"string"==typeof t.from&&"string"==typeof t.to&&"number"==typeof t.transition?new Ne(t.from,t.to,t.transition):"string"==typeof t?new Ne(t,t,1):void 0}}function Ue(t,e,i,n){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===n||"number"==typeof n&&n>=0&&n<=1?null:`Invalid rgba value [${[t,e,i,n].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof n?[t,e,i,n]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ge(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Ne||t instanceof Pe||t instanceof Ce||t instanceof Ie||t instanceof ke||t instanceof $e||t instanceof Oe||t instanceof Le||t instanceof Be)return!0;if(Array.isArray(t)){for(const e of t)if(!Ge(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!Ge(t[e]))return!1;return!0}return!1}function Ve(t){if(null===t)return jt;if("string"==typeof t)return Lt;if("boolean"==typeof t)return Bt;if("number"==typeof t)return Rt;if(t instanceof Pe)return Nt;if(t instanceof Ne)return Ut;if(t instanceof Ce)return qt;if(t instanceof Ie)return Zt;if(t instanceof ke)return Wt;if(t instanceof $e)return Yt;if(t instanceof Oe)return Ht;if(t instanceof Le)return Jt;if(t instanceof Be)return Xt;if(Array.isArray(t)){const e=t.length;let i;for(const e of t){const t=Ve(e);if(i){if(i===t)continue;i=Vt;break}i=t}return Kt(i||Vt,e)}return Gt}function qe(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Pe||t instanceof Ne||t instanceof Ie||t instanceof ke||t instanceof $e||t instanceof Oe||t instanceof Le||t instanceof Be?t.toString():JSON.stringify(t)}class Ze{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Ge(t[1]))return e.error("invalid value");const i=t[1];let n=Ve(i);const s=e.expectedType;return"array"!==n.kind||0!==n.N||!s||"array"!==s.kind||"number"==typeof s.N&&0!==s.N||(n=s),new Ze(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const We={string:Lt,number:Rt,boolean:Bt,object:Gt};class He{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i,n=1;const s=t[0];if("array"===s){let s,r;if(t.length>2){const i=t[1];if("string"!=typeof i||!(i in We)||"object"===i)return e.error('The item type argument of "array" must be one of string, number, boolean',1);s=We[i],n++}else s=Vt;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);r=t[2],n++}i=Kt(s,r)}else{if(!We[s])throw new Error(`Types doesn't contain name = ${s}`);i=We[s]}const r=[];for(;n<t.length;n++){const i=e.parse(t[n],n,Vt);if(!i)return null;r.push(i)}return new He(i,r)}evaluate(t){for(let e=0;e<this.args.length;e++){const i=this.args[e].evaluate(t);if(!ee(this.type,Ve(i)))return i;if(e===this.args.length-1)throw new je(`Expected value to be of type ${Qt(this.type)}, but found ${Qt(Ve(i))} instead.`)}throw new Error}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Ye={"to-boolean":Bt,"to-color":Nt,"to-number":Rt,"to-string":Lt};class Xe{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[0];if(!Ye[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==t.length)return e.error("Expected one argument.");const n=Ye[i],s=[];for(let i=1;i<t.length;i++){const n=e.parse(t[i],i,Vt);if(!n)return null;s.push(n)}return new Xe(n,s)}evaluate(t){switch(this.type.kind){case"boolean":return Boolean(this.args[0].evaluate(t));case"color":{let e,i;for(const n of this.args){if(e=n.evaluate(t),i=null,e instanceof Pe)return e;if("string"==typeof e){const i=t.parseColor(e);if(i)return i}else if(Array.isArray(e)&&(i=e.length<3||e.length>4?`Invalid rgba value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Ue(e[0],e[1],e[2],e[3]),!i))return new Pe(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new je(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"padding":{let e;for(const i of this.args){e=i.evaluate(t);const n=ke.parse(e);if(n)return n}throw new je(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"numberArray":{let e;for(const i of this.args){e=i.evaluate(t);const n=$e.parse(e);if(n)return n}throw new je(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"colorArray":{let e;for(const i of this.args){e=i.evaluate(t);const n=Oe.parse(e);if(n)return n}throw new je(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"variableAnchorOffsetCollection":{let e;for(const i of this.args){e=i.evaluate(t);const n=Le.parse(e);if(n)return n}throw new je(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`)}case"number":{let e=null;for(const i of this.args){if(e=i.evaluate(t),null===e)return 0;const n=Number(e);if(!isNaN(n))return n}throw new je(`Could not convert ${JSON.stringify(e)} to number.`)}case"formatted":return Ie.fromString(qe(this.args[0].evaluate(t)));case"resolvedImage":return Be.fromString(qe(this.args[0].evaluate(t)));case"projectionDefinition":return this.args[0].evaluate(t);default:return qe(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}const Je=["Unknown","Point","LineString","Polygon"];class Ke{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Je[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(t){let e=this._parseColorCache.get(t);return e||(e=Pe.parse(t),this._parseColorCache.set(t,e)),e}}class Qe{constructor(t,e,i=[],n,s=new Ot,r=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=s,this.errors=r,this.expectedType=n,this._isConstant=e}parse(t,e,i,n,s={}){return e?this.concat(e,i,n)._parse(t,s):this._parse(t,s)}_parse(t,e){function i(t,e,i){return"assert"===i?new He(e,[t]):"coerce"===i?new Xe(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=t[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[n];if(s){let n=s.parse(t,this);if(!n)return null;if(this.expectedType){const t=this.expectedType,s=n.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==s.kind){if("projectionDefinition"===t.kind&&["string","array"].includes(s.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(s.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(s.kind)||"colorArray"===t.kind&&["value","string","array"].includes(s.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(s.kind))n=i(n,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,s))return null}else n=i(n,t,e.typeAnnotation||"assert")}if(!(n instanceof Ze)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const e=new Ke;try{n=new Ze(n.type,n.evaluate(e))}catch(t){return this.error(t.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,i){const n="number"==typeof t?this.path.concat(t):this.path,s=i?this.scope.concat(i):this.scope;return new Qe(this.registry,this._isConstant,n,e||null,s,this.errors)}error(t,...e){const i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new $t(i,t))}checkSubtype(t,e){const i=ee(t,e);return i&&this.error(i),i}}class ti{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const i=[];for(let n=1;n<t.length-1;n+=2){const s=t[n];if("string"!=typeof s)return e.error(`Expected string, but found ${typeof s} instead.`,n);if(/[^a-zA-Z0-9_]/.test(s))return e.error("Variable names must contain only alphanumeric characters or '_'.",n);const r=e.parse(t[n+1],n+1);if(!r)return null;i.push([s,r])}const n=e.parse(t[t.length-1],t.length-1,e.expectedType,i);return n?new ti(i,n):null}outputDefined(){return this.result.outputDefined()}}class ei{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const i=t[1];return e.scope.has(i)?new ei(i,e.scope.get(i)):e.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}}class ii{constructor(t,e,i){this.type=t,this.index=e,this.input=i}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Rt),n=e.parse(t[2],2,Kt(e.expectedType||Vt));return i&&n?new ii(n.type.itemType,i,n):null}evaluate(t){const e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new je(`Array index out of bounds: ${e} < 0.`);if(e>=i.length)throw new je(`Array index out of bounds: ${e} > ${i.length-1}.`);if(e!==Math.floor(e))throw new je(`Array index must be an integer, but found ${e} instead.`);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}}class ni{constructor(t,e){this.type=Bt,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Vt),n=e.parse(t[2],2,Vt);return i&&n?ie(i.type,[Bt,Lt,Rt,jt,Vt])?new ni(i,n):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(i.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!ne(e,["boolean","string","number","null"]))throw new je(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(Ve(e))} instead.`);if(!ne(i,["string","array"]))throw new je(`Expected second argument to be of type array or string, but found ${Qt(Ve(i))} instead.`);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}}class si{constructor(t,e,i){this.type=Rt,this.needle=t,this.haystack=e,this.fromIndex=i}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Vt),n=e.parse(t[2],2,Vt);if(!i||!n)return null;if(!ie(i.type,[Bt,Lt,Rt,jt,Vt]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Rt);return s?new si(i,n,s):null}return new si(i,n)}evaluate(t){const e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!ne(e,["boolean","string","number","null"]))throw new je(`Expected first argument to be of type boolean, string, number or null, but found ${Qt(Ve(e))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(t)),ne(i,["string"])){const t=i.indexOf(e,n);return-1===t?-1:[...i.slice(0,t)].length}if(ne(i,["array"]))return i.indexOf(e,n);throw new je(`Expected second argument to be of type array or string, but found ${Qt(Ve(i))} instead.`)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}}class ri{constructor(t,e,i,n,s,r){this.inputType=t,this.type=e,this.input=i,this.cases=n,this.outputs=s,this.otherwise=r}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let i,n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const s={},r=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const h=t[o+1];Array.isArray(a)||(a=[a]);const l=e.concat(o);if(0===a.length)return l.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return l.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return l.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return l.error("Numeric branch labels must be integer values.");if(i){if(l.checkSubtype(i,Ve(t)))return null}else i=Ve(t);if(void 0!==s[String(t)])return l.error("Branch labels must be unique.");s[String(t)]=r.length}const c=e.parse(h,o,n);if(!c)return null;n=n||c.type,r.push(c)}const o=e.parse(t[1],1,Vt);if(!o)return null;const a=e.parse(t[t.length-1],t.length-1,n);return a?"value"!==o.type.kind&&e.concat(1).checkSubtype(i,o.type)?null:new ri(i,n,o,s,r,a):null}evaluate(t){const e=this.input.evaluate(t);return(Ve(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}}class oi{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let i;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);const n=[];for(let s=1;s<t.length-1;s+=2){const r=e.parse(t[s],s,Bt);if(!r)return null;const o=e.parse(t[s+1],s+1,i);if(!o)return null;n.push([r,o]),i=i||o.type}const s=e.parse(t[t.length-1],t.length-1,i);if(!s)return null;if(!i)throw new Error("Can't infer output type");return new oi(i,n,s)}evaluate(t){for(const[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}}class ai{constructor(t,e,i,n){this.type=t,this.input=e,this.beginIndex=i,this.endIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 2 or 3 arguments, but found ${t.length-1} instead.`);const i=e.parse(t[1],1,Vt),n=e.parse(t[2],2,Rt);if(!i||!n)return null;if(!ie(i.type,[Kt(Vt),Lt,Vt]))return e.error(`Expected first argument to be of type array or string, but found ${Qt(i.type)} instead`);if(4===t.length){const s=e.parse(t[3],3,Rt);return s?new ai(i.type,i,n,s):null}return new ai(i.type,i,n)}evaluate(t){const e=this.input.evaluate(t),i=this.beginIndex.evaluate(t);let n;if(this.endIndex&&(n=this.endIndex.evaluate(t)),ne(e,["string"]))return[...e].slice(i,n).join("");if(ne(e,["array"]))return e.slice(i,n);throw new je(`Expected first argument to be of type array or string, but found ${Qt(Ve(e))} instead.`)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}}function hi(t,e){const i=t.length-1;let n,s,r=0,o=i,a=0;for(;r<=o;)if(a=Math.floor((r+o)/2),n=t[a],s=t[a+1],n<=e){if(a===i||e<s)return a;r=a+1}else{if(!(n>e))throw new je("Input is not a number.");o=a-1}return 0}class li{constructor(t,e,i){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const i=e.parse(t[1],1,Rt);if(!i)return null;const n=[];let s=null;e.expectedType&&"value"!==e.expectedType.kind&&(s=e.expectedType);for(let i=1;i<t.length;i+=2){const r=1===i?-1/0:t[i],o=t[i+1],a=i,h=i+1;if("number"!=typeof r)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',a);if(n.length&&n[n.length-1][0]>=r)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const l=e.parse(o,h,s);if(!l)return null;s=s||l.type,n.push([r,l])}return new li(s,i,n)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const s=e.length;return n>=e[s-1]?i[s-1].evaluate(t):i[hi(e,n)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}var ci,ui,fi=function(){if(ui)return ci;function t(t,e,i,n){this.cx=3*t,this.bx=3*(i-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(n-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=i,this.p2y=n}return ui=1,ci=t,t.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var i=t,n=0;n<8;n++){var s=this.sampleCurveX(i)-t;if(Math.abs(s)<e)return i;var r=this.sampleCurveDerivativeX(i);if(Math.abs(r)<1e-6)break;i-=s/r}var o=0,a=1;for(i=t,n=0;n<20&&(s=this.sampleCurveX(i),!(Math.abs(s-t)<e));n++)t>s?o=i:a=i,i=.5*(a-o)+o;return i},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}},ci}(),di=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(fi);class pi{constructor(t,e,i,n,s){this.type=t,this.operator=e,this.interpolation=i,this.input=n,this.labels=[],this.outputs=[];for(const[t,e]of s)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,n){let s=0;if("exponential"===t.name)s=mi(e,t.base,i,n);else if("linear"===t.name)s=mi(e,1,i,n);else if("cubic-bezier"===t.name){const r=t.controlPoints;s=new di(r[0],r[1],r[2],r[3]).solve(mi(e,1,i,n))}return s}static parse(t,e){let[i,n,s,...r]=t;if(!Array.isArray(n)||0===n.length)return e.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){const t=n[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t}}else{if("cubic-bezier"!==n[0])return e.error(`Unknown interpolation type ${String(n[0])}`,1,0);{const t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(s=e.parse(s,2,Rt),!s)return null;const o=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||e.expectedType==Ht?e.expectedType&&"value"!==e.expectedType.kind&&(a=e.expectedType):a=Nt;for(let t=0;t<r.length;t+=2){const i=r[t],n=r[t+1],s=t+3,h=t+4;if("number"!=typeof i)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',s);if(o.length&&o[o.length-1][0]>=i)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',s);const l=e.parse(n,h,a);if(!l)return null;a=a||l.type,o.push([i,l])}return se(a,Rt)||se(a,Ut)||se(a,Nt)||se(a,Wt)||se(a,Yt)||se(a,Ht)||se(a,Jt)||se(a,Kt(Rt))?new pi(a,i,n,s,o):e.error(`Type ${Qt(a)} is not interpolatable.`)}evaluate(t){const e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);const n=this.input.evaluate(t);if(n<=e[0])return i[0].evaluate(t);const s=e.length;if(n>=e[s-1])return i[s-1].evaluate(t);const r=hi(e,n),o=pi.interpolationFactor(this.interpolation,n,e[r],e[r+1]),a=i[r].evaluate(t),h=i[r+1].evaluate(t);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Ee(a,h,o);case"color":return Pe.interpolate(a,h,o);case"padding":return ke.interpolate(a,h,o);case"colorArray":return Oe.interpolate(a,h,o);case"numberArray":return $e.interpolate(a,h,o);case"variableAnchorOffsetCollection":return Le.interpolate(a,h,o);case"array":return Ae(a,h,o);case"projectionDefinition":return Ne.interpolate(a,h,o)}case"interpolate-hcl":switch(this.type.kind){case"color":return Pe.interpolate(a,h,o,"hcl");case"colorArray":return Oe.interpolate(a,h,o,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Pe.interpolate(a,h,o,"lab");case"colorArray":return Oe.interpolate(a,h,o,"lab")}}}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}}function mi(t,e,i,n){const s=n-i,r=t-i;return 0===s?0:1===e?r/s:(Math.pow(e,r)-1)/(Math.pow(e,s)-1)}const _i={color:Pe.interpolate,number:Ee,padding:ke.interpolate,numberArray:$e.interpolate,colorArray:Oe.interpolate,variableAnchorOffsetCollection:Le.interpolate,array:Ae};class gi{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let i=null;const n=e.expectedType;n&&"value"!==n.kind&&(i=n);const s=[];for(const n of t.slice(1)){const t=e.parse(n,1+s.length,i,void 0,{typeAnnotation:"omit"});if(!t)return null;i=i||t.type,s.push(t)}if(!i)throw new Error("No output type");const r=n&&s.some((t=>ee(n,t.type)));return new gi(r?Vt:i,s)}evaluate(t){let e,i=null,n=0;for(const s of this.args)if(n++,i=s.evaluate(t),i&&i instanceof Be&&!i.available&&(e||(e=i.name),i=null,n===this.args.length&&(i=e)),null!==i)break;return i}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}}function vi(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function yi(t,e,i,n){return 0===n.compare(e,i)}function wi(t,e,i){const n="=="!==t&&"!="!==t;return class s{constructor(t,e,i){this.type=Bt,this.lhs=t,this.rhs=e,this.collator=i,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const i=t[0];let r=e.parse(t[1],1,Vt);if(!r)return null;if(!vi(i,r.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Qt(r.type)}'.`);let o=e.parse(t[2],2,Vt);if(!o)return null;if(!vi(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Qt(o.type)}'.`);if(r.type.kind!==o.type.kind&&"value"!==r.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Qt(r.type)}' and '${Qt(o.type)}'.`);n&&("value"===r.type.kind&&"value"!==o.type.kind?r=new He(o.type,[r]):"value"!==r.type.kind&&"value"===o.type.kind&&(o=new He(r.type,[o])));let a=null;if(4===t.length){if("string"!==r.type.kind&&"string"!==o.type.kind&&"value"!==r.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,qt),!a)return null}return new s(r,o,a)}evaluate(s){const r=this.lhs.evaluate(s),o=this.rhs.evaluate(s);if(n&&this.hasUntypedArgument){const e=Ve(r),i=Ve(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new je(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`)}if(this.collator&&!n&&this.hasUntypedArgument){const t=Ve(r),i=Ve(o);if("string"!==t.kind||"string"!==i.kind)return e(s,r,o)}return this.collator?i(s,r,o,this.collator.evaluate(s)):e(s,r,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const bi=wi("==",(function(t,e,i){return e===i}),yi),xi=wi("!=",(function(t,e,i){return e!==i}),(function(t,e,i,n){return!yi(0,e,i,n)})),Mi=wi("<",(function(t,e,i){return e<i}),(function(t,e,i,n){return n.compare(e,i)<0})),Si=wi(">",(function(t,e,i){return e>i}),(function(t,e,i,n){return n.compare(e,i)>0})),zi=wi("<=",(function(t,e,i){return e<=i}),(function(t,e,i,n){return n.compare(e,i)<=0})),Ti=wi(">=",(function(t,e,i){return e>=i}),(function(t,e,i,n){return n.compare(e,i)>=0}));class Ei{constructor(t,e,i){this.type=qt,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const i=t[1];if("object"!=typeof i||Array.isArray(i))return e.error("Collator options argument must be an object.");const n=e.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Bt);if(!n)return null;const s=e.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Bt);if(!s)return null;let r=null;return i.locale&&(r=e.parse(i.locale,1,Lt),!r)?null:new Ei(n,s,r)}evaluate(t){return new Ce(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}}class Ai{constructor(t,e,i,n,s,r){this.type=Lt,this.number=t,this.locale=e,this.currency=i,this.unit=n,this.minFractionDigits=s,this.maxFractionDigits=r}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Rt);if(!i)return null;const n=t[2];if("object"!=typeof n||Array.isArray(n))return e.error("NumberFormat options argument must be an object.");let s=null;if(n.locale&&(s=e.parse(n.locale,1,Lt),!s))return null;let r=null;if(n.currency&&(r=e.parse(n.currency,1,Lt),!r))return null;let o=null;if(n.unit&&(o=e.parse(n.unit,1,Lt),!o))return null;if(r&&o)return e.error("NumberFormat options `currency` and `unit` are mutually exclusive");let a=null;if(n["min-fraction-digits"]&&(a=e.parse(n["min-fraction-digits"],1,Rt),!a))return null;let h=null;return n["max-fraction-digits"]&&(h=e.parse(n["max-fraction-digits"],1,Rt),!h)?null:new Ai(i,s,r,o,a,h)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:this.currency?"currency":this.unit?"unit":"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}}class Pi{constructor(t){this.type=Zt,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const i=t[1];if(!Array.isArray(i)&&"object"==typeof i)return e.error("First argument must be an image or text section.");const n=[];let s=!1;for(let i=1;i<=t.length-1;++i){const r=t[i];if(s&&"object"==typeof r&&!Array.isArray(r)){s=!1;let t=null;if(r["font-scale"]&&(t=e.parse(r["font-scale"],1,Rt),!t))return null;let i=null;if(r["text-font"]&&(i=e.parse(r["text-font"],1,Kt(Lt)),!i))return null;let o=null;if(r["text-color"]&&(o=e.parse(r["text-color"],1,Nt),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!De.includes(r["vertical-align"]))return e.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(a=e.parse(r["vertical-align"],1,Lt),!a)return null}const h=n[n.length-1];h.scale=t,h.font=i,h.textColor=o,h.verticalAlign=a}else{const r=e.parse(t[i],1,Vt);if(!r)return null;const o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,n.push({content:r,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Pi(n)}evaluate(t){return new Ie(this.sections.map((e=>{const i=e.content.evaluate(t);return Ve(i)===Xt?new Fe("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new Fe(qe(i),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null,e.verticalAlign?e.verticalAlign.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor),e.verticalAlign&&t(e.verticalAlign)}outputDefined(){return!1}}class Ci{constructor(t){this.type=Xt,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const i=e.parse(t[1],1,Lt);return i?new Ci(i):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),i=Be.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}}class Di{constructor(t){this.type=Rt,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=e.parse(t[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?e.error(`Expected argument of type string or array, but found ${Qt(i.type)} instead.`):new Di(i):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new je(`Expected value to be of type string or array, but found ${Qt(Ve(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}}const Fi=8192;function Ii(t,e){const i=(180+t[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,s=Math.pow(2,e.z);return[Math.round(i*s*Fi),Math.round(n*s*Fi)]}function ki(t,e){const i=Math.pow(2,e.z);return[(s=(t[0]/Fi+e.x)/i,360*s-180),(n=(t[1]/Fi+e.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,s}function $i(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function Oi(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function ji(t,e,i){const n=t[0]-e[0],s=t[1]-e[1],r=t[0]-i[0],o=t[1]-i[1];return n*o-r*s==0&&n*r<=0&&s*o<=0}function Ri(t,e,i,n){return 0!=(s=[n[0]-i[0],n[1]-i[1]])[0]*(r=[e[0]-t[0],e[1]-t[1]])[1]-s[1]*r[0]&&!(!Vi(t,e,i,n)||!Vi(i,n,t,e));var s,r}function Li(t,e,i){for(const n of i)for(let i=0;i<n.length-1;++i)if(Ri(t,e,n[i],n[i+1]))return!0;return!1}function Bi(t,e,i=!1){let n=!1;for(const a of e)for(let e=0;e<a.length-1;e++){if(ji(t,a[e],a[e+1]))return i;(r=a[e])[1]>(s=t)[1]!=(o=a[e+1])[1]>s[1]&&s[0]<(o[0]-r[0])*(s[1]-r[1])/(o[1]-r[1])+r[0]&&(n=!n)}var s,r,o;return n}function Ni(t,e){for(const i of e)if(Bi(t,i))return!0;return!1}function Ui(t,e){for(const i of t)if(!Bi(i,e))return!1;for(let i=0;i<t.length-1;++i)if(Li(t[i],t[i+1],e))return!1;return!0}function Gi(t,e){for(const i of e)if(Ui(t,i))return!0;return!1}function Vi(t,e,i,n){const s=n[0]-i[0],r=n[1]-i[1],o=(t[0]-i[0])*r-s*(t[1]-i[1]),a=(e[0]-i[0])*r-s*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function qi(t,e,i){const n=[];for(let s=0;s<t.length;s++){const r=[];for(let n=0;n<t[s].length;n++){const o=Ii(t[s][n],i);$i(e,o),r.push(o)}n.push(r)}return n}function Zi(t,e,i){const n=[];for(let s=0;s<t.length;s++){const r=qi(t[s],e,i);n.push(r)}return n}function Wi(t,e,i,n){if(t[0]<i[0]||t[0]>i[2]){const e=.5*n;let s=t[0]-i[0]>e?-n:i[0]-t[0]>e?n:0;0===s&&(s=t[0]-i[2]>e?-n:i[2]-t[0]>e?n:0),t[0]+=s}$i(e,t)}function Hi(t,e,i,n){const s=Math.pow(2,n.z)*Fi,r=[n.x*Fi,n.y*Fi],o=[];for(const n of t)for(const t of n){const n=[t.x+r[0],t.y+r[1]];Wi(n,e,i,s),o.push(n)}return o}function Yi(t,e,i,n){const s=Math.pow(2,n.z)*Fi,r=[n.x*Fi,n.y*Fi],o=[];for(const i of t){const t=[];for(const n of i){const i=[n.x+r[0],n.y+r[1]];$i(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=s/2){(a=e)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const n of t)Wi(n,e,i,s)}var a;return o}class Xi{constructor(t,e){this.type=Bt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ge(t[1])){const e=t[1];if("FeatureCollection"===e.type){const t=[];for(const i of e.features){const{type:e,coordinates:n}=i.geometry;"Polygon"===e&&t.push(n),"MultiPolygon"===e&&t.push(...n)}if(t.length)return new Xi(e,{type:"MultiPolygon",coordinates:t})}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Xi(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Xi(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const r=qi(e.coordinates,n,s),o=Hi(t.geometry(),i,n,s);if(!Oi(i,n))return!1;for(const t of o)if(!Bi(t,r))return!1}if("MultiPolygon"===e.type){const r=Zi(e.coordinates,n,s),o=Hi(t.geometry(),i,n,s);if(!Oi(i,n))return!1;for(const t of o)if(!Ni(t,r))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=[1/0,1/0,-1/0,-1/0],n=[1/0,1/0,-1/0,-1/0],s=t.canonicalID();if("Polygon"===e.type){const r=qi(e.coordinates,n,s),o=Yi(t.geometry(),i,n,s);if(!Oi(i,n))return!1;for(const t of o)if(!Ui(t,r))return!1}if("MultiPolygon"===e.type){const r=Zi(e.coordinates,n,s),o=Yi(t.geometry(),i,n,s);if(!Oi(i,n))return!1;for(const t of o)if(!Gi(t,r))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let Ji=class{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const s=t-1>>1,r=e[s];if(i(n,r)>=0)break;e[t]=r,t=s}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,s=e[t];for(;t<n;){let n=1+(t<<1);const r=n+1;if(r<this.length&&i(e[r],e[n])<0&&(n=r),i(e[n],s)>=0)break;e[t]=e[n],t=n}e[t]=s}};function Ki(t,e,i=0,n=t.length-1,s=tn){for(;n>i;){if(n-i>600){const r=n-i+1,o=e-i+1,a=Math.log(r),h=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*h*(r-h)/r)*(o-r/2<0?-1:1);Ki(t,e,Math.max(i,Math.floor(e-o*h/r+l)),Math.min(n,Math.floor(e+(r-o)*h/r+l)),s)}const r=t[e];let o=i,a=n;for(Qi(t,i,e),s(t[n],r)>0&&Qi(t,i,n);o<a;){for(Qi(t,o,a),o++,a--;s(t[o],r)<0;)o++;for(;s(t[a],r)>0;)a--}0===s(t[i],r)?Qi(t,i,a):(a++,Qi(t,a,n)),a<=e&&(i=a+1),e<=a&&(n=a-1)}}function Qi(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function tn(t,e){return t<e?-1:t>e?1:0}function en(t,e){if(t.length<=1)return[t];const i=[];let n,s;for(const e of t){const t=sn(e);0!==t&&(e.area=Math.abs(t),void 0===s&&(s=t<0),s===t<0?(n&&i.push(n),n=[e]):n.push(e))}if(n&&i.push(n),e>1)for(let t=0;t<i.length;t++)i[t].length<=e||(Ki(i[t],e,1,i[t].length-1,nn),i[t]=i[t].slice(0,e));return i}function nn(t,e){return e.area-t.area}function sn(t){let e=0;for(let i,n,s=0,r=t.length,o=r-1;s<r;o=s++)i=t[s],n=t[o],e+=(n.x-i.x)*(i.y+n.y);return e}const rn=1/298.257223563,on=rn*(2-rn),an=Math.PI/180;class hn{constructor(t){const e=6378.137*an*1e3,i=Math.cos(t*an),n=1/(1-on*(1-i*i)),s=Math.sqrt(n);this.kx=e*s*i,this.ky=e*s*n*(1-on)}distance(t,e){const i=this.wrap(t[0]-e[0])*this.kx,n=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+n*n)}pointOnLine(t,e){let i,n,s,r,o=1/0;for(let a=0;a<t.length-1;a++){let h=t[a][0],l=t[a][1],c=this.wrap(t[a+1][0]-h)*this.kx,u=(t[a+1][1]-l)*this.ky,f=0;0===c&&0===u||(f=(this.wrap(e[0]-h)*this.kx*c+(e[1]-l)*this.ky*u)/(c*c+u*u),f>1?(h=t[a+1][0],l=t[a+1][1]):f>0&&(h+=c/this.kx*f,l+=u/this.ky*f)),c=this.wrap(e[0]-h)*this.kx,u=(e[1]-l)*this.ky;const d=c*c+u*u;d<o&&(o=d,i=h,n=l,s=a,r=f)}return{point:[i,n],index:s,t:Math.max(0,Math.min(1,r))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}}function ln(t,e){return e[0]-t[0]}function cn(t){return t[1]-t[0]+1}function un(t,e){return t[1]>=t[0]&&t[1]<e}function fn(t,e){if(t[0]>t[1])return[null,null];const i=cn(t);if(e){if(2===i)return[t,null];const e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];const n=Math.floor(i/2)-1;return[[t[0],t[0]+n],[t[0]+n+1,t[1]]]}function dn(t,e){if(!un(e,t.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=e[0];n<=e[1];++n)$i(i,t[n]);return i}function pn(t){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const t of i)$i(e,t);return e}function mn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function _n(t,e,i){if(!mn(t)||!mn(e))return NaN;let n=0,s=0;return t[2]<e[0]&&(n=e[0]-t[2]),t[0]>e[2]&&(n=t[0]-e[2]),t[1]>e[3]&&(s=t[1]-e[3]),t[3]<e[1]&&(s=e[1]-t[3]),i.distance([0,0],[n,s])}function gn(t,e,i){const n=i.pointOnLine(e,t);return i.distance(t,n.point)}function vn(t,e,i,n,s){const r=Math.min(gn(t,[i,n],s),gn(e,[i,n],s)),o=Math.min(gn(i,[t,e],s),gn(n,[t,e],s));return Math.min(r,o)}function yn(t,e,i,n,s){if(!un(e,t.length)||!un(n,i.length))return 1/0;let r=1/0;for(let o=e[0];o<e[1];++o){const e=t[o],a=t[o+1];for(let t=n[0];t<n[1];++t){const n=i[t],o=i[t+1];if(Ri(e,a,n,o))return 0;r=Math.min(r,vn(e,a,n,o,s))}}return r}function wn(t,e,i,n,s){if(!un(e,t.length)||!un(n,i.length))return NaN;let r=1/0;for(let o=e[0];o<=e[1];++o)for(let e=n[0];e<=n[1];++e)if(r=Math.min(r,s.distance(t[o],i[e])),0===r)return r;return r}function bn(t,e,i){if(Bi(t,e,!0))return 0;let n=1/0;for(const s of e){const e=s[0],r=s[s.length-1];if(e!==r&&(n=Math.min(n,gn(t,[r,e],i)),0===n))return n;const o=i.pointOnLine(s,t);if(n=Math.min(n,i.distance(t,o.point)),0===n)return n}return n}function xn(t,e,i,n){if(!un(e,t.length))return NaN;for(let n=e[0];n<=e[1];++n)if(Bi(t[n],i,!0))return 0;let s=1/0;for(let r=e[0];r<e[1];++r){const e=t[r],o=t[r+1];for(const t of i)for(let i=0,r=t.length,a=r-1;i<r;a=i++){const r=t[a],h=t[i];if(Ri(e,o,r,h))return 0;s=Math.min(s,vn(e,o,r,h,n))}}return s}function Mn(t,e){for(const i of t)for(const t of i)if(Bi(t,e,!0))return!0;return!1}function Sn(t,e,i,n=1/0){const s=pn(t),r=pn(e);if(n!==1/0&&_n(s,r,i)>=n)return n;if(Oi(s,r)){if(Mn(t,e))return 0}else if(Mn(e,t))return 0;let o=1/0;for(const n of t)for(let t=0,s=n.length,r=s-1;t<s;r=t++){const s=n[r],a=n[t];for(const t of e)for(let e=0,n=t.length,r=n-1;e<n;r=e++){const n=t[r],h=t[e];if(Ri(s,a,n,h))return 0;o=Math.min(o,vn(s,a,n,h,i))}}return o}function zn(t,e,i,n,s,r){if(!r)return;const o=_n(dn(n,r),s,i);o<e&&t.push([o,r,[0,0]])}function Tn(t,e,i,n,s,r,o){if(!r||!o)return;const a=_n(dn(n,r),dn(s,o),i);a<e&&t.push([a,r,o])}function En(t,e,i,n,s=1/0){let r=Math.min(n.distance(t[0],i[0][0]),s);if(0===r)return r;const o=new Ji([[0,[0,t.length-1],[0,0]]],ln),a=pn(i);for(;o.length>0;){const s=o.pop();if(s[0]>=r)continue;const h=s[1],l=e?50:100;if(cn(h)<=l){if(!un(h,t.length))return NaN;if(e){const e=xn(t,h,i,n);if(isNaN(e)||0===e)return e;r=Math.min(r,e)}else for(let e=h[0];e<=h[1];++e){const s=bn(t[e],i,n);if(r=Math.min(r,s),0===r)return 0}}else{const i=fn(h,e);zn(o,r,n,t,a,i[0]),zn(o,r,n,t,a,i[1])}}return r}function An(t,e,i,n,s,r=1/0){let o=Math.min(r,s.distance(t[0],i[0]));if(0===o)return o;const a=new Ji([[0,[0,t.length-1],[0,i.length-1]]],ln);for(;a.length>0;){const r=a.pop();if(r[0]>=o)continue;const h=r[1],l=r[2],c=e?50:100,u=n?50:100;if(cn(h)<=c&&cn(l)<=u){if(!un(h,t.length)&&un(l,i.length))return NaN;let r;if(e&&n)r=yn(t,h,i,l,s),o=Math.min(o,r);else if(e&&!n){const e=t.slice(h[0],h[1]+1);for(let t=l[0];t<=l[1];++t)if(r=gn(i[t],e,s),o=Math.min(o,r),0===o)return o}else if(!e&&n){const e=i.slice(l[0],l[1]+1);for(let i=h[0];i<=h[1];++i)if(r=gn(t[i],e,s),o=Math.min(o,r),0===o)return o}else r=wn(t,h,i,l,s),o=Math.min(o,r)}else{const r=fn(h,e),c=fn(l,n);Tn(a,o,s,t,i,r[0],c[0]),Tn(a,o,s,t,i,r[0],c[1]),Tn(a,o,s,t,i,r[1],c[0]),Tn(a,o,s,t,i,r[1],c[1])}}return o}function Pn(t){return"MultiPolygon"===t.type?t.coordinates.map((t=>({type:"Polygon",coordinates:t}))):"MultiLineString"===t.type?t.coordinates.map((t=>({type:"LineString",coordinates:t}))):"MultiPoint"===t.type?t.coordinates.map((t=>({type:"Point",coordinates:t}))):[t]}class Cn{constructor(t,e){this.type=Rt,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'distance' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Ge(t[1])){const e=t[1];if("FeatureCollection"===e.type)return new Cn(e,e.features.map((t=>Pn(t.geometry))).flat());if("Feature"===e.type)return new Cn(e,Pn(e.geometry));if("type"in e&&"coordinates"in e)return new Cn(e,Pn(e))}return e.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const i=t.geometry(),n=i.flat().map((e=>ki([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const s=new hn(n[0][1]);let r=1/0;for(const t of e){switch(t.type){case"Point":r=Math.min(r,An(n,!1,[t.coordinates],!1,s,r));break;case"LineString":r=Math.min(r,An(n,!1,t.coordinates,!0,s,r));break;case"Polygon":r=Math.min(r,En(n,!1,t.coordinates,s,r))}if(0===r)return r}return r}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const i=t.geometry(),n=i.flat().map((e=>ki([e.x,e.y],t.canonical)));if(0===i.length)return NaN;const s=new hn(n[0][1]);let r=1/0;for(const t of e){switch(t.type){case"Point":r=Math.min(r,An(n,!0,[t.coordinates],!1,s,r));break;case"LineString":r=Math.min(r,An(n,!0,t.coordinates,!0,s,r));break;case"Polygon":r=Math.min(r,En(n,!0,t.coordinates,s,r))}if(0===r)return r}return r}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){const i=t.geometry();if(0===i.length||0===i[0].length)return NaN;const n=en(i,0).map((e=>e.map((e=>e.map((e=>ki([e.x,e.y],t.canonical))))))),s=new hn(n[0][0][0][1]);let r=1/0;for(const t of e)for(const e of n){switch(t.type){case"Point":r=Math.min(r,En([t.coordinates],!1,e,s,r));break;case"LineString":r=Math.min(r,En(t.coordinates,!0,e,s,r));break;case"Polygon":r=Math.min(r,Sn(e,t.coordinates,s,r))}if(0===r)return r}return r}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Dn{constructor(t){this.type=Vt,this.key=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const i=t[1];return null==i?e.error("Global state property must be defined."):"string"!=typeof i?e.error(`Global state property must be string, but found ${typeof t[1]} instead.`):new Dn(i)}evaluate(t){var e;const i=null===(e=t.globals)||void 0===e?void 0:e.globalState;return i&&0!==Object.keys(i).length?be(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Fn={"==":bi,"!=":xi,">":Si,"<":Mi,">=":Ti,"<=":zi,array:He,at:ii,boolean:He,case:oi,coalesce:gi,collator:Ei,format:Pi,image:Ci,in:ni,"index-of":si,interpolate:pi,"interpolate-hcl":pi,"interpolate-lab":pi,length:Di,let:ti,literal:Ze,match:ri,number:He,"number-format":Ai,object:He,slice:ai,step:li,string:He,"to-boolean":Xe,"to-color":Xe,"to-number":Xe,"to-string":Xe,var:ei,within:Xi,distance:Cn,"global-state":Dn};class In{constructor(t,e,i,n){this.name=t,this.type=e,this._evaluate=i,this.args=n}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(t,e){const i=t[0],n=In.definitions[i];if(!n)return e.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(n)?n[0]:n.type,r=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,o=r.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let a=null;for(const[n,r]of o){a=new Qe(e.registry,Rn,e.path,null,e.scope);const o=[];let h=!1;for(let e=1;e<t.length;e++){const i=t[e],s=Array.isArray(n)?n[e-1]:n.type,r=a.parse(i,1+o.length,s);if(!r){h=!0;break}o.push(r)}if(!h)if(Array.isArray(n)&&n.length!==o.length)a.error(`Expected ${n.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const e=Array.isArray(n)?n[t]:n.type,i=o[t];a.concat(t+1).checkSubtype(e,i.type)}if(0===a.errors.length)return new In(i,s,r,o)}}if(1===o.length)e.errors.push(...a.errors);else{const i=(o.length?o:r).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Qt).join(", ")})`:`(${Qt(e.type)}...)`;var e})).join(" | "),n=[];for(let i=1;i<t.length;i++){const s=e.parse(t[i],1+n.length);if(!s)return null;n.push(Qt(s.type))}e.error(`Expected arguments of type ${i}, but found (${n.join(", ")}) instead.`)}return null}static register(t,e){In.definitions=e;for(const i in e)t[i]=In}}function kn(t,[e,i,n,s]){e=e.evaluate(t),i=i.evaluate(t),n=n.evaluate(t);const r=s?s.evaluate(t):1,o=Ue(e,i,n,r);if(o)throw new je(o);return new Pe(e/255,i/255,n/255,r,!1)}function $n(t,e){return t in e}function On(t,e){const i=e[t];return void 0===i?null:i}function jn(t){return{type:t}}function Rn(t){if(t instanceof ei)return Rn(t.boundExpression);if(t instanceof In&&"error"===t.name)return!1;if(t instanceof Ei)return!1;if(t instanceof Xi)return!1;if(t instanceof Cn)return!1;if(t instanceof Dn)return!1;const e=t instanceof Xe||t instanceof He;let i=!0;return t.eachChild((t=>{i=e?i&&Rn(t):i&&t instanceof Ze})),!!i&&Ln(t)&&Nn(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Ln(t){if(t instanceof In){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Xi)return!1;if(t instanceof Cn)return!1;let e=!0;return t.eachChild((t=>{e&&!Ln(t)&&(e=!1)})),e}function Bn(t){if(t instanceof In&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Bn(t)&&(e=!1)})),e}function Nn(t,e){if(t instanceof In&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!Nn(t,e)&&(i=!1)})),i}function Un(t){return{result:"success",value:t}}function Gn(t){return{result:"error",value:t}}function Vn(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function qn(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function Zn(t){return!!t.expression&&t.expression.interpolated}function Wn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Hn(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)&&Ve(t)===Gt}function Yn(t){return t}function Xn(t,e){const i=t.stops&&"object"==typeof t.stops[0][0],n=i||!(i||void 0!==t.property),s=t.type||(Zn(e)?"exponential":"interval"),r=function(t){switch(t.type){case"color":return Pe.parse;case"padding":return ke.parse;case"numberArray":return $e.parse;case"colorArray":return Oe.parse;default:return null}}(e);if(r&&((t=kt({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],r(t[1])]))),t.default=r(t.default?t.default:e.default)),t.colorSpace&&"rgb"!==(o=t.colorSpace)&&"hcl"!==o&&"lab"!==o)throw new Error(`Unknown color space: "${t.colorSpace}"`);var o;const a=function(t){switch(t){case"exponential":return ts;case"interval":return Qn;case"categorical":return Kn;case"identity":return es;default:throw new Error(`Unknown function type "${t}"`)}}(s);let h,l;if("categorical"===s){h=Object.create(null);for(const e of t.stops)h[e[0]]=e[1];l=typeof t.stops[0][0]}if(i){const i={},n=[];for(let e=0;e<t.stops.length;e++){const s=t.stops[e],r=s[0].zoom;void 0===i[r]&&(i[r]={zoom:r,type:t.type,property:t.property,default:t.default,stops:[]},n.push(r)),i[r].stops.push([s[0].value,s[1]])}const s=[];for(const t of n)s.push([i[t].zoom,Xn(i[t],e)]);const r={name:"linear"};return{kind:"composite",interpolationType:r,interpolationFactor:pi.interpolationFactor.bind(void 0,r),zoomStops:s.map((t=>t[0])),evaluate:({zoom:i},n)=>ts({stops:s,base:t.base},e,i).evaluate(i,n)}}if(n){const i="exponential"===s?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:pi.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>a(t,e,i,h,l)}}return{kind:"source",evaluate(i,n){const s=n&&n.properties?n.properties[t.property]:void 0;return void 0===s?Jn(t.default,e.default):a(t,e,s,h,l)}}}function Jn(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function Kn(t,e,i,n,s){return Jn(typeof i===s?n[i]:void 0,t.default,e.default)}function Qn(t,e,i){if("number"!==Wn(i))return Jn(t.default,e.default);const n=t.stops.length;if(1===n)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];const s=hi(t.stops.map((t=>t[0])),i);return t.stops[s][1]}function ts(t,e,i){const n=void 0!==t.base?t.base:1;if("number"!==Wn(i))return Jn(t.default,e.default);const s=t.stops.length;if(1===s)return t.stops[0][1];if(i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[s-1][0])return t.stops[s-1][1];const r=hi(t.stops.map((t=>t[0])),i),o=function(t,e,i,n){const s=n-i,r=t-i;return 0===s?0:1===e?r/s:(Math.pow(e,r)-1)/(Math.pow(e,s)-1)}(i,n,t.stops[r][0],t.stops[r+1][0]),a=t.stops[r][1],h=t.stops[r+1][1],l=_i[e.type]||Yn;return"function"==typeof a.evaluate?{evaluate(...e){const i=a.evaluate.apply(void 0,e),n=h.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==n)return l(i,n,o,t.colorSpace)}}:l(a,h,o,t.colorSpace)}function es(t,e,i){switch(e.type){case"color":i=Pe.parse(i);break;case"formatted":i=Ie.fromString(i.toString());break;case"resolvedImage":i=Be.fromString(i.toString());break;case"padding":i=ke.parse(i);break;case"colorArray":i=Oe.parse(i);break;case"numberArray":i=$e.parse(i);break;default:Wn(i)===e.type||"enum"===e.type&&e.values[i]||(i=void 0)}return Jn(i,t.default,e.default)}In.register(Fn,{error:[{kind:"error"},[Lt],(t,[e])=>{throw new je(e.evaluate(t))}],typeof:[Lt,[Vt],(t,[e])=>Qt(Ve(e.evaluate(t)))],"to-rgba":[Kt(Rt,4),[Nt],(t,[e])=>{const[i,n,s,r]=e.evaluate(t).rgb;return[255*i,255*n,255*s,r]}],rgb:[Nt,[Rt,Rt,Rt],kn],rgba:[Nt,[Rt,Rt,Rt,Rt],kn],has:{type:Bt,overloads:[[[Lt],(t,[e])=>$n(e.evaluate(t),t.properties())],[[Lt,Gt],(t,[e,i])=>$n(e.evaluate(t),i.evaluate(t))]]},get:{type:Vt,overloads:[[[Lt],(t,[e])=>On(e.evaluate(t),t.properties())],[[Lt,Gt],(t,[e,i])=>On(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Vt,[Lt],(t,[e])=>On(e.evaluate(t),t.featureState||{})],properties:[Gt,[],t=>t.properties()],"geometry-type":[Lt,[],t=>t.geometryType()],id:[Vt,[],t=>t.id()],zoom:[Rt,[],t=>t.globals.zoom],"heatmap-density":[Rt,[],t=>t.globals.heatmapDensity||0],elevation:[Rt,[],t=>t.globals.elevation||0],"line-progress":[Rt,[],t=>t.globals.lineProgress||0],accumulated:[Vt,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Rt,jn(Rt),(t,e)=>{let i=0;for(const n of e)i+=n.evaluate(t);return i}],"*":[Rt,jn(Rt),(t,e)=>{let i=1;for(const n of e)i*=n.evaluate(t);return i}],"-":{type:Rt,overloads:[[[Rt,Rt],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[Rt],(t,[e])=>-e.evaluate(t)]]},"/":[Rt,[Rt,Rt],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[Rt,[Rt,Rt],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[Rt,[],()=>Math.LN2],pi:[Rt,[],()=>Math.PI],e:[Rt,[],()=>Math.E],"^":[Rt,[Rt,Rt],(t,[e,i])=>Math.pow(e.evaluate(t),i.evaluate(t))],sqrt:[Rt,[Rt],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Rt,[Rt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Rt,[Rt],(t,[e])=>Math.log(e.evaluate(t))],log2:[Rt,[Rt],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Rt,[Rt],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Rt,[Rt],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Rt,[Rt],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Rt,[Rt],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Rt,[Rt],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Rt,[Rt],(t,[e])=>Math.atan(e.evaluate(t))],min:[Rt,jn(Rt),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Rt,jn(Rt),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Rt,[Rt],(t,[e])=>Math.abs(e.evaluate(t))],round:[Rt,[Rt],(t,[e])=>{const i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[Rt,[Rt],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Rt,[Rt],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Bt,[Lt,Vt],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Bt,[Vt],(t,[e])=>t.id()===e.value],"filter-type-==":[Bt,[Lt],(t,[e])=>t.geometryType()===e.value],"filter-<":[Bt,[Lt,Vt],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<s}],"filter-id-<":[Bt,[Vt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<n}],"filter->":[Bt,[Lt,Vt],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>s}],"filter-id->":[Bt,[Vt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>n}],"filter-<=":[Bt,[Lt,Vt],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n<=s}],"filter-id-<=":[Bt,[Vt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i<=n}],"filter->=":[Bt,[Lt,Vt],(t,[e,i])=>{const n=t.properties()[e.value],s=i.value;return typeof n==typeof s&&n>=s}],"filter-id->=":[Bt,[Vt],(t,[e])=>{const i=t.id(),n=e.value;return typeof i==typeof n&&i>=n}],"filter-has":[Bt,[Vt],(t,[e])=>e.value in t.properties()],"filter-has-id":[Bt,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Bt,[Kt(Lt)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Bt,[Kt(Vt)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Bt,[Lt,Kt(Vt)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Bt,[Lt,Kt(Vt)],(t,[e,i])=>function(t,e,i,n){for(;i<=n;){const s=i+n>>1;if(e[s]===t)return!0;e[s]>t?n=s-1:i=s+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:Bt,overloads:[[[Bt,Bt],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[jn(Bt),(t,e)=>{for(const i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Bt,overloads:[[[Bt,Bt],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[jn(Bt),(t,e)=>{for(const i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Bt,[Bt],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Bt,[Lt],(t,[e])=>{const i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[Lt,[Lt],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Lt,[Lt],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Lt,jn(Vt),(t,e)=>e.map((e=>qe(e.evaluate(t)))).join("")],split:[Kt(Lt),[Lt,Lt],(t,[e,i])=>e.evaluate(t).split(i.evaluate(t))],join:[Lt,[Kt(Lt),Lt],(t,[e,i])=>e.evaluate(t).join(i.evaluate(t))],"resolved-locale":[Lt,[qt],(t,[e])=>e.evaluate(t).resolvedLocale()]});class is{constructor(t,e,i){this.expression=t,this._warningHistory={},this._evaluator=new Ke,this._defaultValue=e?function(t){if("color"===t.type&&Hn(t.default))return new Pe(0,0,0,0);switch(t.type){case"color":return Pe.parse(t.default)||null;case"padding":return ke.parse(t.default)||null;case"numberArray":return $e.parse(t.default)||null;case"colorArray":return Oe.parse(t.default)||null;case"variableAnchorOffsetCollection":return Le.parse(t.default)||null;case"projectionDefinition":return Ne.parse(t.default)||null;default:return void 0===t.default?null:t.default}}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null,this._globalState=i}evaluateWithoutErrorHandling(t,e,i,n,s,r){return this._globalState&&(t=us(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=r,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,n,s,r){this._globalState&&(t=us(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=r||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new je(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function ns(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Fn}function ss(t,e,i){const n=new Qe(Fn,Rn,[],e?function(t){const e={color:Nt,string:Lt,number:Rt,enum:Lt,boolean:Bt,formatted:Zt,padding:Wt,numberArray:Yt,colorArray:Ht,projectionDefinition:Ut,resolvedImage:Xt,variableAnchorOffsetCollection:Jt};return"array"===t.type?Kt(e[t.value]||Vt,t.length):e[t.type]}(e):void 0),s=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return s?Un(new is(s,e,i)):Gn(n.errors)}class rs{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Bn(e.expression),this.globalStateRefs=cs(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,n,s,r){return this._globalState&&(t=us(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,s,r)}evaluate(t,e,i,n,s,r){return this._globalState&&(t=us(t,this._globalState)),this._styleExpression.evaluate(t,e,i,n,s,r)}}class os{constructor(t,e,i,n,s){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Bn(e.expression),this.globalStateRefs=cs(e.expression),this.interpolationType=n,this._globalState=s}evaluateWithoutErrorHandling(t,e,i,n,s,r){return this._globalState&&(t=us(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,n,s,r)}evaluate(t,e,i,n,s,r){return this._globalState&&(t=us(t,this._globalState)),this._styleExpression.evaluate(t,e,i,n,s,r)}interpolationFactor(t,e,i){return this.interpolationType?pi.interpolationFactor(this.interpolationType,t,e,i):0}}function as(t,e,i){const n=ss(t,e,i);if("error"===n.result)return n;const s=n.value.expression,r=Ln(s);if(!r&&!Vn(e))return Gn([new $t("","data expressions not supported")]);const o=Nn(s,["zoom"]);if(!o&&!qn(e))return Gn([new $t("","zoom expressions not supported")]);const a=ls(s);return a||o?a instanceof $t?Gn([a]):a instanceof pi&&!Zn(e)?Gn([new $t("",'"interpolate" expressions cannot be used with this property')]):Un(a?new os(r?"camera":"composite",n.value,a.labels,a instanceof pi?a.interpolation:void 0,i):new rs(r?"constant":"source",n.value,i)):Gn([new $t("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class hs{constructor(t,e){this._parameters=t,this._specification=e,kt(this,Xn(this._parameters,this._specification))}static deserialize(t){return new hs(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function ls(t){let e=null;if(t instanceof ti)e=ls(t.result);else if(t instanceof gi){for(const i of t.args)if(e=ls(i),e)break}else(t instanceof li||t instanceof pi)&&t.input instanceof In&&"zoom"===t.input.name&&(e=t);return e instanceof $t||t.eachChild((t=>{const i=ls(t);i instanceof $t?e=i:!e&&i?e=new $t("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new $t("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function cs(t,e=new Set){return t instanceof Dn&&e.add(t.key),t.eachChild((t=>{cs(t,e)})),e}function us(t,e){const{zoom:i,heatmapDensity:n,elevation:s,lineProgress:r,isSupportedScript:o,accumulated:a}=null!=t?t:{};return{zoom:i,heatmapDensity:n,elevation:s,lineProgress:r,isSupportedScript:o,accumulated:a,globalState:e}}function fs(t){if(!0===t||!1===t)return!0;if(!Array.isArray(t)||0===t.length)return!1;switch(t[0]){case"has":return t.length>=2&&"$id"!==t[1]&&"$type"!==t[1];case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2]);case"any":case"all":for(const e of t.slice(1))if(!fs(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}}const ds={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function ps(t,e){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};fs(t)||(t=gs(t));const i=ss(t,ds,e);if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,e,n)=>i.value.evaluate(t,e,{},n),needGeometry:_s(t),getGlobalStateRefs:()=>cs(i.value.expression)}}function ms(t,e){return t<e?-1:t>e?1:0}function _s(t){if(!Array.isArray(t))return!1;if("within"===t[0]||"distance"===t[0])return!0;for(let e=1;e<t.length;e++)if(_s(t[e]))return!0;return!1}function gs(t){if(!t)return!0;const e=t[0];return t.length<=1?"any"!==e:"=="===e?vs(t[1],t[2],"=="):"!="===e?bs(vs(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?vs(t[1],t[2],e):"any"===e?(i=t.slice(1),["any"].concat(i.map(gs))):"all"===e?["all"].concat(t.slice(1).map(gs)):"none"===e?["all"].concat(t.slice(1).map(gs).map(bs)):"in"===e?ys(t[1],t.slice(2)):"!in"===e?bs(ys(t[1],t.slice(2))):"has"===e?ws(t[1]):"!has"!==e||bs(ws(t[1]));var i}function vs(t,e,i){switch(t){case"$type":return[`filter-type-${i}`,e];case"$id":return[`filter-id-${i}`,e];default:return[`filter-${i}`,t,e]}}function ys(t,e){if(0===e.length)return!1;switch(t){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some((t=>typeof t!=typeof e[0]))?["filter-in-large",t,["literal",e.sort(ms)]]:["filter-in-small",t,["literal",e]]}}function ws(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function bs(t){return["!",t]}function xs(t){const e=typeof t;if("number"===e||"boolean"===e||"string"===e||null==t)return JSON.stringify(t);if(Array.isArray(t)){let e="[";for(const i of t)e+=`${xs(i)},`;return`${e}]`}const i=Object.keys(t).sort();let n="{";for(let e=0;e<i.length;e++)n+=`${JSON.stringify(i[e])}:${xs(t[i[e]])},`;return`${n}}`}function Ms(t){let e="";for(const i of xt)e+=`/${xs(t[i])}`;return e}function Ss(t){const e=t.value;return e?[new It(t.key,e,"constants have been deprecated as of v8")]:[]}function zs(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Ts(t){if(Array.isArray(t))return t.map(Ts);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const i in t)e[i]=Ts(t[i]);return e}return zs(t)}function Es(t){const e=t.key,i=t.value,n=t.valueSpec||{},s=t.objectElementValidators||{},r=t.style,o=t.styleSpec,a=t.validateSpec;let h=[];const l=Wn(i);if("object"!==l)return[new It(e,i,`object expected, ${l} found`)];for(const t in i){const l=t.split(".")[0],c=be(n,l)||n["*"];let u;if(be(s,l))u=s[l];else if(be(n,l)){if(void 0===i[t])continue;u=a}else if(s["*"])u=s["*"];else{if(!n["*"]){h.push(new It(e,i[t],`unknown property "${t}"`));continue}u=a}h=h.concat(u({key:(e?`${e}.`:e)+t,value:i[t],valueSpec:c,style:r,styleSpec:o,object:i,objectKey:t,validateSpec:a},i))}for(const t in n)s[t]||n[t].required&&void 0===n[t].default&&void 0===i[t]&&h.push(new It(e,i,`missing required property "${t}"`));return h}function As(t){const e=t.value,i=t.valueSpec,n=t.style,s=t.styleSpec,r=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==Wn(e))return[new It(r,e,`array expected, ${Wn(e)} found`)];if(i.length&&e.length!==i.length)return[new It(r,e,`array length ${i.length} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};s.$version<7&&(a.function=i.function),"object"===Wn(i.value)&&(a=i.value);let h=[];for(let i=0;i<e.length;i++)h=h.concat(o({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:n,styleSpec:s,key:`${r}[${i}]`}));return h}function Ps(t){const e=t.key,i=t.value,n=t.valueSpec;let s=Wn(i);return"number"===s&&i!=i&&(s="NaN"),"number"!==s?[new It(e,i,`number expected, ${s} found`)]:"minimum"in n&&i<n.minimum?[new It(e,i,`${i} is less than the minimum value ${n.minimum}`)]:"maximum"in n&&i>n.maximum?[new It(e,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Cs(t){const e=t.valueSpec,i=zs(t.value.type);let n,s,r,o={};const a="categorical"!==i&&void 0===t.value.property,h=!a,l="array"===Wn(t.value.stops)&&"array"===Wn(t.value.stops[0])&&"object"===Wn(t.value.stops[0][0]),c=Es({key:t.key,value:t.value,valueSpec:t.styleSpec.function,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===i)return[new It(t.key,t.value,'identity function may not have a "stops" property')];let e=[];const n=t.value;return e=e.concat(As({key:t.key,value:n,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:u})),"array"===Wn(n)&&0===n.length&&e.push(new It(t.key,n,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===i&&a&&c.push(new It(t.key,t.value,'missing required property "property"')),"identity"===i||t.value.stops||c.push(new It(t.key,t.value,'missing required property "stops"')),"exponential"===i&&t.valueSpec.expression&&!Zn(t.valueSpec)&&c.push(new It(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!Vn(t.valueSpec)?c.push(new It(t.key,t.value,"property functions not supported")):a&&!qn(t.valueSpec)&&c.push(new It(t.key,t.value,"zoom functions not supported"))),"categorical"!==i&&!l||void 0!==t.value.property||c.push(new It(t.key,t.value,'"property" property is required')),c;function u(t){let i=[];const n=t.value,a=t.key;if("array"!==Wn(n))return[new It(a,n,`array expected, ${Wn(n)} found`)];if(2!==n.length)return[new It(a,n,`array length 2 expected, length ${n.length} found`)];if(l){if("object"!==Wn(n[0]))return[new It(a,n,`object expected, ${Wn(n[0])} found`)];if(void 0===n[0].zoom)return[new It(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new It(a,n,"object stop key must have value")];if(r&&r>zs(n[0].zoom))return[new It(a,n[0].zoom,"stop zoom values must appear in ascending order")];zs(n[0].zoom)!==r&&(r=zs(n[0].zoom),s=void 0,o={}),i=i.concat(Es({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:Ps,value:f}}))}else i=i.concat(f({key:`${a}[0]`,value:n[0]},n));return ns(Ts(n[1]))?i.concat([new It(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(t.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:e,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function f(t,r){const a=Wn(t.value),h=zs(t.value),l=null!==t.value?t.value:r;if(n){if(a!==n)return[new It(t.key,l,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new It(t.key,l,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return Vn(e)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new It(t.key,l,n)]}return"categorical"!==i||"number"!==a||isFinite(h)&&Math.floor(h)===h?"categorical"!==i&&"number"===a&&void 0!==s&&h<s?[new It(t.key,l,"stop domain values must appear in ascending order")]:(s=h,"categorical"===i&&h in o?[new It(t.key,l,"stop domain values must be unique")]:(o[h]=!0,[])):[new It(t.key,l,`integer expected, found ${h}`)]}}function Ds(t){const e=("property"===t.expressionContext?as:ss)(Ts(t.value),t.valueSpec);if("error"===e.result)return e.value.map((e=>new It(`${t.key}${e.key}`,t.value,e.message)));const i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new It(t.key,t.value,`Invalid data expression for "${t.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===t.expressionContext&&"layout"===t.propertyType&&!Bn(i))return[new It(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!Bn(i))return[new It(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!Nn(i,["zoom","feature-state"]))return[new It(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!Ln(i))return[new It(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Fs(t){const e=t.key,i=t.value,n=Wn(i);return"string"!==n?[new It(e,i,`color expected, ${n} found`)]:Pe.parse(String(i))?[]:[new It(e,i,`color expected, "${i}" found`)]}function Is(t){const e=t.key,i=t.value,n=t.valueSpec,s=[];return Array.isArray(n.values)?-1===n.values.indexOf(zs(i))&&s.push(new It(e,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(zs(i))&&s.push(new It(e,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),s}function ks(t){return fs(Ts(t.value))?Ds(kt({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}})):$s(t)}function $s(t){const e=t.value,i=t.key;if("array"!==Wn(e))return[new It(i,e,`array expected, ${Wn(e)} found`)];const n=t.styleSpec;let s,r=[];if(e.length<1)return[new It(i,e,"filter array must have at least 1 element")];switch(r=r.concat(Is({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator})),zs(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===zs(e[1])&&r.push(new It(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&r.push(new It(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(s=Wn(e[1]),"string"!==s&&r.push(new It(`${i}[1]`,e[1],`string expected, ${s} found`)));for(let t=2;t<e.length;t++)s=Wn(e[t]),"$type"===zs(e[1])?r=r.concat(Is({key:`${i}[${t}]`,value:e[t],valueSpec:n.geometry_type})):"string"!==s&&"number"!==s&&"boolean"!==s&&r.push(new It(`${i}[${t}]`,e[t],`string, number, or boolean expected, ${s} found`));break;case"any":case"all":case"none":for(let n=1;n<e.length;n++)r=r.concat($s({key:`${i}[${n}]`,value:e[n],styleSpec:t.styleSpec}));break;case"has":case"!has":s=Wn(e[1]),2!==e.length?r.push(new It(i,e,`filter array for "${e[0]}" operator must have 2 elements`)):"string"!==s&&r.push(new It(`${i}[1]`,e[1],`string expected, ${s} found`))}return r}function Os(t,e){const i=t.key,n=t.validateSpec,s=t.style,r=t.styleSpec,o=t.value,a=t.objectKey,h=r[`${e}_${t.layerType}`];if(!h)return[];const l=a.match(/^(.*)-transition$/);if("paint"===e&&l&&h[l[1]]&&h[l[1]].transition)return n({key:i,value:o,valueSpec:r.transition,style:s,styleSpec:r});const c=t.valueSpec||h[a];if(!c)return[new It(i,o,`unknown property "${a}"`)];let u;if("string"===Wn(o)&&Vn(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new It(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];const f=[];return"symbol"===t.layerType&&"text-font"===a&&Hn(Ts(o))&&"identity"===zs(o.type)&&f.push(new It(i,o,'"text-font" does not support identity functions')),f.concat(n({key:t.key,value:o,valueSpec:c,style:s,styleSpec:r,expressionContext:"property",propertyType:e,propertyKey:a}))}function js(t){return Os(t,"paint")}function Rs(t){return Os(t,"layout")}function Ls(t){var e,i;let n=[];const s=t.value,r=t.key,o=t.style,a=t.styleSpec;if("object"!==Wn(s))return[new It(r,s,`object expected, ${Wn(s)} found`)];s.type||s.ref||n.push(new It(r,s,'either "type" or "ref" is required'));let h=zs(s.type);const l=zs(s.ref);if(s.id){const e=zs(s.id);for(let i=0;i<t.arrayIndex;i++){const t=o.layers[i];zs(t.id)===e&&n.push(new It(r,s.id,`duplicate layer id "${s.id}", previously used at line ${t.id.__line__}`))}}if("ref"in s){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in s&&n.push(new It(r,s[t],`"${t}" is prohibited for ref layers`))})),o.layers.forEach((e=>{zs(e.id)===l&&(t=e)})),t?t.ref?n.push(new It(r,s.ref,"ref cannot reference another ref layer")):h=zs(t.type):n.push(new It(r,s.ref,`ref layer "${l}" not found`))}else if("background"!==h)if(s.source){const t=o.sources&&o.sources[s.source],e=t&&zs(t.type);t?"vector"===e&&"raster"===h?n.push(new It(r,s.source,`layer "${s.id}" requires a raster source`)):"raster-dem"!==e&&"hillshade"===h||"raster-dem"!==e&&"color-relief"===h?n.push(new It(r,s.source,`layer "${s.id}" requires a raster-dem source`)):"raster"===e&&"raster"!==h?n.push(new It(r,s.source,`layer "${s.id}" requires a vector source`)):"vector"!==e||s["source-layer"]?"raster-dem"===e&&"hillshade"!==h&&"color-relief"!==h?n.push(new It(r,s.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==h||!s.paint||!s.paint["line-gradient"]||"geojson"===e&&t.lineMetrics||n.push(new It(r,s,`layer "${s.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):n.push(new It(r,s,`layer "${s.id}" must specify a "source-layer"`)):n.push(new It(r,s.source,`source "${s.source}" not found`))}else n.push(new It(r,s,'missing required property "source"'));return"raster"===h&&(null===(e=s.paint)||void 0===e?void 0:e.resampling)&&(null===(i=s.paint)||void 0===i?void 0:i["raster-resampling"])&&n.push(new It(r,s.paint,`layer "${s.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),n=n.concat(Es({key:r,value:s,valueSpec:a.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:s.type,valueSpec:a.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:s,objectKey:"type"}),filter:ks,layout:t=>Es({layer:s,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>Rs(kt({layerType:h},t))}}),paint:t=>Es({layer:s,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>js(kt({layerType:h},t))}})}})),n}function Bs(t){const e=t.value,i=t.key,n=Wn(e);return"string"!==n?[new It(i,e,`string expected, ${n} found`)]:[]}const Ns={promoteId:function({key:t,value:e}){if("string"===Wn(e))return Bs({key:t,value:e});{const i=[];for(const n in e)i.push(...Bs({key:`${t}.${n}`,value:e[n]}));return i}}};function Us(t){const e=t.value,i=t.key,n=t.styleSpec,s=t.style,r=t.validateSpec;if(!e.type)return[new It(i,e,'"type" is required')];const o=zs(e.type);let a;switch(o){case"vector":case"raster":return a=Es({key:i,value:e,valueSpec:n[`source_${o.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:Ns,validateSpec:r}),a;case"raster-dem":return a=function(t){var e;const i=null!==(e=t.sourceName)&&void 0!==e?e:"",n=t.value,s=t.styleSpec,r=s.source_raster_dem,o=t.style;let a=[];const h=Wn(n);if(void 0===n)return a;if("object"!==h)return a.push(new It("source_raster_dem",n,`object expected, ${h} found`)),a;const l="custom"===zs(n.encoding),c=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(const e in n)!l&&c.includes(e)?a.push(new It(e,n[e],`In "${i}": "${e}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):r[e]?a=a.concat(t.validateSpec({key:e,value:n[e],valueSpec:r[e],validateSpec:t.validateSpec,style:o,styleSpec:s})):a.push(new It(e,n[e],`unknown property "${e}"`));return a}({sourceName:i,value:e,style:t.style,styleSpec:n,validateSpec:r}),a;case"geojson":if(a=Es({key:i,value:e,valueSpec:n.source_geojson,style:s,styleSpec:n,validateSpec:r,objectElementValidators:Ns}),e.cluster)for(const t in e.clusterProperties){const[n,s]=e.clusterProperties[t],r="string"==typeof n?[n,["accumulated"],["get",t]]:n;a.push(...Ds({key:`${i}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...Ds({key:`${i}.${t}.reduce`,value:r,expressionContext:"cluster-reduce"}))}return a;case"video":return Es({key:i,value:e,valueSpec:n.source_video,style:s,validateSpec:r,styleSpec:n});case"image":return Es({key:i,value:e,valueSpec:n.source_image,style:s,validateSpec:r,styleSpec:n});case"canvas":return[new It(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Is({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Gs(t){const e=t.value,i=t.styleSpec,n=i.light,s=t.style;let r=[];const o=Wn(e);if(void 0===e)return r;if("object"!==o)return r=r.concat([new It("light",e,`object expected, ${o} found`)]),r;for(const o in e){const a=o.match(/^(.*)-transition$/);r=r.concat(a&&n[a[1]]&&n[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:i.transition,validateSpec:t.validateSpec,style:s,styleSpec:i}):n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new It(o,e[o],`unknown property "${o}"`)])}return r}function Vs(t){const e=t.value,i=t.styleSpec,n=i.sky,s=t.style,r=Wn(e);if(void 0===e)return[];if("object"!==r)return[new It("sky",e,`object expected, ${r} found`)];let o=[];for(const r in e)o=o.concat(n[r]?t.validateSpec({key:r,value:e[r],valueSpec:n[r],style:s,styleSpec:i}):[new It(r,e[r],`unknown property "${r}"`)]);return o}function qs(t){const e=t.value,i=t.styleSpec,n=i.terrain,s=t.style;let r=[];const o=Wn(e);if(void 0===e)return r;if("object"!==o)return r=r.concat([new It("terrain",e,`object expected, ${o} found`)]),r;for(const o in e)r=r.concat(n[o]?t.validateSpec({key:o,value:e[o],valueSpec:n[o],validateSpec:t.validateSpec,style:s,styleSpec:i}):[new It(o,e[o],`unknown property "${o}"`)]);return r}function Zs(t){let e=[];const i=t.value,n=t.key;if(Array.isArray(i)){const s=[],r=[];for(const o in i)i[o].id&&s.includes(i[o].id)&&e.push(new It(n,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),s.push(i[o].id),i[o].url&&r.includes(i[o].url)&&e.push(new It(n,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),r.push(i[o].url),e=e.concat(Es({key:`${n}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Bs({key:n,value:i})}function Ws(t){return Boolean(t)&&t.constructor===Object}function Hs(t){return Ws(t.value)?[]:[new It(t.key,t.value,`object expected, ${Wn(t.value)} found`)]}const Ys={"*":()=>[],array:As,boolean:function(t){const e=t.value,i=t.key,n=Wn(e);return"boolean"!==n?[new It(i,e,`boolean expected, ${n} found`)]:[]},number:Ps,color:Fs,constants:Ss,enum:Is,filter:ks,function:Cs,layer:Ls,object:Es,source:Us,light:Gs,sky:Vs,terrain:qs,projection:function(t){const e=t.value,i=t.styleSpec,n=i.projection,s=t.style,r=Wn(e);if(void 0===e)return[];if("object"!==r)return[new It("projection",e,`object expected, ${r} found`)];let o=[];for(const r in e)o=o.concat(n[r]?t.validateSpec({key:r,value:e[r],valueSpec:n[r],style:s,styleSpec:i}):[new It(r,e[r],`unknown property "${r}"`)]);return o},projectionDefinition:function(t){const e=t.key;let i=t.value;i=i instanceof String?i.valueOf():i;const n=Wn(i);return"array"!==n||function(t){return Array.isArray(t)&&3===t.length&&"string"==typeof t[0]&&"string"==typeof t[1]&&"number"==typeof t[2]}(i)||function(t){return!!["interpolate","step","literal"].includes(t[0])}(i)?["array","string"].includes(n)?[]:[new It(e,i,`projection expected, invalid type "${n}" found`)]:[new It(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Bs,formatted:function(t){return 0===Bs(t).length?[]:Ds(t)},resolvedImage:function(t){return 0===Bs(t).length?[]:Ds(t)},padding:function(t){const e=t.key,i=t.value;if("array"===Wn(i)){if(i.length<1||i.length>4)return[new It(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let s=[];for(let r=0;r<i.length;r++)s=s.concat(t.validateSpec({key:`${e}[${r}]`,value:i[r],validateSpec:t.validateSpec,valueSpec:n}));return s}return Ps({key:e,value:i,valueSpec:{}})},numberArray:function(t){const e=t.key,i=t.value;if("array"===Wn(i)){const n={type:"number"};if(i.length<1)return[new It(e,i,"array length at least 1 expected, length 0 found")];let s=[];for(let r=0;r<i.length;r++)s=s.concat(t.validateSpec({key:`${e}[${r}]`,value:i[r],validateSpec:t.validateSpec,valueSpec:n}));return s}return Ps({key:e,value:i,valueSpec:{}})},colorArray:function(t){const e=t.key,i=t.value;if("array"===Wn(i)){if(i.length<1)return[new It(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let n=0;n<i.length;n++)t=t.concat(Fs({key:`${e}[${n}]`,value:i[n]}));return t}return Fs({key:e,value:i})},variableAnchorOffsetCollection:function(t){const e=t.key,i=t.value,n=Wn(i),s=t.styleSpec;if("array"!==n||i.length<1||i.length%2!=0)return[new It(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let r=[];for(let n=0;n<i.length;n+=2)r=r.concat(Is({key:`${e}[${n}]`,value:i[n],valueSpec:s.layout_symbol["text-anchor"]})),r=r.concat(As({key:`${e}[${n+1}]`,value:i[n+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:s}));return r},sprite:Zs,state:Hs,fontFaces:function(t){const e=t.key,i=t.value,n=t.validateSpec,s=t.styleSpec,r=t.style;if(!Ws(i))return[new It(e,i,`object expected, ${Wn(i)} found`)];const o=[];for(const t in i){const a=i[t],h=Wn(a);if("string"===h)o.push(...Bs({key:`${e}.${t}`,value:a}));else if("array"===h){const i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(const[h,l]of a.entries())o.push(...Es({key:`${e}.${t}[${h}]`,value:l,valueSpec:i,styleSpec:s,style:r,validateSpec:n}))}else o.push(new It(`${e}.${t}`,a,`string or array expected, ${h} found`))}return o}};function Xs(t){const e=t.value,i=t.valueSpec,n=t.styleSpec;return t.validateSpec=Xs,i.expression&&Hn(zs(e))?Cs(t):i.expression&&ns(Ts(e))?Ds(t):i.type&&Ys[i.type]?Ys[i.type](t):Es(kt({},t,{valueSpec:i.type?n[i.type]:i}))}function Js(t){const e=t.value,i=t.key,n=Bs(t);return n.length||(-1===e.indexOf("{fontstack}")&&n.push(new It(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&n.push(new It(i,e,'"glyphs" url must include a "{range}" token'))),n}function Ks(t,e=bt){let i=[];return i=i.concat(Xs({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Xs,objectElementValidators:{glyphs:Js,"*":()=>[]}})),t.constants&&(i=i.concat(Ss({key:"constants",value:t.constants}))),tr(i)}function Qs(t){return function(e){return t(Object.assign({},e,{validateSpec:Xs}))}}function tr(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function er(t){return function(...e){return tr(t.apply(this,e))}}Ks.source=er(Qs(Us)),Ks.sprite=er(Qs(Zs)),Ks.glyphs=er(Qs(Js)),Ks.light=er(Qs(Gs)),Ks.sky=er(Qs(Vs)),Ks.terrain=er(Qs(qs)),Ks.state=er(Qs(Hs)),Ks.layer=er(Qs(Ls)),Ks.filter=er(Qs(ks)),Ks.paintProperty=er(Qs(js)),Ks.layoutProperty=er(Qs(Rs));const ir={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};class nr{constructor(t,e){this._globalState=e,this.setValue(t)}evaluate(){var t;return null!==(t=this._literalValue)&&void 0!==t?t:this._compiledValue.evaluate({})}setValue(t){if(null==t||"visible"===t||"none"===t)return this._literalValue="none"===t?"none":"visible",this._compiledValue=void 0,void(this._globalStateRefs=new Set);const e=ss(t,ir,this._globalState);if("error"===e.result)throw this._literalValue="visible",this._compiledValue=void 0,new Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=cs(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}}const sr=bt,rr=Ks,or=rr.light,ar=rr.sky,hr=rr.paintProperty,lr=rr.layoutProperty;function cr(t,e){let i=!1;if(null==e?void 0:e.length)for(const n of e)t.fire(new yt(new Error(n.message))),i=!0;return i}class ur{constructor(t,e,i){const n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;const s=new Int32Array(this.arrayBuffer);t=s[0],this.d=(e=s[1])+2*(i=s[2]);for(let t=0;t<this.d*this.d;t++){const e=s[3+t],i=s[3+t+1];n.push(e===i?null:s.subarray(e,i))}const r=s[3+n.length+1];this.keys=s.subarray(s[3+n.length],r),this.bboxes=s.subarray(r),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)n.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;const s=i/e*t;this.min=-s,this.max=t+s}insert(t,e,i,n,s){this._forEachCell(e,i,n,s,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(s)}_insertReadonly(){throw new Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,n,s,r){this.cells[s].push(r)}query(t,e,i,n,s){const r=this.min,o=this.max;if(t<=r&&e<=r&&o<=i&&o<=n&&!s)return[...this.keys];{const r=[];return this._forEachCell(t,e,i,n,this._queryCell,r,{},s),r}}_queryCell(t,e,i,n,s,r,o,a){const h=this.cells[s];if(null!==h){const s=this.keys,l=this.bboxes;for(const c of h)if(void 0===o[c]){const h=4*c;(a?a(l[h+0],l[h+1],l[h+2],l[h+3]):t<=l[h+2]&&e<=l[h+3]&&i>=l[h+0]&&n>=l[h+1])?(o[c]=!0,r.push(s[c])):o[c]=!1}}}_forEachCell(t,e,i,n,s,r,o,a){const h=this._convertToCellCoord(t),l=this._convertToCellCoord(e),c=this._convertToCellCoord(i),u=this._convertToCellCoord(n);for(let f=h;f<=c;f++)for(let h=l;h<=u;h++){const l=this.d*h+f;if((!a||a(this._convertFromCellCoord(f),this._convertFromCellCoord(h),this._convertFromCellCoord(f+1),this._convertFromCellCoord(h+1)))&&s.call(this,t,e,i,n,l,r,o,a))return}}_convertFromCellCoord(t){return(t-this.padding)/this.scale}_convertToCellCoord(t){return Math.max(0,Math.min(this.d-1,Math.floor(t*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const t=this.cells,e=3+this.cells.length+1+1;let i=0;for(const t of this.cells)i+=t.length;const n=new Int32Array(e+i+this.keys.length+this.bboxes.length);n[0]=this.extent,n[1]=this.n,n[2]=this.padding;let s=e;for(let e=0;e<t.length;e++){const i=t[e];n[3+e]=s,n.set(i,s),s+=i.length}return n[3+t.length]=s,n.set(this.keys,s),s+=this.keys.length,n[3+t.length+1]=s,n.set(this.bboxes,s),s+=this.bboxes.length,n.buffer}static serialize(t,e){const i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(t){return new ur(t.buffer)}}const fr={};function dr(t,e,i={}){if(fr[t])throw new Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),fr[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}dr("Object",Object),dr("Set",Set),dr("TransferableGridIndex",ur),dr("Color",Pe),dr("Error",Error),dr("AJAXError",ft),dr("ResolvedImage",Be),dr("StylePropertyFunction",hs),dr("StyleExpression",is,{omit:["_evaluator"]}),dr("ZoomDependentExpression",os),dr("ZoomConstantExpression",rs),dr("CompoundExpression",In,{omit:["_evaluate"]});for(const t in Fn)Fn[t]._classRegistryKey||dr(`Expression_${t}`,Fn[t]);function pr(t){var e;return t&&"undefined"!=typeof ArrayBuffer&&(t instanceof ArrayBuffer||"ArrayBuffer"===(null===(e=t.constructor)||void 0===e?void 0:e.name))}function mr(t){return t.$name||t.constructor._classRegistryKey}function _r(t){return!function(t){if(null===t||"object"!=typeof t)return!1;const e=mr(t);return e&&"Object"!==e}(t)&&(null==t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||t instanceof Boolean||t instanceof Number||t instanceof String||t instanceof Date||t instanceof RegExp||t instanceof Blob||t instanceof Error||pr(t)||Y(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function gr(t,e){if(_r(t))return(pr(t)||Y(t))&&e&&e.push(t),ArrayBuffer.isView(t)&&e&&e.push(t.buffer),t instanceof ImageData&&e&&e.push(t.data.buffer),t;if(Array.isArray(t)){const i=[];for(const n of t)i.push(gr(n,e));return i}if("object"!=typeof t)throw new Error("can't serialize object of type "+typeof t);const i=mr(t);if(!i)throw new Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!fr[i])throw new Error(`${i} is not registered.`);const{klass:n}=fr[i],s=n.serialize?n.serialize(t,e):{};if(n.serialize){if(s===(null==e?void 0:e[e.length-1]))throw new Error("statically serialized object won't survive transfer of $name property")}else{for(const n in t){if(!t.hasOwnProperty(n))continue;if(fr[i].omit.includes(n))continue;const r=t[n];s[n]=fr[i].shallow.includes(n)?r:gr(r,e)}t instanceof Error&&(s.message=t.message)}if(s.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(s.$name=i),s}function vr(t){if(_r(t))return t;if(Array.isArray(t))return t.map(vr);if("object"!=typeof t)throw new Error("can't deserialize object of type "+typeof t);const e=mr(t)||"Object";if(!fr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:i}=fr[e];if(!i)throw new Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);const n=Object.create(i.prototype);for(const i of Object.keys(t)){if("$name"===i)continue;const s=t[i];n[i]=fr[e].shallow.includes(i)?s:vr(s)}return n}class yr{constructor(){this.first=!0}update(t,e){const i=Math.floor(t);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=t,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=e):this.lastFloorZoom<i&&(this.lastIntegerZoom=i,this.lastIntegerZoomTime=e),t!==this.lastZoom&&(this.lastZoom=t,this.lastFloorZoom=i,!0))}}function wr(t){return/[\u02EA\u02EB\u2E80-\u2FDF\u2FF0-\u303F\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FD-\u30FF\u3105-\u312F\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function br(t){return/[\u02EA\u02EB\u1100-\u11FF\u1400-\u167F\u18B0-\u18F5\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303F\u3041-\u3096\u309D-\u30FB\u30FD-\u30FF\u3105-\u312F\u3131-\u318E\u3190-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE48\uFE50-\uFE57\uFE5F-\uFE62\uFE67-\uFE6F\uFF00-\uFF07\uFF0A-\uFF0C\uFF0E-\uFF19\uFF1F-\uFF3A\uFF3C\uFF3E\uFF40-\uFF5A\uFFE0-\uFFE2\uFFE4-\uFFE7]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFE4\uDFF0-\uDFF6]|[\uD81C-\uD822\uD83D\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFF3\uDFF5-\uDFFB\uDFFD\uDFFE]|\uD82C[\uDC00-\uDD22\uDD30-\uDEFB]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83C[\uDC00-\uDE00\uDF00-\uDFFF]|\uD83E[\uDD00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))}function xr(t){return/\s/u.test(String.fromCodePoint(t))}function Mr(t){for(const e of t)if(br(e.codePointAt(0)))return!0;return!1}function Sr(t){for(const e of t)if(!Er(e.codePointAt(0)))return!1;return!0}function zr(t){const e=t.map((t=>{try{return new RegExp(`\\p{sc=${t}}`,"u").source}catch(t){return null}})).filter((t=>t));return new RegExp(e.join("|"),"u")}const Tr=zr(["Arab","Dupl","Mong","Ougr","Syrc"]);function Er(t){return!Tr.test(String.fromCodePoint(t))}function Ar(t){return!(br(t)||(e=t,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(e))));var e}const Pr=zr(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Cr(t){return Pr.test(String.fromCodePoint(t))}function Dr(t,e){return!(!e&&Cr(t)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(t)))}function Fr(t){for(const e of t)if(Cr(e.codePointAt(0)))return!0;return!1}const Ir=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(t){this.pluginStatus=t.pluginStatus,this.pluginURL=t.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(t){if(Ir.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=t.applyArabicShaping,this.processBidirectionalText=t.processBidirectionalText,this.processStyledBidirectionalText=t.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(t,i){return e(this,void 0,void 0,(function*(){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;const e=t.pluginURL,n=new Promise((t=>{this.loadScriptResolve=t}));i(e);const s=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(yield Promise.race([n,s]),this.isParsed()){const t={pluginStatus:"loaded",pluginURL:e};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${e}`)}))}};class kr{constructor(t,e){this.isSupportedScript=$r,this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new yr,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new yr,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const t=this.zoom,e=t-Math.floor(t),i=this.crossFadingFactor();return t>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:e+(1-e)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*e}}}function $r(t){return function(t,e){for(const i of t)if(!Dr(i.codePointAt(0),e))return!1;return!0}(t,"loaded"===Ir.getRTLTextPluginStatus())}const Or="-transition";class jr{constructor(t,e,i){this.property=t,this.value=e,this.expression=function(t,e,i){if(Hn(t))return new hs(t,e);if(ns(t)){const n=as(t,e,i);if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return n.value}{let i=t;return"color"===e.type&&"string"==typeof t?i=Pe.parse(t):"padding"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==e.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==e.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===e.type&&Array.isArray(t)?i=Le.parse(t):"projectionDefinition"===e.type&&"string"==typeof t&&(i=Ne.parse(t)):i=Oe.parse(t):i=$e.parse(t):i=ke.parse(t),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===e?t.specification.default:e,t.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}}class Rr{constructor(t,e){this.property=t,this.value=new jr(t,void 0,e)}transitioned(t,e){return new Br(this.property,this.value,e,L({},t.transition,this.transition),t.now)}untransitioned(){return new Br(this.property,this.value,null,{},0)}}class Lr{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=e}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return G(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new Rr(this._values[t].property,this._globalState)),this._values[t].value=new jr(this._values[t].property,null===e?void 0:G(e),this._globalState)}getTransition(t){return G(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new Rr(this._values[t].property,this._globalState)),this._values[t].transition=G(e)||void 0}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i);const n=this.getTransition(e);void 0!==n&&(t[`${e}${Or}`]=n)}return t}transitioned(t,e){const i=new Nr(this._properties);for(const n of Object.keys(this._values))i._values[n]=this._values[n].transitioned(t,e._values[n]);return i}untransitioned(){const t=new Nr(this._properties);for(const e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}}class Br{constructor(t,e,i,n,s){this.property=t,this.value=e,this.begin=s+n.delay||0,this.end=this.begin+n.duration||0,t.specification.transition&&(n.delay||n.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){const n=t.now||0,s=this.value.possiblyEvaluate(t,e,i),r=this.prior;if(r){if(n>this.end)return this.prior=null,s;if(this.value.isDataDriven())return this.prior=null,s;if(n<this.begin)return r.possiblyEvaluate(t,e,i);{const o=(n-this.begin)/(this.end-this.begin);return this.property.interpolate(r.possiblyEvaluate(t,e,i),s,k(o))}}return s}}class Nr{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){const n=new Vr(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].possiblyEvaluate(t,e,i);return n}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class Ur{constructor(t,e){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=e}hasValue(t){return void 0!==this._values[t].value}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return G(this._values[t].value)}setValue(t,e){this._values[t]=new jr(this._values[t].property,null===e?void 0:G(e),this._globalState)}serialize(){const t={};for(const e of Object.keys(this._values)){const i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){const n=new Vr(this._properties);for(const s of Object.keys(this._values))n._values[s]=this._values[s].possiblyEvaluate(t,e,i);return n}}class Gr{constructor(t,e,i){this.property=t,this.value=e,this.parameters=i}isConstant(){return"constant"===this.value.kind}constantOr(t){return"constant"===this.value.kind?this.value.value:t}evaluate(t,e,i,n){return this.property.evaluate(this.value,this.parameters,t,e,i,n)}}class Vr{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class qr{constructor(t){this.specification=t}possiblyEvaluate(t,e){if(t.isDataDriven())throw new Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){const n=_i[this.specification.type];return n?n(t,e,i):t}}class Zr{constructor(t,e){this.specification=t,this.overrides=e}possiblyEvaluate(t,e,i,n){return new Gr(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,n)}:t.expression,e)}interpolate(t,e,i){if("constant"!==t.value.kind||"constant"!==e.value.kind)return t;if(void 0===t.value.value||void 0===e.value.value)return new Gr(this,{kind:"constant",value:void 0},t.parameters);const n=_i[this.specification.type];if(n){const s=n(t.value.value,e.value.value,i);return new Gr(this,{kind:"constant",value:s},t.parameters)}return t}evaluate(t,e,i,n,s,r){return"constant"===t.kind?t.value:t.evaluate(e,i,n,s,r)}}class Wr extends Zr{possiblyEvaluate(t,e,i,n){if(void 0===t.value)return new Gr(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,n),r="resolvedImage"===t.property.specification.type&&"string"!=typeof s?s.name:s,o=this._calculate(r,r,r,e);return new Gr(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){const i=this._calculate(t.expression.evaluate({zoom:e.zoom-1}),t.expression.evaluate({zoom:e.zoom}),t.expression.evaluate({zoom:e.zoom+1}),e);return new Gr(this,{kind:"constant",value:i},e)}return new Gr(this,t.expression,e)}evaluate(t,e,i,n,s,r){if("source"===t.kind){const o=t.evaluate(e,i,n,s,r);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,n),t.evaluate({zoom:Math.floor(e.zoom)},i,n),t.evaluate({zoom:Math.floor(e.zoom)+1},i,n),e):t.value}_calculate(t,e,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Hr{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,n){if(void 0!==t.value){if("constant"===t.expression.kind){const s=t.expression.evaluate(e,null,{},i,n);return this._calculate(s,s,s,e)}return this._calculate(t.expression.evaluate(new kr(Math.floor(e.zoom-1),e)),t.expression.evaluate(new kr(Math.floor(e.zoom),e)),t.expression.evaluate(new kr(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}}class Yr{constructor(t){this.specification=t}possiblyEvaluate(t,e,i,n){return!!t.expression.evaluate(e,null,{},i,n)}interpolate(){return!1}}class Xr{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const e in t){const i=t[e];i.specification.overridable&&this.overridableProperties.push(e);const n=this.defaultPropertyValues[e]=new jr(i,void 0,void 0),s=this.defaultTransitionablePropertyValues[e]=new Rr(i,void 0);this.defaultTransitioningPropertyValues[e]=s.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=n.possiblyEvaluate({})}}}dr("DataDrivenProperty",Zr),dr("DataConstantProperty",qr),dr("CrossFadedDataDrivenProperty",Wr),dr("CrossFadedProperty",Hr),dr("ColorRampProperty",Yr);const Jr=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Kr=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";class Qr extends wt{constructor(t,e,i){if(super(),this.id=t.id,this.type=t.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},this._visibilityExpression=function(t,e){return new nr(t,e)}(this.visibility,i),"custom"!==t.type&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,"background"!==t.type&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter,this._featureFilter=ps(t.filter,i)),e.layout&&(this._unevaluatedLayout=new Ur(e.layout,i)),e.paint)){this._transitionablePaint=new Lr(e.paint,i);for(const e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(const e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Vr(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=ps(t,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){var e;if("visibility"===t)return this.visibility;if(null===(e=this._transitionablePaint)||void 0===e?void 0:e.hasProperty(t))throw new Error(t+Jr);if(!this._unevaluatedLayout)throw new Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){const t=new Set;for(const e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(const e in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[e];for(const e of i.getGlobalStateRefs())t.add(e)}for(const e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){var t;const e=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const n=this._transitionablePaint._values[i].value;for(const s of n.getGlobalStateRefs()){const r=null!==(t=e.get(s))&&void 0!==t?t:[];r.push({name:i,value:n.value}),e.set(s,r)}}return e}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,i={}){var n;if("visibility"===t)return this.visibility=e,this._visibilityExpression.setValue(e),void this.recalculateVisibility();(null===(n=this._transitionablePaint)||void 0===n?void 0:n.hasProperty(t))?this.fire(new yt(new Error(t+Jr))):null!=e&&this._validate(lr,`layers.${this.id}.layout.${t}`,t,e,i)||this._unevaluatedLayout.setValue(t,e)}getPaintProperty(t){var e,i;if(t.endsWith(Or)){const i=t.slice(0,-11);if("visibility"===i||(null===(e=this._unevaluatedLayout)||void 0===e?void 0:e.hasProperty(i)))throw new Error(t+Kr);return this._transitionablePaint.getTransition(i)}if("visibility"===t||(null===(i=this._unevaluatedLayout)||void 0===i?void 0:i.hasProperty(t)))throw new Error(t+Kr);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){var n;if("visibility"===t||(null===(n=this._unevaluatedLayout)||void 0===n?void 0:n.hasProperty(t)))return this.fire(new yt(new Error(t+Kr))),!1;if(null!=e&&this._validate(hr,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith(Or))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{const i=this._transitionablePaint._values[t],n="cross-faded-data-driven"===i.property.specification["property-type"],s=i.value.isDataDriven(),r=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);const o=this._transitionablePaint._values[t].value;return o.isDataDriven()||s||n||this._handleOverridablePaintPropertyUpdate(t,r,o)}}_handleSpecialPaintPropertyUpdate(t){}_handleOverridablePaintPropertyUpdate(t,e,i){return!1}isHidden(t=this.minzoom,e=!1){return!!(this.minzoom&&t<(e?Math.floor(this.minzoom):this.minzoom))||!!(this.maxzoom&&t>=this.maxzoom)||"none"===this._evaluatedVisibility}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculateVisibility(){this._evaluatedVisibility=this._visibilityExpression.evaluate()}recalculate(t,e){t.getCrossfadeParameters&&(this._crossfadeParameters=t.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,e)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,e)}serialize(){var t,e;const i={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:null===(t=this._unevaluatedLayout)||void 0===t?void 0:t.serialize(),paint:null===(e=this._transitionablePaint)||void 0===e?void 0:e.serialize()};return this.visibility&&(i.layout||(i.layout={}),i.layout.visibility=this.visibility),U(i,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,n,s={}){return!1!==(null==s?void 0:s.validate)&&cr(this,t.call(rr,{key:e,layerType:this.type,objectKey:i,value:n,styleSpec:bt,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const e=this.paint.get(t);if(e instanceof Gr&&Vn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}}let to;var eo={get paint(){return to=to||new Xr({"raster-opacity":new qr(bt.paint_raster["raster-opacity"]),"raster-hue-rotate":new qr(bt.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new qr(bt.paint_raster["raster-brightness-min"]),"raster-brightness-max":new qr(bt.paint_raster["raster-brightness-max"]),"raster-saturation":new qr(bt.paint_raster["raster-saturation"]),"raster-contrast":new qr(bt.paint_raster["raster-contrast"]),resampling:new qr(bt.paint_raster.resampling),"raster-resampling":new qr(bt.paint_raster["raster-resampling"]),"raster-fade-duration":new qr(bt.paint_raster["raster-fade-duration"])})}};class io extends Qr{constructor(t,e){super(t,eo,e)}}const no={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class so{constructor(t,e){this._structArray=t,this._pos1=e*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ro{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,e){return t._trim(),e&&(t.isTransferred=!0,e.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const e=Object.create(this.prototype);return e.arrayBuffer=t.arrayBuffer,e.length=t.length,e.capacity=t.arrayBuffer.byteLength/e.bytesPerElement,e._refreshViews(),e}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}}function oo(t,e=1){let i=0,n=0;return{members:t.map((t=>{const s=no[t.type].BYTES_PER_ELEMENT,r=i=ao(i,Math.max(e,s)),o=t.components||1;return n=Math.max(n,s),i+=s*o,{name:t.name,type:t.type,components:o,offset:r}})),size:ao(i,Math.max(n,e)),alignment:e}}function ao(t,e){return Math.ceil(t/e)*e}class ho extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.int16[n+0]=e,this.int16[n+1]=i,t}}ho.prototype.bytesPerElement=4,dr("StructArrayLayout2i4",ho);class lo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const s=3*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=n,t}}lo.prototype.bytesPerElement=6,dr("StructArrayLayout3i6",lo);class co extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n)}emplace(t,e,i,n,s){const r=4*t;return this.int16[r+0]=e,this.int16[r+1]=i,this.int16[r+2]=n,this.int16[r+3]=s,t}}co.prototype.bytesPerElement=8,dr("StructArrayLayout4i8",co);class uo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,s,r)}emplace(t,e,i,n,s,r,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=s,this.int16[a+4]=r,this.int16[a+5]=o,t}}uo.prototype.bytesPerElement=12,dr("StructArrayLayout2i4i12",uo);class fo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,s,r)}emplace(t,e,i,n,s,r,o){const a=4*t,h=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[h+4]=n,this.uint8[h+5]=s,this.uint8[h+6]=r,this.uint8[h+7]=o,t}}fo.prototype.bytesPerElement=8,dr("StructArrayLayout2i4ub8",fo);class po extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.float32[n+0]=e,this.float32[n+1]=i,t}}po.prototype.bytesPerElement=8,dr("StructArrayLayout2f8",po);class mo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a,h,l){const c=this.length;return this.resize(c+1),this.emplace(c,t,e,i,n,s,r,o,a,h,l)}emplace(t,e,i,n,s,r,o,a,h,l,c){const u=10*t;return this.uint16[u+0]=e,this.uint16[u+1]=i,this.uint16[u+2]=n,this.uint16[u+3]=s,this.uint16[u+4]=r,this.uint16[u+5]=o,this.uint16[u+6]=a,this.uint16[u+7]=h,this.uint16[u+8]=l,this.uint16[u+9]=c,t}}mo.prototype.bytesPerElement=20,dr("StructArrayLayout10ui20",mo);class _o extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a){const h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,n,s,r,o,a)}emplace(t,e,i,n,s,r,o,a,h){const l=8*t;return this.uint16[l+0]=e,this.uint16[l+1]=i,this.uint16[l+2]=n,this.uint16[l+3]=s,this.uint16[l+4]=r,this.uint16[l+5]=o,this.uint16[l+6]=a,this.uint16[l+7]=h,t}}_o.prototype.bytesPerElement=16,dr("StructArrayLayout8ui16",_o);class go extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a,h,l,c,u){const f=this.length;return this.resize(f+1),this.emplace(f,t,e,i,n,s,r,o,a,h,l,c,u)}emplace(t,e,i,n,s,r,o,a,h,l,c,u,f){const d=12*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=n,this.int16[d+3]=s,this.uint16[d+4]=r,this.uint16[d+5]=o,this.uint16[d+6]=a,this.uint16[d+7]=h,this.int16[d+8]=l,this.int16[d+9]=c,this.int16[d+10]=u,this.int16[d+11]=f,t}}go.prototype.bytesPerElement=24,dr("StructArrayLayout4i4ui4i24",go);class vo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const s=3*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,t}}vo.prototype.bytesPerElement=12,dr("StructArrayLayout3f12",vo);class yo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}}yo.prototype.bytesPerElement=4,dr("StructArrayLayout1ul4",yo);class wo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a,h){const l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,n,s,r,o,a,h)}emplace(t,e,i,n,s,r,o,a,h,l){const c=10*t,u=5*t;return this.int16[c+0]=e,this.int16[c+1]=i,this.int16[c+2]=n,this.int16[c+3]=s,this.int16[c+4]=r,this.int16[c+5]=o,this.uint32[u+3]=a,this.uint16[c+8]=h,this.uint16[c+9]=l,t}}wo.prototype.bytesPerElement=20,dr("StructArrayLayout6i1ul2ui20",wo);class bo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,s,r)}emplace(t,e,i,n,s,r,o){const a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=n,this.int16[a+3]=s,this.int16[a+4]=r,this.int16[a+5]=o,t}}bo.prototype.bytesPerElement=12,dr("StructArrayLayout2i2i2i12",bo);class xo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s){const r=this.length;return this.resize(r+1),this.emplace(r,t,e,i,n,s)}emplace(t,e,i,n,s,r){const o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=n,this.int16[a+6]=s,this.int16[a+7]=r,t}}xo.prototype.bytesPerElement=16,dr("StructArrayLayout2f1f2i16",xo);class Mo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r){const o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,n,s,r)}emplace(t,e,i,n,s,r,o){const a=16*t,h=4*t,l=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[h+1]=n,this.float32[h+2]=s,this.int16[l+6]=r,this.int16[l+7]=o,t}}Mo.prototype.bytesPerElement=16,dr("StructArrayLayout2ub2f2i16",Mo);class So extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const s=3*t;return this.uint16[s+0]=e,this.uint16[s+1]=i,this.uint16[s+2]=n,t}}So.prototype.bytesPerElement=6,dr("StructArrayLayout3ui6",So);class zo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_){const g=this.length;return this.resize(g+1),this.emplace(g,t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_)}emplace(t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g){const v=24*t,y=12*t,w=48*t;return this.int16[v+0]=e,this.int16[v+1]=i,this.uint16[v+2]=n,this.uint16[v+3]=s,this.uint32[y+2]=r,this.uint32[y+3]=o,this.uint32[y+4]=a,this.uint16[v+10]=h,this.uint16[v+11]=l,this.uint16[v+12]=c,this.float32[y+7]=u,this.float32[y+8]=f,this.uint8[w+36]=d,this.uint8[w+37]=p,this.uint8[w+38]=m,this.uint32[y+10]=_,this.int16[v+22]=g,t}}zo.prototype.bytesPerElement=48,dr("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",zo);class To extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y,w,b,x,M,S,z,T,E){const A=this.length;return this.resize(A+1),this.emplace(A,t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y,w,b,x,M,S,z,T,E)}emplace(t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y,w,b,x,M,S,z,T,E,A){const P=32*t,C=16*t;return this.int16[P+0]=e,this.int16[P+1]=i,this.int16[P+2]=n,this.int16[P+3]=s,this.int16[P+4]=r,this.int16[P+5]=o,this.int16[P+6]=a,this.int16[P+7]=h,this.uint16[P+8]=l,this.uint16[P+9]=c,this.uint16[P+10]=u,this.uint16[P+11]=f,this.uint16[P+12]=d,this.uint16[P+13]=p,this.uint16[P+14]=m,this.uint16[P+15]=_,this.uint16[P+16]=g,this.uint16[P+17]=v,this.uint16[P+18]=y,this.uint16[P+19]=w,this.uint16[P+20]=b,this.uint16[P+21]=x,this.uint16[P+22]=M,this.uint32[C+12]=S,this.float32[C+13]=z,this.float32[C+14]=T,this.uint16[P+30]=E,this.uint16[P+31]=A,t}}To.prototype.bytesPerElement=64,dr("StructArrayLayout8i15ui1ul2f2ui64",To);class Eo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}}Eo.prototype.bytesPerElement=4,dr("StructArrayLayout1f4",Eo);class Ao extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const s=3*t;return this.uint16[6*t+0]=e,this.float32[s+1]=i,this.float32[s+2]=n,t}}Ao.prototype.bytesPerElement=12,dr("StructArrayLayout1ui2f12",Ao);class Po extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){const n=this.length;return this.resize(n+1),this.emplace(n,t,e,i)}emplace(t,e,i,n){const s=4*t;return this.uint32[2*t+0]=e,this.uint16[s+2]=i,this.uint16[s+3]=n,t}}Po.prototype.bytesPerElement=8,dr("StructArrayLayout1ul2ui8",Po);class Co extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){const i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){const n=2*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,t}}Co.prototype.bytesPerElement=4,dr("StructArrayLayout2ui4",Co);class Do extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}}Do.prototype.bytesPerElement=2,dr("StructArrayLayout1ui2",Do);class Fo extends ro{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,n){const s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,n)}emplace(t,e,i,n,s){const r=4*t;return this.float32[r+0]=e,this.float32[r+1]=i,this.float32[r+2]=n,this.float32[r+3]=s,t}}Fo.prototype.bytesPerElement=16,dr("StructArrayLayout4f16",Fo);class Io extends so{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Io.prototype.size=20;class ko extends wo{get(t){return new Io(this,t)}}dr("CollisionBoxArray",ko);class $o extends so{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(t){this._structArray.uint8[this._pos1+37]=t}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(t){this._structArray.uint8[this._pos1+38]=t}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(t){this._structArray.uint32[this._pos4+10]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}$o.prototype.size=48;class Oo extends zo{get(t){return new $o(this,t)}}dr("PlacedSymbolArray",Oo);class jo extends so{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(t){this._structArray.uint32[this._pos4+12]=t}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}jo.prototype.size=64;class Ro extends To{get(t){return new jo(this,t)}}dr("SymbolInstanceArray",Ro);class Lo extends Eo{getoffsetX(t){return this.float32[1*t+0]}}dr("GlyphOffsetArray",Lo);class Bo extends lo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}}dr("SymbolLineVertexArray",Bo);class No extends so{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}No.prototype.size=12;class Uo extends Ao{get(t){return new No(this,t)}}dr("TextAnchorOffsetArray",Uo);class Go extends so{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}}Go.prototype.size=8;class Vo extends Po{get(t){return new Go(this,t)}}dr("FeatureIndexArray",Vo);class qo extends ho{}class Zo extends ho{}class Wo extends ho{}class Ho extends uo{}class Yo extends fo{}class Xo extends po{}class Jo extends mo{}class Ko extends _o{}class Qo extends go{}class ta extends vo{}class ea extends yo{}class ia extends bo{}class na extends Mo{}class sa extends So{}class ra extends Co{}const oa=oo([{name:"a_pos",components:2,type:"Int16"}],4),{members:aa}=oa;class ha{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(t,e,i,n){const s=this.segments[this.segments.length-1];return t>ha.MAX_VERTEX_ARRAY_LENGTH&&q(`Max vertices per segment is ${ha.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ha.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!s||s.vertexLength+t>ha.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n?this.createNewSegment(e,i,n):s}createNewSegment(t,e,i){const n={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const t of this.segments)for(const e in t.vaos)t.vaos[e].destroy()}static simpleSegment(t,e,i,n){return new ha([{vertexOffset:t,primitiveOffset:e,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function la(t,e){return 256*(t=j(Math.floor(t),0,255))+j(Math.floor(e),0,255)}ha.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,dr("SegmentVector",ha);const ca=oo([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ua=oo([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var fa,da,pa,ma={exports:{}},_a={exports:{}},ga={exports:{}},va=function(){if(pa)return ma.exports;pa=1;var t=(fa||(fa=1,_a.exports=function(t,e){var i,n,s,r,o,a,h,l;for(n=t.length-(i=3&t.length),s=e,o=3432918353,a=461845907,l=0;l<n;)h=255&t.charCodeAt(l)|(255&t.charCodeAt(++l))<<8|(255&t.charCodeAt(++l))<<16|(255&t.charCodeAt(++l))<<24,++l,s=27492+(65535&(r=5*(65535&(s=(s^=h=(65535&(h=(h=(65535&h)*o+(((h>>>16)*o&65535)<<16)&4294967295)<<15|h>>>17))*a+(((h>>>16)*a&65535)<<16)&4294967295)<<13|s>>>19))+((5*(s>>>16)&65535)<<16)&4294967295))+((58964+(r>>>16)&65535)<<16);switch(h=0,i){case 3:h^=(255&t.charCodeAt(l+2))<<16;case 2:h^=(255&t.charCodeAt(l+1))<<8;case 1:s^=h=(65535&(h=(h=(65535&(h^=255&t.charCodeAt(l)))*o+(((h>>>16)*o&65535)<<16)&4294967295)<<15|h>>>17))*a+(((h>>>16)*a&65535)<<16)&4294967295}return s^=t.length,s=2246822507*(65535&(s^=s>>>16))+((2246822507*(s>>>16)&65535)<<16)&4294967295,s=3266489909*(65535&(s^=s>>>13))+((3266489909*(s>>>16)&65535)<<16)&4294967295,(s^=s>>>16)>>>0}),_a.exports),e=(da||(da=1,ga.exports=function(t,e){for(var i,n=t.length,s=e^n,r=0;n>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(r)|(255&t.charCodeAt(++r))<<8|(255&t.charCodeAt(++r))<<16|(255&t.charCodeAt(++r))<<24))+((1540483477*(i>>>16)&65535)<<16),s=1540483477*(65535&s)+((1540483477*(s>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++r;switch(n){case 3:s^=(255&t.charCodeAt(r+2))<<16;case 2:s^=(255&t.charCodeAt(r+1))<<8;case 1:s=1540483477*(65535&(s^=255&t.charCodeAt(r)))+((1540483477*(s>>>16)&65535)<<16)}return s=1540483477*(65535&(s^=s>>>13))+((1540483477*(s>>>16)&65535)<<16),(s^=s>>>15)>>>0}),ga.exports);return ma.exports=t,ma.exports.murmur3=t,ma.exports.murmur2=e,ma.exports}(),ya=n(va);class wa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,n){this.ids.push(ba(t)),this.positions.push(e,i,n)}getPositions(t){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const e=ba(t);let i=0,n=this.ids.length-1;for(;i<n;){const t=i+n>>1;this.ids[t]>=e?n=t:i=t+1}const s=[];for(;this.ids[i]===e;)s.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return s}static serialize(t,e){const i=new Float64Array(t.ids),n=new Uint32Array(t.positions);return xa(i,n,0,i.length-1),e&&e.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(t){const e=new wa;return e.ids=t.ids,e.positions=t.positions,e.indexed=!0,e}}function ba(t){const e=+t;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ya(String(t))}function xa(t,e,i,n){for(;i<n;){const s=t[i+n>>1];let r=i-1,o=n+1;for(;;){do{r++}while(t[r]<s);do{o--}while(t[o]>s);if(r>=o)break;Ma(t,r,o),Ma(e,3*r,3*o),Ma(e,3*r+1,3*o+1),Ma(e,3*r+2,3*o+2)}o-i<n-o?(xa(t,e,i,o),i=o+1):(xa(t,e,o+1,n),n=o)}}function Ma(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}dr("FeaturePositionMap",wa);class Sa{constructor(t,e){this.gl=t.gl,this.location=e}}class za extends Sa{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}}class Ta extends Sa{constructor(t,e){super(t,e),this.current=[0,0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]&&t[3]===this.current[3]||(this.current=t,this.gl.uniform4f(this.location,t[0],t[1],t[2],t[3]))}}class Ea extends Sa{constructor(t,e){super(t,e),this.current=Pe.transparent}set(t){t.r===this.current.r&&t.g===this.current.g&&t.b===this.current.b&&t.a===this.current.a||(this.current=t,this.gl.uniform4f(this.location,t.r,t.g,t.b,t.a))}}const Aa=new Float32Array(16);function Pa(t){return[la(255*t.r,255*t.g),la(255*t.b,255*t.a)]}class Ca{constructor(t,e,i){this.value=t,this.uniformNames=e.map((t=>`u_${t}`)),this.type=i}setUniform(t,e,i){t.set(i.constantOr(this.value))}getBinding(t,e,i){return"color"===this.type?new Ea(t,e):new za(t,e)}}class Da{constructor(t,e){this.uniformNames=e.map((t=>`u_${t}`)),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(t,e){this.pixelRatioFrom=e.pixelRatio,this.pixelRatioTo=t.pixelRatio,this.patternFrom=e.tlbr,this.patternTo=t.tlbr}setConstantDashPositions(t,e){this.dashTo=[0,t.y,t.height,t.width],this.dashFrom=[0,e.y,e.height,e.width]}setUniform(t,e,i,n){let s=null;"u_pattern_to"===n?s=this.patternTo:"u_pattern_from"===n?s=this.patternFrom:"u_dasharray_to"===n?s=this.dashTo:"u_dasharray_from"===n?s=this.dashFrom:"u_pixel_ratio_to"===n?s=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(s=this.pixelRatioFrom),null!==s&&t.set(s)}getBinding(t,e,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new Ta(t,e):new za(t,e)}}class Fa{constructor(t,e,i,n){this.expression=t,this.type=i,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?2:1,offset:0}))),this.paintVertexArray=new n}populatePaintArray(t,e,i){const n=this.paintVertexArray.length,s=this.expression.evaluate(new kr(0,i),e,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(n,t,s)}updatePaintArray(t,e,i,n,s){const r=this.expression.evaluate(new kr(0,s),i,n);this._setPaintValue(t,e,r)}_setPaintValue(t,e,i){if("color"===this.type){const n=Pa(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){var e,i;(null===(e=this.paintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Ia{constructor(t,e,i,n,s,r){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=n,this.zoom=s,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new r}populatePaintArray(t,e,i){const n=this.expression.evaluate(new kr(this.zoom,i),e,{},i.canonical,[],i.formattedSection),s=this.expression.evaluate(new kr(this.zoom+1,i),e,{},i.canonical,[],i.formattedSection),r=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(r,t,n,s)}updatePaintArray(t,e,i,n,s){const r=this.expression.evaluate(new kr(this.zoom,s),i,n),o=this.expression.evaluate(new kr(this.zoom+1,s),i,n);this._setPaintValue(t,e,r,o)}_setPaintValue(t,e,i,n){if("color"===this.type){const s=Pa(i),r=Pa(n);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,s[0],s[1],r[0],r[1])}else{for(let s=t;s<e;s++)this.paintVertexArray.emplace(s,i,n);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(n))}}upload(t){var e,i;(null===(e=this.paintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&((null===(i=this.paintVertexBuffer)||void 0===i?void 0:i.buffer)?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,e){const i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,n=j(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(n)}getBinding(t,e,i){return new za(t,e)}}class ka{constructor(t,e,i,n,s,r){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=n,this.layerId=r,this.zoomInPaintVertexArray=new s,this.zoomOutPaintVertexArray=new s}populatePaintArray(t,e,i){const n=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(n,t,this.getPositionIds(e),i)}updatePaintArray(t,e,i,n,s){this._setPaintValues(t,e,this.getPositionIds(i),s)}_setPaintValues(t,e,i,n){const s=this.getPositions(n);if(!s||!i)return;const r=s[i.min],o=s[i.mid],a=s[i.max];if(r&&o&&a)for(let i=t;i<e;i++)this.emplace(this.zoomInPaintVertexArray,i,o,r),this.emplace(this.zoomOutPaintVertexArray,i,o,a)}upload(t){var e,i;if((null===(e=this.zoomInPaintVertexArray)||void 0===e?void 0:e.arrayBuffer.byteLength)&&(null===(i=this.zoomOutPaintVertexArray)||void 0===i?void 0:i.arrayBuffer.byteLength)){const e=this.getVertexAttributes();this.zoomInPaintVertexBuffer=t.createVertexBuffer(this.zoomInPaintVertexArray,e,this.expression.isStateDependent),this.zoomOutPaintVertexBuffer=t.createVertexBuffer(this.zoomOutPaintVertexArray,e,this.expression.isStateDependent)}}destroy(){this.zoomOutPaintVertexBuffer&&this.zoomOutPaintVertexBuffer.destroy(),this.zoomInPaintVertexBuffer&&this.zoomInPaintVertexBuffer.destroy()}}class $a extends ka{getPositions(t){return t.imagePositions}getPositionIds(t){var e;return null===(e=t.patterns)||void 0===e?void 0:e[this.layerId]}getVertexAttributes(){return ca.members}emplace(t,e,i,n){t.emplace(e,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],n.tlbr[0],n.tlbr[1],n.tlbr[2],n.tlbr[3],i.pixelRatio,n.pixelRatio)}}class Oa extends ka{getPositions(t){return t.dashPositions}getPositionIds(t){var e;return null===(e=t.dashes)||void 0===e?void 0:e[this.layerId]}getVertexAttributes(){return ua.members}emplace(t,e,i,n){t.emplace(e,0,i.y,i.height,i.width,0,n.y,n.height,n.width)}}class ja{constructor(t,e,i){this.binders={},this._buffers=[];const n=[];for(const s in t.paint._values){if(!i(s))continue;const r=t.paint.get(s);if(!(r instanceof Gr&&Vn(r.property.specification)))continue;const o=La(s,t.type),a=r.value,h=r.property.specification.type,l=r.property.useIntegerZoom,c=r.property.specification["property-type"],u="cross-faded"===c||"cross-faded-data-driven"===c;if("constant"===a.kind)this.binders[s]=u?new Da(a.value,o):new Ca(a.value,o,h),n.push(`/u_${s}`);else if("source"===a.kind||u){const i=Ba(s,h,"source");this.binders[s]=u?"line-dasharray"===s?new Oa(a,h,l,e,i,t.id):new $a(a,h,l,e,i,t.id):new Fa(a,o,h,i),n.push(`/a_${s}`)}else{const t=Ba(s,h,"composite");this.binders[s]=new Ia(a,o,h,l,e,t),n.push(`/z_${s}`)}}this.cacheKey=n.sort().join("")}getMaxValue(t){const e=this.binders[t];return e instanceof Fa||e instanceof Ia?e.maxValue:0}populatePaintArrays(t,e,i){for(const n in this.binders){const s=this.binders[n];(s instanceof Fa||s instanceof Ia||s instanceof ka)&&s.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(const i in this.binders){const n=this.binders[i];n instanceof Da&&n.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(const i in this.binders){const n=this.binders[i];n instanceof Da&&n.setConstantDashPositions(t,e)}}updatePaintArrays(t,e,i,n,s){let r=!1;for(const o in t){const a=e.getPositions(o);for(const e of a){const a=i.feature(e.index);for(const i in this.binders){const h=this.binders[i];if((h instanceof Fa||h instanceof Ia||h instanceof ka)&&!0===h.expression.isStateDependent){const l=n.paint.get(i);h.expression=l.value,h.updatePaintArray(e.start,e.end,a,t[o],s),r=!0}}}}return r}defines(){const t=[];for(const e in this.binders){const i=this.binders[e];(i instanceof Ca||i instanceof Da)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Fa||i instanceof Ia)for(const e of i.paintVertexAttributes)t.push(e.name);else if(i instanceof ka){const e=i.getVertexAttributes();for(const i of e)t.push(i.name)}}return t}getBinderUniforms(){const t=[];for(const e in this.binders){const i=this.binders[e];if(i instanceof Ca||i instanceof Da||i instanceof Ia)for(const e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){const i=[];for(const n in this.binders){const s=this.binders[n];if(s instanceof Ca||s instanceof Da||s instanceof Ia)for(const r of s.uniformNames)if(e[r]){const o=s.getBinding(t,e[r],r);i.push({name:r,property:n,binding:o})}}return i}setUniforms(t,e,i,n){for(const{name:t,property:s,binding:r}of e)this.binders[s].setUniform(r,n,i.get(s),t)}updatePaintBuffers(t){this._buffers=[];for(const e in this.binders){const i=this.binders[e];if(t&&i instanceof ka){const e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof Fa||i instanceof Ia)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(const e in this.binders){const i=this.binders[e];(i instanceof Fa||i instanceof Ia||i instanceof ka)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const e=this.binders[t];(e instanceof Fa||e instanceof Ia||e instanceof ka)&&e.destroy()}}}class Ra{constructor(t,e,i=()=>!0){this.programConfigurations={};for(const n of t)this.programConfigurations[n.id]=new ja(n,e,i);this.needsUpload=!1,this._featureMap=new wa,this._bufferOffset=0}populatePaintArrays(t,e,i,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,n);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,n){for(const s of i)this.needsUpload=this.programConfigurations[s.id].updatePaintArrays(t,this._featureMap,e,s,n)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}function La(t,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[t]||[t.replace(`${e}-`,"").replace(/-/g,"_")]}function Ba(t,e,i){const n={color:{source:po,composite:Fo},number:{source:Eo,composite:po}},s=function(t){return{"line-pattern":{source:Jo,composite:Jo},"fill-pattern":{source:Jo,composite:Jo},"fill-extrusion-pattern":{source:Jo,composite:Jo},"line-dasharray":{source:Ko,composite:Ko}}[t]}(t);return(null==s?void 0:s[i])||n[e][i]}dr("ConstantBinder",Ca),dr("CrossFadedConstantBinder",Da),dr("SourceExpressionBinder",Fa),dr("CrossFadedPatternBinder",$a),dr("CrossFadedDasharrayBinder",Oa),dr("CompositeExpressionBinder",Ia),dr("ProgramConfiguration",ja,{omit:["_buffers"]}),dr("ProgramConfigurationSet",Ra);const Na=Math.pow(2,14)-1,Ua=-Na-1;function Ga(t){const e=P/t.extent,i=t.loadGeometry();for(const t of i)for(const i of t){const t=Math.round(i.x*e),n=Math.round(i.y*e);i.x=j(t,Ua,Na),i.y=j(n,Ua,Na),(t<i.x||t>i.x+1||n<i.y||n>i.y+1)&&q("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function Va(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?Ga(t):[]}}const qa=-32768;function Za(t,e,i,n,s){t.emplaceBack(qa+8*e+n,qa+8*i+s)}class Wa{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Zo,this.indexArray=new sa,this.segments=new ha,this.programConfigurations=new Ra(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){const n=this.layers[0],s=[];let r=null,o=!1,a="heatmap"===n.type;if("circle"===n.type){const t=n;r=t.layout.get("circle-sort-key"),o=!r.isConstant(),a||(a="map"===t.paint.get("circle-pitch-alignment"))}const h=a?e.subdivisionGranularity.circle:1;for(const{feature:e,id:n,index:a,sourceLayerIndex:h}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Va(e,t);if(!this.layers[0]._featureFilter.filter(new kr(this.zoom),l,i))continue;const c=o?r.evaluate(l,{},i):void 0,u={id:n,properties:e.properties,type:e.type,sourceLayerIndex:h,index:a,geometry:t?l.geometry:Ga(e),patterns:{},sortKey:c};s.push(u)}o&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of s){const{geometry:s,index:r,sourceLayerIndex:o}=n,a=t[r].feature;this.addFeature(n,s,r,i,h),e.featureIndex.insert(a,s,r,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,aa),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,e,i,n,s=1){let r;switch(s){case 1:r=[0,7];break;case 3:r=[0,2,5,7];break;case 5:r=[0,1,3,4,6,7];break;case 7:r=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${s}; valid values are 1, 3, 5, 7.`)}const o=r.length;for(const i of e)for(const e of i){const i=e.x,n=e.y;if(i<0||i>=P||n<0||n>=P)continue;const s=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),a=s.vertexLength;for(let t=0;t<o;t++)for(let e=0;e<o;e++)Za(this.layoutVertexArray,i,n,r[e],r[t]);for(let t=0;t<o-1;t++)for(let e=0;e<o-1;e++){const i=a+t*o+e,n=a+(t+1)*o+e;this.indexArray.emplaceBack(i,n+1,i+1),this.indexArray.emplaceBack(i,n,n+1)}s.vertexLength+=o*o,s.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:n})}}function Ha(t,e){for(const i of t)if(nh(e,i))return!0;for(const i of e)if(nh(t,i))return!0;return Ka(t,e)}function Ya(t,e,i){return!!nh(t,e)||th(e,t,i)}function Xa(t,e){if(1===t.length)return ih(e,t[0]);for(const i of e)for(const e of i)if(nh(t,e))return!0;for(const i of t)if(ih(e,i))return!0;for(const i of e)if(Ka(t,i))return!0;return!1}function Ja(t,e,i){if(t.length>1){if(Ka(t,e))return!0;for(const n of e)if(th(n,t,i))return!0}for(const n of t)if(th(n,e,i))return!0;return!1}function Ka(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)if(Qa(n,s,e[t],e[t+1]))return!0}return!1}function Qa(t,e,i,n){return Z(t,i,n)!==Z(e,i,n)&&Z(t,e,i)!==Z(t,e,n)}function th(t,e,i){const n=i*i;if(1===e.length)return t.distSqr(e[0])<n;for(let i=1;i<e.length;i++)if(eh(t,e[i-1],e[i])<n)return!0;return!1}function eh(t,e,i){const n=e.distSqr(i);if(0===n)return t.distSqr(e);const s=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/n;return t.distSqr(s<0?e:s>1?i:i.sub(e)._mult(s)._add(e))}function ih(t,e){let i,n,s,r=!1;for(const o of t){i=o;for(let t=0,o=i.length-1;t<i.length;o=t++)n=i[t],s=i[o],n.y>e.y!=s.y>e.y&&e.x<(s.x-n.x)*(e.y-n.y)/(s.y-n.y)+n.x&&(r=!r)}return r}function nh(t,e){let i=!1;for(let n=0,s=t.length-1;n<t.length;s=n++){const r=t[n],o=t[s];r.y>e.y!=o.y>e.y&&e.x<(o.x-r.x)*(e.y-r.y)/(o.y-r.y)+r.x&&(i=!i)}return i}function sh(t,e,i){const n=i[0],s=i[2];if(t.x<n.x&&e.x<n.x||t.x>s.x&&e.x>s.x||t.y<n.y&&e.y<n.y||t.y>s.y&&e.y>s.y)return!1;const r=Z(t,e,i[0]);return r!==Z(t,e,i[1])||r!==Z(t,e,i[2])||r!==Z(t,e,i[3])}function rh(t,e,i){const n=e.paint.get(t).value;return"constant"===n.kind?n.value:i.programConfigurations.get(e.id).getMaxValue(t)}function oh(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function ah(t,e,n,s,r){if(!e[0]&&!e[1])return t;const o=i.convert(e)._mult(r);"viewport"===n&&o._rotate(-s);const a=[];for(const e of t)a.push(e.sub(o));return a}function hh(t){const e=[];for(let i=0;i<t.length;i++){const n=t[i],s=e.at(-1);(0===i||s&&!n.equals(s))&&e.push(n)}return e}function lh({queryGeometry:t,size:e},i){return Ya(t,i,e)}function ch({queryGeometry:t,size:e,transform:i,unwrappedTileID:n,getElevation:s},r){return Ya(t,r,e*(i.projectTileCoordinates(r.x,r.y,n,s).signedDistanceFromCamera/i.cameraToCenterDistance))}function uh({queryGeometry:t,size:e,transform:i,unwrappedTileID:n,getElevation:s},r){const o=i.projectTileCoordinates(r.x,r.y,n,s).signedDistanceFromCamera,a=e*(i.cameraToCenterDistance/o);return Ya(t,ph(r,i,n,s),a)}function fh({queryGeometry:t,size:e,transform:i,unwrappedTileID:n,getElevation:s},r){return Ya(t,ph(r,i,n,s),e)}function dh({queryGeometry:t,size:e,transform:i,unwrappedTileID:n,getElevation:s,pitchAlignment:r="map",pitchScale:o="map"},a){const h="map"===r?"map"===o?lh:ch:"map"===o?uh:fh,l={queryGeometry:t,size:e,transform:i,unwrappedTileID:n,getElevation:s};for(const t of a)for(const e of t)if(h(l,e))return!0;return!1}function ph(t,e,n,s){const r=e.projectTileCoordinates(t.x,t.y,n,s).point;return new i((.5*r.x+.5)*e.width,(.5*-r.y+.5)*e.height)}let mh,_h;dr("CircleBucket",Wa,{omit:["layers"]});var gh={get paint(){return _h=_h||new Xr({"circle-radius":new Zr(bt.paint_circle["circle-radius"]),"circle-color":new Zr(bt.paint_circle["circle-color"]),"circle-blur":new Zr(bt.paint_circle["circle-blur"]),"circle-opacity":new Zr(bt.paint_circle["circle-opacity"]),"circle-translate":new qr(bt.paint_circle["circle-translate"]),"circle-translate-anchor":new qr(bt.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new qr(bt.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new qr(bt.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new Zr(bt.paint_circle["circle-stroke-width"]),"circle-stroke-color":new Zr(bt.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new Zr(bt.paint_circle["circle-stroke-opacity"])})},get layout(){return mh=mh||new Xr({"circle-sort-key":new Zr(bt.layout_circle["circle-sort-key"])})}};class vh extends Qr{constructor(t,e){super(t,gh,e)}createBucket(t){return new Wa(t)}queryRadius(t){const e=t;return rh("circle-radius",this,e)+rh("circle-stroke-width",this,e)+oh(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:n,transform:s,pixelsToTileUnits:r,unwrappedTileID:o,getElevation:a}){const h=ah(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-s.bearingInRadians,r),l=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),c=this.paint.get("circle-pitch-scale"),u=this.paint.get("circle-pitch-alignment");let f,d;return"map"===u?(f=h,d=l*r):(f=function(t,e,i,n){return t.map((t=>ph(t,e,i,n)))}(h,s,o,a),d=l),dh({queryGeometry:f,size:d,transform:s,unwrappedTileID:o,getElevation:a,pitchAlignment:u,pitchScale:c},n)}}class yh extends Wa{}let wh;dr("HeatmapBucket",yh,{omit:["layers"]});var bh={get paint(){return wh=wh||new Xr({"heatmap-radius":new Zr(bt.paint_heatmap["heatmap-radius"]),"heatmap-weight":new Zr(bt.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new qr(bt.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Yr(bt.paint_heatmap["heatmap-color"]),"heatmap-opacity":new qr(bt.paint_heatmap["heatmap-opacity"])})}};function xh(t,{width:e,height:i},n,s){if(s){if(s instanceof Uint8ClampedArray)s=new Uint8Array(s.buffer);else if(s.length!==e*i*n)throw new RangeError(`mismatched image size. expected: ${s.length} but got: ${e*i*n}`)}else s=new Uint8Array(e*i*n);return t.width=e,t.height=i,t.data=s,t}function Mh(t,{width:e,height:i},n){if(e===t.width&&i===t.height)return;const s=xh({},{width:e,height:i},n);Sh(t,s,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},n),t.width=e,t.height=i,t.data=s.data}function Sh(t,e,i,n,s,r){if(0===s.width||0===s.height)return e;if(s.width>t.width||s.height>t.height||i.x>t.width-s.width||i.y>t.height-s.height)throw new RangeError("out of range source coordinates for image copy");if(s.width>e.width||s.height>e.height||n.x>e.width-s.width||n.y>e.height-s.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=e.data;if(o===a)throw new Error("srcData equals dstData, so image is already copied");for(let h=0;h<s.height;h++){const l=((i.y+h)*t.width+i.x)*r,c=((n.y+h)*e.width+n.x)*r;for(let t=0;t<s.width*r;t++)a[c+t]=o[l+t]}return e}class zh{constructor(t,e){xh(this,t,1,e)}resize(t){Mh(this,t,1)}clone(){return new zh({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,n,s){Sh(t,e,i,n,s,1)}}class Th{constructor(t,e){xh(this,t,4,e)}resize(t){Mh(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Th({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,n,s){Sh(t,e,i,n,s,4)}setPixel(t,e,i){const n=4*(t*this.width+e);this.data[n+0]=Math.round(255*i.r/i.a),this.data[n+1]=Math.round(255*i.g/i.a),this.data[n+2]=Math.round(255*i.b/i.a),this.data[n+3]=Math.round(255*i.a)}}function Eh(t){const e=new Uint8Array(t.length);for(let i=0;i<t.length;i+=4){const n=t[i+3];e[i+0]=Math.round(t[i+0]*n/255),e[i+1]=Math.round(t[i+1]*n/255),e[i+2]=Math.round(t[i+2]*n/255),e[i+3]=n}return e}function Ah(t){const e={},i=t.resolution||256,n=t.clips?t.clips.length:1,s=t.image||new Th({width:i,height:n});if(Math.log(i)/Math.LN2%1!=0)throw new Error(`width is not a power of 2 - ${i}`);const r=(n,r,o)=>{e[t.evaluationKey]=o;const a=t.expression.evaluate(e);s.setPixel(n/4/i,r/4,a)};if(t.clips)for(let e=0,s=0;e<n;++e,s+=4*i)for(let n=0,o=0;n<i;n++,o+=4){const a=n/(i-1),{start:h,end:l}=t.clips[e];r(s,o,h*(1-a)+l*a)}else for(let t=0,e=0;t<i;t++,e+=4)r(0,e,t/(i-1));return s}dr("AlphaImage",zh),dr("RGBAImage",Th);const Ph="big-fb";class Ch extends Qr{createBucket(t){return new yh(t)}constructor(t,e){super(t,bh,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Ah({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has(Ph)&&this.heatmapFbos.delete(Ph)}queryRadius(t){return rh("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:n,transform:s,pixelsToTileUnits:r,unwrappedTileID:o,getElevation:a}){return dh({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,i)*r,transform:s,unwrappedTileID:o,getElevation:a},n)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}}let Dh;var Fh={get paint(){return Dh=Dh||new Xr({"hillshade-illumination-direction":new qr(bt.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-altitude":new qr(bt.paint_hillshade["hillshade-illumination-altitude"]),"hillshade-illumination-anchor":new qr(bt.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new qr(bt.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new qr(bt.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new qr(bt.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new qr(bt.paint_hillshade["hillshade-accent-color"]),"hillshade-method":new qr(bt.paint_hillshade["hillshade-method"]),resampling:new qr(bt.paint_hillshade.resampling)})}};class Ih extends Qr{constructor(t,e){super(t,Fh,e),this.recalculate({zoom:0,zoomHistory:{}},void 0)}getIlluminationProperties(){let t=this.paint.get("hillshade-illumination-direction").values,e=this.paint.get("hillshade-illumination-altitude").values,i=this.paint.get("hillshade-highlight-color").values,n=this.paint.get("hillshade-shadow-color").values;const s=Math.max(t.length,e.length,i.length,n.length);t=t.concat(Array(s-t.length).fill(t.at(-1))),e=e.concat(Array(s-e.length).fill(e.at(-1))),i=i.concat(Array(s-i.length).fill(i.at(-1))),n=n.concat(Array(s-n.length).fill(n.at(-1)));const r=e.map(et);return{directionRadians:t.map(et),altitudeRadians:r,shadowColor:n,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}}let kh;var $h={get paint(){return kh=kh||new Xr({"color-relief-opacity":new qr(bt["paint_color-relief"]["color-relief-opacity"]),"color-relief-color":new Yr(bt["paint_color-relief"]["color-relief-color"]),resampling:new qr(bt["paint_color-relief"].resampling)})}};function Oh(t){return"data"in t}class jh{constructor(t,e,i,n){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(e,n)}update(t,e,i){var n;const{width:s,height:r}=t,o=((null===(n=this.size)||void 0===n?void 0:n[0])!==s||this.size[1]!==r)&&!i,{context:a}=this,{gl:h}=a;this.useMipmap=Boolean(null==e?void 0:e.useMipmap),h.bindTexture(h.TEXTURE_2D,this.texture),a.pixelStoreUnpackFlipY.set(!1),a.pixelStoreUnpack.set(1);const l=this.format===h.RGBA&&!1!==(null==e?void 0:e.premultiply);if(o)this.size=[s,r],Oh(t)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,l,s,r,h)):(a.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(t,h));else{const{x:e,y:n}=i||{x:0,y:0};Oh(t)?(a.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,l,e,n,s,r,h)):(a.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(t,e,n,h))}this.useMipmap&&this.isSizePowerOfTwo()&&h.generateMipmap(h.TEXTURE_2D),a.pixelStoreUnpackFlipY.setDefault(),a.pixelStoreUnpack.setDefault(),a.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,e){e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,e.UNSIGNED_BYTE,t)}_uploadRawData(t,e,i,n,s){let{data:r}=t;e&&r&&(r=Eh(r)),s.texImage2D(s.TEXTURE_2D,0,this.format,i,n,0,this.format,s.UNSIGNED_BYTE,r)}_updateDomImage(t,e,i,n){n.texSubImage2D(n.TEXTURE_2D,0,e,i,n.RGBA,n.UNSIGNED_BYTE,t)}_updateRawData(t,e,i,n,s,r,o){let{data:a}=t;e&&a&&(a=Eh(a)),o.texSubImage2D(o.TEXTURE_2D,0,i,n,s,r,o.RGBA,o.UNSIGNED_BYTE,a)}bind(t,e,i){const{context:n}=this,{gl:s}=n;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),s.bindTexture(s.TEXTURE_2D,this.texture),i!==s.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(i=s.LINEAR),t!==this.filter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,i||t),this.filter=t),e!==this.wrap&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,e),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,e),this.wrap=e)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}}class Rh{constructor(t,e,i,n=1,s=1,r=1,o=0){if(this.uid=t,e.height!==e.width)throw new RangeError("DEM tiles must be square");if(i&&!["mapbox","terrarium","custom"].includes(i))return void q(`"${i}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=e.height;const a=this.dim=e.height-2;switch(this.data=new Uint32Array(e.data.buffer),i){case"terrarium":this.redFactor=256,this.greenFactor=1,this.blueFactor=1/256,this.baseShift=32768;break;case"custom":this.redFactor=n,this.greenFactor=s,this.blueFactor=r,this.baseShift=o;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=0;t<a;t++)this.data[this._idx(-1,t)]=this.data[this._idx(0,t)],this.data[this._idx(a,t)]=this.data[this._idx(a-1,t)],this.data[this._idx(t,-1)]=this.data[this._idx(t,0)],this.data[this._idx(t,a)]=this.data[this._idx(t,a-1)];this.data[this._idx(-1,-1)]=this.data[this._idx(0,0)],this.data[this._idx(a,-1)]=this.data[this._idx(a-1,0)],this.data[this._idx(-1,a)]=this.data[this._idx(0,a-1)],this.data[this._idx(a,a)]=this.data[this._idx(a-1,a-1)],this.min=Number.MAX_SAFE_INTEGER,this.max=Number.MIN_SAFE_INTEGER;for(let t=0;t<a;t++)for(let e=0;e<a;e++){const i=this.get(t,e);i>this.max&&(this.max=i),i<this.min&&(this.min=i)}}get(t,e){const i=new Uint8Array(this.data.buffer),n=4*this._idx(t,e);return this.unpack(i[n],i[n+1],i[n+2])}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-1||t>=this.dim+1||e<-1||e>=this.dim+1)throw new RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);return(e+1)*this.stride+(t+1)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return Lh(t,this.getUnpackVector())}getPixels(){return new Th({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(t,e,i){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let n=e*this.dim,s=e*this.dim+this.dim,r=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:n=s-1;break;case 1:s=n+1}switch(i){case-1:r=o-1;break;case 1:o=r+1}const a=-e*this.dim,h=-i*this.dim;for(let e=r;e<o;e++)for(let i=n;i<s;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+h)]}}function Lh(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=Math.min(i,n,s),a=Math.round((t+r)/o);return{r:Math.floor(a*o/i)%256,g:Math.floor(a*o/n)%256,b:Math.floor(a*o/s)%256}}dr("DEMData",Rh);class Bh extends Qr{constructor(t,e){super(t,$h,e)}_createColorRamp(t){const e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof rs&&i._styleExpression.expression instanceof pi){this.colorRampExpression=i;const t=i._styleExpression.expression;e.elevationStops=t.labels,e.colorStops=[];for(const i of e.elevationStops)e.colorStops.push(t.evaluate({globals:{elevation:i}}))}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[Pe.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;const n={elevationStops:[],colorStops:[]},s=(e.elevationStops.length-1)/(t-1);for(let t=0;t<e.elevationStops.length-.5;t+=s)n.elevationStops.push(e.elevationStops[Math.round(t)]),n.colorStops.push(e.colorStops[Math.round(t)]);return q(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),n}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;const n=this._createColorRamp(e),s=new Th({width:n.colorStops.length,height:1}),r=new Th({width:n.colorStops.length,height:1});for(let t=0;t<n.elevationStops.length;t++){const e=Lh(n.elevationStops[t],i);r.setPixel(0,t,new Pe(e.r/255,e.g/255,e.b/255,1)),s.setPixel(0,t,n.colorStops[t])}return this.colorRampTextures={elevationTexture:new jh(t,r,t.gl.RGBA),colorTexture:new jh(t,s,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}}const Nh=oo([{name:"a_pos",components:2,type:"Int16"}],4),{members:Uh}=Nh;function Gh(t,e,i){const n=i.patternDependencies;let s=!1;for(const i of e){const e=i.paint.get(`${t}-pattern`);e.isConstant()||(s=!0);const r=e.constantOr(null);r&&(s=!0,n[r.to]=!0,n[r.from]=!0)}return s}function Vh(t,e,i,n,s){const{zoom:r}=n,o=s.patternDependencies;for(const n of e){const e=n.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:r-1},i,{},s.availableImages),a=e.evaluate({zoom:r},i,{},s.availableImages),h=e.evaluate({zoom:r+1},i,{},s.availableImages);t=(null==t?void 0:t.name)?t.name:t,a=(null==a?void 0:a.name)?a.name:a,h=(null==h?void 0:h.name)?h.name:h,o[t]=!0,o[a]=!0,o[h]=!0,i.patterns[n.id]={min:t,mid:a,max:h}}}return i}function qh(t,e,i,n,s){let r;if(s===function(t,e,i,n){let s=0;for(let r=e,o=i-n;r<i;r+=n)s+=(t[o]-t[r])*(t[r+1]+t[o+1]),o=r;return s}(t,e,i,n)>0)for(let s=e;s<i;s+=n)r=dl(s/n|0,t[s],t[s+1],r);else for(let s=i-n;s>=e;s-=n)r=dl(s/n|0,t[s],t[s+1],r);return r&&al(r,r.next)&&(pl(r),r=r.next),r}function Zh(t,e){if(!t)return t;e||(e=t);let i,n=t;do{if(i=!1,n.steiner||!al(n,n.next)&&0!==ol(n.prev,n,n.next))n=n.next;else{if(pl(n),n=e=n.prev,n===n.next)break;i=!0}}while(i||n!==e);return e}function Wh(t,e,i,n,s,r,o){if(!t)return;!o&&r&&function(t,e,i,n){let s=t;do{0===s.z&&(s.z=el(s.x,s.y,e,i,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next}while(s!==t);s.prevZ.nextZ=null,s.prevZ=null,function(t){let e,i=1;do{let n,s=t;t=null;let r=null;for(e=0;s;){e++;let o=s,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let h=i;for(;a>0||h>0&&o;)0!==a&&(0===h||!o||s.z<=o.z)?(n=s,s=s.nextZ,a--):(n=o,o=o.nextZ,h--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;s=o}r.nextZ=null,i*=2}while(e>1)}(s)}(t,n,s,r);let a=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(r?Yh(t,n,s,r):Hh(t))e.push(h.i,t.i,l.i),pl(t),t=l.next,a=l.next;else if((t=l)===a){o?1===o?Wh(t=Xh(Zh(t),e),e,i,n,s,r,2):2===o&&Jh(t,e,i,n,s,r):Wh(Zh(t),e,i,n,s,r,1);break}}}function Hh(t){const e=t.prev,i=t,n=t.next;if(ol(e,i,n)>=0)return!1;const s=e.x,r=i.x,o=n.x,a=e.y,h=i.y,l=n.y,c=Math.min(s,r,o),u=Math.min(a,h,l),f=Math.max(s,r,o),d=Math.max(a,h,l);let p=n.next;for(;p!==e;){if(p.x>=c&&p.x<=f&&p.y>=u&&p.y<=d&&sl(s,a,r,h,o,l,p.x,p.y)&&ol(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Yh(t,e,i,n){const s=t.prev,r=t,o=t.next;if(ol(s,r,o)>=0)return!1;const a=s.x,h=r.x,l=o.x,c=s.y,u=r.y,f=o.y,d=Math.min(a,h,l),p=Math.min(c,u,f),m=Math.max(a,h,l),_=Math.max(c,u,f),g=el(d,p,e,i,n),v=el(m,_,e,i,n);let y=t.prevZ,w=t.nextZ;for(;y&&y.z>=g&&w&&w.z<=v;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=_&&y!==s&&y!==o&&sl(a,c,h,u,l,f,y.x,y.y)&&ol(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,w.x>=d&&w.x<=m&&w.y>=p&&w.y<=_&&w!==s&&w!==o&&sl(a,c,h,u,l,f,w.x,w.y)&&ol(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;y&&y.z>=g;){if(y.x>=d&&y.x<=m&&y.y>=p&&y.y<=_&&y!==s&&y!==o&&sl(a,c,h,u,l,f,y.x,y.y)&&ol(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;w&&w.z<=v;){if(w.x>=d&&w.x<=m&&w.y>=p&&w.y<=_&&w!==s&&w!==o&&sl(a,c,h,u,l,f,w.x,w.y)&&ol(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Xh(t,e){let i=t;do{const n=i.prev,s=i.next.next;!al(n,s)&&hl(n,i,i.next,s)&&ul(n,s)&&ul(s,n)&&(e.push(n.i,i.i,s.i),pl(i),pl(i.next),i=t=s),i=i.next}while(i!==t);return Zh(i)}function Jh(t,e,i,n,s,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&rl(o,t)){let a=fl(o,t);return o=Zh(o,o.next),a=Zh(a,a.next),Wh(o,e,i,n,s,r,0),void Wh(a,e,i,n,s,r,0)}t=t.next}o=o.next}while(o!==t)}function Kh(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function Qh(t,e){const i=function(t,e){let i=e;const n=t.x,s=t.y;let r,o=-1/0;if(al(t,i))return i;do{if(al(t,i.next))return i.next;if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){const t=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=n&&t>o&&(o=t,r=i.x<i.next.x?i:i.next,t===n))return r}i=i.next}while(i!==e);if(!r)return null;const a=r,h=r.x,l=r.y;let c=1/0;i=r;do{if(n>=i.x&&i.x>=h&&n!==i.x&&nl(s<l?n:o,s,h,l,s<l?o:n,s,i.x,i.y)){const e=Math.abs(s-i.y)/(n-i.x);ul(i,t)&&(e<c||e===c&&(i.x>r.x||i.x===r.x&&tl(r,i)))&&(r=i,c=e)}i=i.next}while(i!==a);return r}(t,e);if(!i)return e;const n=fl(i,t);return Zh(n,n.next),Zh(i,i.next)}function tl(t,e){return ol(t.prev,t,e.prev)<0&&ol(e.next,t,t.next)<0}function el(t,e,i,n,s){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*s|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*s|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function il(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function nl(t,e,i,n,s,r,o,a){return(s-o)*(e-a)>=(t-o)*(r-a)&&(t-o)*(n-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(s-o)*(n-a)}function sl(t,e,i,n,s,r,o,a){return!(t===o&&e===a)&&nl(t,e,i,n,s,r,o,a)}function rl(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&hl(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(ul(t,e)&&ul(e,t)&&function(t,e){let i=t,n=!1;const s=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&s<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(n=!n),i=i.next}while(i!==t);return n}(t,e)&&(ol(t.prev,t,e.prev)||ol(t,e.prev,e))||al(t,e)&&ol(t.prev,t,t.next)>0&&ol(e.prev,e,e.next)>0)}function ol(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function al(t,e){return t.x===e.x&&t.y===e.y}function hl(t,e,i,n){const s=cl(ol(t,e,i)),r=cl(ol(t,e,n)),o=cl(ol(i,n,t)),a=cl(ol(i,n,e));return s!==r&&o!==a||!(0!==s||!ll(t,i,e))||!(0!==r||!ll(t,n,e))||!(0!==o||!ll(i,t,n))||!(0!==a||!ll(i,e,n))}function ll(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function cl(t){return t>0?1:t<0?-1:0}function ul(t,e){return ol(t.prev,t,t.next)<0?ol(t,e,t.next)>=0&&ol(t,t.prev,e)>=0:ol(t,e,t.prev)<0||ol(t,t.next,e)<0}function fl(t,e){const i=ml(t.i,t.x,t.y),n=ml(e.i,e.x,e.y),s=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=s,s.prev=i,n.next=i,i.prev=n,r.next=n,n.prev=r,n}function dl(t,e,i,n){const s=ml(t,e,i);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function pl(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function ml(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class _l{constructor(t,e){if(e>t)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=t,this._minGranularity=e}getGranularityForZoomLevel(t){return Math.max(Math.floor(this._baseZoomGranularity/(1<<t)),this._minGranularity,1)}}class gl{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}}gl.noSubdivision=new gl({fill:new _l(0,0),line:new _l(0,0),tile:new _l(0,0),stencil:new _l(0,0),circle:1}),dr("SubdivisionGranularityExpression",_l),dr("SubdivisionGranularitySetting",gl);const vl=-32768,yl=32767;class wl{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=P/t,this._canonical=e}_getKey(t,e){return(t+=32768)<<16|e+32768}_vertexToIndex(t,e){if(t<-32768||e<-32768||t>32767||e>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(t),n=0|Math.round(e),s=this._getKey(i,n);if(this._vertexDictionary.has(s))return this._vertexDictionary.get(s);const r=this._vertexBuffer.length/2;return this._vertexDictionary.set(s,r),this._vertexBuffer.push(i,n),r}_subdivideTrianglesScanline(t){if(this._granularity<2)return function(t,e){const i=[];for(let n=0;n<e.length;n+=3){const s=e[n],r=e[n+1],o=e[n+2],a=t[2*s],h=t[2*s+1];(t[2*r]-a)*(t[2*o+1]-h)-(t[2*r+1]-h)*(t[2*o]-a)>0?(i.push(s),i.push(o),i.push(r)):(i.push(s),i.push(r),i.push(o))}return i}(this._vertexBuffer,t);const e=[],i=t.length;for(let n=0;n<i;n+=3){const i=[t[n+0],t[n+1],t[n+2]],s=[this._vertexBuffer[2*t[n+0]+0],this._vertexBuffer[2*t[n+0]+1],this._vertexBuffer[2*t[n+1]+0],this._vertexBuffer[2*t[n+1]+1],this._vertexBuffer[2*t[n+2]+0],this._vertexBuffer[2*t[n+2]+1]];let r=1/0,o=1/0,a=-1/0,h=-1/0;for(let t=0;t<3;t++){const e=s[2*t],i=s[2*t+1];r=Math.min(r,e),a=Math.max(a,e),o=Math.min(o,i),h=Math.max(h,i)}if(r===a||o===h)continue;const l=Math.floor(r/this._granularityCellSize),c=Math.ceil(a/this._granularityCellSize),u=Math.floor(o/this._granularityCellSize),f=Math.ceil(h/this._granularityCellSize);if(l!==c||u!==f)for(let t=u;t<f;t++){const n=this._scanlineGenerateVertexRingForCellRow(t,s,i);Ml(this._vertexBuffer,n,e)}else e.push(...i)}return e}_scanlineGenerateVertexRingForCellRow(t,e,i){const n=t*this._granularityCellSize,s=n+this._granularityCellSize,r=[];for(let t=0;t<3;t++){const o=e[2*t],a=e[2*t+1],h=e[2*(t+1)%6],l=e[(2*(t+1)+1)%6],c=e[2*(t+2)%6],u=e[(2*(t+2)+1)%6],f=h-o,d=l-a,p=0===f,m=0===d,_=(n-a)/d,g=(s-a)/d,v=Math.min(_,g),y=Math.max(_,g);if(!m&&(v>=1||y<=0)||m&&(a<n||a>s)){l>=n&&l<=s&&r.push(i[(t+1)%3]);continue}!m&&v>0&&r.push(this._vertexToIndex(o+f*v,a+d*v));const w=o+f*Math.max(v,0),b=o+f*Math.min(y,1);p||this._generateIntraEdgeVertices(r,o,a,h,l,w,b),!m&&y<1&&r.push(this._vertexToIndex(o+f*y,a+d*y)),(m||l>=n&&l<=s)&&r.push(i[(t+1)%3]),!m&&(l<=n||l>=s)&&this._generateInterEdgeVertices(r,o,a,h,l,c,u,b,n,s)}return r}_generateIntraEdgeVertices(t,e,i,n,s,r,o){const a=n-e,h=s-i,l=0===h,c=l?Math.min(e,n):Math.min(r,o),u=l?Math.max(e,n):Math.max(r,o),f=Math.floor(c/this._granularityCellSize)+1,d=Math.ceil(u/this._granularityCellSize)-1;if(l?e<n:r<o)for(let n=f;n<=d;n++){const s=n*this._granularityCellSize;t.push(this._vertexToIndex(s,i+h*(s-e)/a))}else for(let n=d;n>=f;n--){const s=n*this._granularityCellSize;t.push(this._vertexToIndex(s,i+h*(s-e)/a))}}_generateInterEdgeVertices(t,e,i,n,s,r,o,a,h,l){const c=s-i,u=r-n,f=o-s,d=(h-s)/f,p=(l-s)/f,m=Math.min(d,p),_=Math.max(d,p),g=n+u*m;let v=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,w=a<g;const b=0===f;if(b&&(o===h||o===l))return;if(b||m>=1||_<=0){const t=i-o,n=r+(e-r)*Math.min((h-o)/t,(l-o)/t);v=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,w=a<n}const x=c>0?l:h;if(w)for(let e=v;e<=y;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,x));else for(let e=y;e>=v;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,x))}_generateOutline(t){const e=[];for(const i of t){const t=xl(i,this._granularity,!0),n=this._pointArrayToIndices(t),s=[];for(let t=1;t<n.length;t++)s.push(n[t-1]),s.push(n[t]);e.push(s)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){const i=t[e+1];i===vl&&(t[e+1]=-32767),i===yl&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,n,s,r){n>s!=(r===vl)?(t.push(e),t.push(i),t.push(this._vertexToIndex(n,r)),t.push(i),t.push(this._vertexToIndex(s,r)),t.push(this._vertexToIndex(n,r))):(t.push(i),t.push(e),t.push(this._vertexToIndex(n,r)),t.push(this._vertexToIndex(s,r)),t.push(i),t.push(this._vertexToIndex(n,r)))}_fillPoles(t,e,i){const n=this._vertexBuffer,s=P,r=t.length;for(let o=2;o<r;o+=3){const r=t[o-2],a=t[o-1],h=t[o],l=n[2*r],c=n[2*r+1],u=n[2*a],f=n[2*a+1],d=n[2*h],p=n[2*h+1];e&&(0===c&&0===f&&this._generatePoleQuad(t,r,a,l,u,vl),0===f&&0===p&&this._generatePoleQuad(t,a,h,u,d,vl),0===p&&0===c&&this._generatePoleQuad(t,h,r,d,l,vl)),i&&(c===s&&f===s&&this._generatePoleQuad(t,r,a,l,u,yl),f===s&&p===s&&this._generatePoleQuad(t,a,h,u,d,yl),p===s&&c===s&&this._generatePoleQuad(t,h,r,d,l,yl))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:n}=function(t){const e=[],i=[];for(const n of t)if(0!==n.length){n!==t[0]&&e.push(i.length/2);for(const t of n)i.push(t.x),i.push(t.y)}return{flattened:i,holeIndices:e}}(t);let s;this._initializeVertices(i);try{const t=function(t,e,i=2){const n=e&&e.length,s=n?e[0]*i:t.length;let r=qh(t,0,s,i,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(n&&(r=function(t,e,i,n){const s=[];for(let i=0,r=e.length;i<r;i++){const o=qh(t,e[i]*n,i<r-1?e[i+1]*n:t.length,n,!1);o===o.next&&(o.steiner=!0),s.push(il(o))}s.sort(Kh);for(let t=0;t<s.length;t++)i=Qh(s[t],i);return i}(t,e,r,i)),t.length>80*i){a=t[0],h=t[1];let e=a,n=h;for(let r=i;r<s;r+=i){const i=t[r],s=t[r+1];i<a&&(a=i),s<h&&(h=s),i>e&&(e=i),s>n&&(n=s)}l=Math.max(e-a,n-h),l=0!==l?32767/l:0}return Wh(r,o,i,a,h,l,0),o}(i,n),e=this._convertIndices(i,t);s=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let r=[];return e&&(r=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(s),{verticesFlattened:this._vertexBuffer,indicesTriangles:s,indicesLineList:r}}_convertIndices(t,e){const i=[];for(const n of e)i.push(this._vertexToIndex(t[2*n],t[2*n+1]));return i}_pointArrayToIndices(t){const e=[];for(const i of t)e.push(this._vertexToIndex(i.x,i.y));return e}}function bl(t,e,i,n=!0){return new wl(i,e).subdividePolygonInternal(t,n)}function xl(t,e,n=!1){if(!t||t.length<1)return[];if(t.length<2)return[];const s=t[0],r=t[t.length-1],o=n&&(s.x!==r.x||s.y!==r.y);if(e<2)return o?[...t,t[0]]:[...t];const a=Math.floor(P/e),h=[];h.push(new i(t[0].x,t[0].y));const l=t.length,c=o?l:l-1;for(let e=0;e<c;e++){const n=t[e],s=e<l-1?t[e+1]:t[0],r=n.x,o=n.y,c=s.x,u=s.y,f=r!==c,d=o!==u;if(!f&&!d)continue;const p=c-r,m=u-o,_=Math.abs(p),g=Math.abs(m);let v=r,y=o;for(;;){const t=p>0?(Math.floor(v/a)+1)*a:(Math.ceil(v/a)-1)*a,e=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(v-t),s=Math.abs(y-e),r=Math.abs(v-c),o=Math.abs(y-u),l=f?n/_:Number.POSITIVE_INFINITY,w=d?s/g:Number.POSITIVE_INFINITY;if((r<=n||!f)&&(o<=s||!d))break;if(l<w&&f||!d){v=t,y+=m*l;const e=new i(v,Math.round(y));h[h.length-1].x===e.x&&h[h.length-1].y===e.y||h.push(e)}else{v+=p*w,y=e;const t=new i(Math.round(v),y);h[h.length-1].x===t.x&&h[h.length-1].y===t.y||h.push(t)}}const w=new i(c,u);h[h.length-1].x===w.x&&h[h.length-1].y===w.y||h.push(w)}return h}function Ml(t,e,i){if(0===e.length)throw new Error("Subdivision vertex ring is empty.");let n=0,s=t[2*e[0]];for(let i=1;i<e.length;i++){const r=t[2*e[i]];r<s&&(s=r,n=i)}const r=e.length;let o=n,a=(o+1)%r;for(;;){const n=o-1>=0?o-1:r-1,s=(a+1)%r,h=t[2*e[n]],l=t[2*e[s]],c=t[2*e[o]],u=t[2*e[o]+1],f=t[2*e[a]+1];let d=!1;if(h<l)d=!0;else if(h>l)d=!1;else{const i=f-u,r=-(t[2*e[a]]-c),o=u<f?1:-1;((h-c)*i+(t[2*e[n]+1]-u)*r)*o>((l-c)*i+(t[2*e[s]+1]-u)*r)*o&&(d=!0)}if(d){const t=e[n],s=e[o],h=e[a];t!==s&&t!==h&&s!==h&&i.push(h,s,t),o--,o<0&&(o=r-1)}else{const t=e[s],n=e[o],h=e[a];t!==n&&t!==h&&n!==h&&i.push(h,n,t),a++,a>=r&&(a=0)}if(n===s)break}}function Sl(t,e,i,n,s,r,o,a,h){const l=s.length/2,c=o&&a&&h;if(l<ha.MAX_VERTEX_ARRAY_LENGTH){const u=e.prepareSegment(l,i,n),f=u.vertexLength;for(let t=0;t<r.length;t+=3)n.emplaceBack(f+r[t],f+r[t+1],f+r[t+2]);let d,p;u.vertexLength+=l,u.primitiveLength+=r.length/3,c&&(p=o.prepareSegment(l,i,a),d=p.vertexLength,p.vertexLength+=l);for(let e=0;e<s.length;e+=2)t(s[e],s[e+1]);if(c)for(const t of h){for(let e=1;e<t.length;e+=2)a.emplaceBack(d+t[e-1],d+t[e]);p.primitiveLength+=t.length/2}}else!function(t,e,i,n,s,r){const o=[];for(let t=0;t<n.length/2;t++)o.push(-1);const a={count:0};let h=0,l=t.getOrCreateLatestSegment(e,i),c=l.vertexLength;for(let u=2;u<s.length;u+=3){const f=s[u-2],d=s[u-1],p=s[u];let m=o[f]<h,_=o[d]<h,g=o[p]<h;l.vertexLength+((m?1:0)+(_?1:0)+(g?1:0))>ha.MAX_VERTEX_ARRAY_LENGTH&&(l=t.createNewSegment(e,i),h=a.count,m=!0,_=!0,g=!0,c=0);const v=zl(o,n,r,a,f,m,l),y=zl(o,n,r,a,d,_,l),w=zl(o,n,r,a,p,g,l);i.emplaceBack(c+v-h,c+y-h,c+w-h),l.primitiveLength++}}(e,i,n,s,r,t),c&&function(t,e,i,n,s,r){const o=[];for(let t=0;t<n.length/2;t++)o.push(-1);const a={count:0};let h=0,l=t.getOrCreateLatestSegment(e,i),c=l.vertexLength;for(const u of s)for(let s=1;s<u.length;s+=2){const f=u[s-1],d=u[s];let p=o[f]<h,m=o[d]<h;l.vertexLength+((p?1:0)+(m?1:0))>ha.MAX_VERTEX_ARRAY_LENGTH&&(l=t.createNewSegment(e,i),h=a.count,p=!0,m=!0,c=0);const _=zl(o,n,r,a,f,p,l),g=zl(o,n,r,a,d,m,l);i.emplaceBack(c+_-h,c+g-h),l.primitiveLength++}}(o,i,a,s,h,t),e.forceNewSegmentOnNextPrepare(),null==o||o.forceNewSegmentOnNextPrepare()}function zl(t,e,i,n,s,r,o){if(r){const r=n.count;return i(e[2*s],e[2*s+1]),t[s]=n.count,n.count++,o.vertexLength++,r}return t[s]}class Tl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Wo,this.indexArray=new sa,this.indexArray2=new ra,this.programConfigurations=new Ra(t.layers,t.zoom),this.segments=new ha,this.segments2=new ha,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Gh("fill",this.layers,e);const n=this.layers[0].layout.get("fill-sort-key"),s=!n.isConstant(),r=[];for(const{feature:o,id:a,index:h,sourceLayerIndex:l}of t){const t=this.layers[0]._featureFilter.needGeometry,c=Va(o,t);if(!this.layers[0]._featureFilter.filter(new kr(this.zoom),c,i))continue;const u=s?n.evaluate(c,{},i,e.availableImages):void 0,f={id:a,properties:o.properties,type:o.type,sourceLayerIndex:l,index:h,geometry:t?c.geometry:Ga(o),patterns:{},sortKey:u};r.push(f)}s&&r.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of r){const{geometry:s,index:r,sourceLayerIndex:o}=n;if(this.hasDependencies){const t=Vh("fill",this.layers,n,{zoom:this.zoom},e);this.patternFeatures.push(t)}else this.addFeature(n,s,r,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[r].feature,s,r,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}addFeatures(t,e,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,i,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Uh),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,e,i,n,s,r){for(const t of en(e,500)){const e=bl(t,n,r.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;Sl(((t,e)=>{i.emplaceBack(t,e)}),this.segments,this.layoutVertexArray,this.indexArray,e.verticesFlattened,e.indicesTriangles,this.segments2,this.indexArray2,e.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,canonical:n})}}let El,Al;dr("FillBucket",Tl,{omit:["layers","patternFeatures"]});var Pl={get paint(){return Al=Al||new Xr({"fill-antialias":new qr(bt.paint_fill["fill-antialias"]),"fill-opacity":new Zr(bt.paint_fill["fill-opacity"]),"fill-color":new Zr(bt.paint_fill["fill-color"]),"fill-outline-color":new Zr(bt.paint_fill["fill-outline-color"]),"fill-translate":new qr(bt.paint_fill["fill-translate"]),"fill-translate-anchor":new qr(bt.paint_fill["fill-translate-anchor"]),"fill-pattern":new Wr(bt.paint_fill["fill-pattern"])})},get layout(){return El=El||new Xr({"fill-sort-key":new Zr(bt.layout_fill["fill-sort-key"])})}};class Cl extends Qr{constructor(t,e){super(t,Pl,e)}recalculate(t,e){super.recalculate(t,e);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(t){return new Tl(t)}queryRadius(){return oh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:n}){return Xa(ah(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),e)}isTileClipped(){return!0}}const Dl=oo([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),Fl=oo([{name:"a_centroid",components:2,type:"Int16"}],4),{members:Il}=Dl;class kl{constructor(t,e,i,n,s){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=n,this._values=s,t.readFields($l,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos,n=[];let s,r=1,o=0,a=0,h=0;for(;t.pos<e;){if(o<=0){const e=t.readVarint();r=7&e,o=e>>3}if(o--,1===r||2===r)a+=t.readSVarint(),h+=t.readSVarint(),1===r&&(s&&n.push(s),s=[]),s&&s.push(new i(a,h));else{if(7!==r)throw new Error(`unknown command ${r}`);s&&s.push(s[0].clone())}}return s&&n.push(s),n}bbox(){const t=this._pbf;t.pos=this._geometry;const e=t.readVarint()+t.pos;let i=1,n=0,s=0,r=0,o=1/0,a=-1/0,h=1/0,l=-1/0;for(;t.pos<e;){if(n<=0){const e=t.readVarint();i=7&e,n=e>>3}if(n--,1===i||2===i)s+=t.readSVarint(),r+=t.readSVarint(),s<o&&(o=s),s>a&&(a=s),r<h&&(h=r),r>l&&(l=r);else if(7!==i)throw new Error(`unknown command ${i}`)}return[o,h,a,l]}toGeoJSON(t,e,i){const n=this.extent*Math.pow(2,i),s=this.extent*t,r=this.extent*e,o=this.loadGeometry();function a(t){return[360*(t.x+s)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+r)/n)*Math.PI))-90]}function h(t){return t.map(a)}let l;if(1===this.type){const t=[];for(const e of o)t.push(e[0]);const e=h(t);l=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e}}else if(2===this.type){const t=o.map(h);l=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw new Error("unknown feature type");{const t=Ol(o),e=[];for(const i of t)e.push(i.map(h));l=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}}const c={type:"Feature",geometry:l,properties:this.properties};return null!=this.id&&(c.id=this.id),c}}function $l(t,e,i){1===t?e.id=i.readVarint():2===t?function(t,e){const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=e._keys[t.readVarint()],n=e._values[t.readVarint()];e.properties[i]=n}}(i,e):3===t?e.type=i.readVarint():4===t&&(e._geometry=i.pos)}function Ol(t){const e=t.length;if(e<=1)return[t];const i=[];let n,s;for(let r=0;r<e;r++){const e=jl(t[r]);0!==e&&(void 0===s&&(s=e<0),s===e<0?(n&&i.push(n),n=[t[r]]):n&&n.push(t[r]))}return n&&i.push(n),i}function jl(t){let e=0;for(let i,n,s=0,r=t.length,o=r-1;s<r;o=s++)i=t[s],n=t[o],e+=(n.x-i.x)*(i.y+n.y);return e}kl.types=["Unknown","Point","LineString","Polygon"];class Rl{constructor(t,e){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(Ll,this,e),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];const e=this._pbf.readVarint()+this._pbf.pos;return new kl(this._pbf,e,this.extent,this._keys,this._values)}}function Ll(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;const i=t.readVarint()+t.pos;for(;t.pos<i;){const i=t.readVarint()>>3;e=1===i?t.readString():2===i?t.readFloat():3===i?t.readDouble():4===i?t.readVarint64():5===i?t.readVarint():6===i?t.readSVarint():7===i?t.readBoolean():null}if(null==e)throw new Error("unknown feature value");return e}(i))}class Bl{constructor(t,e){this.layers=t.readFields(Nl,{},e)}}function Nl(t,e,i){if(3===t){const t=new Rl(i,i.readVarint()+i.pos);t.length&&(e[t.name]=t)}}const Ul=Math.pow(2,13);function Gl(t,e,i,n,s,r,o,a){t.emplaceBack(e,i,2*Math.floor(n*Ul)+o,s*Ul*2,r*Ul*2,Math.round(a))}class Vl{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.layoutVertexArray=new Ho,this.centroidVertexArray=new qo,this.indexArray=new sa,this.programConfigurations=new Ra(t.layers,t.zoom),this.segments=new ha,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasDependencies=Gh("fill-extrusion",this.layers,e);for(const{feature:n,id:s,index:r,sourceLayerIndex:o}of t){const t=this.layers[0]._featureFilter.needGeometry,a=Va(n,t);if(!this.layers[0]._featureFilter.filter(new kr(this.zoom),a,i))continue;const h={id:s,sourceLayerIndex:o,index:r,geometry:t?a.geometry:Ga(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push(Vh("fill-extrusion",this.layers,h,{zoom:this.zoom},e)):this.addFeature(h,h.geometry,r,i,{},e.subdivisionGranularity),e.featureIndex.insert(n,h.geometry,r,o,this.index,!0)}}addFeatures(t,e,i){for(const n of this.features){const{geometry:s}=n;this.addFeature(n,s,n.index,e,i,t.subdivisionGranularity)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Il),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,Fl.members,!0),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(t,e,i,n,s,r){for(const i of en(e,500)){const e={x:0,y:0,sampleCount:0},s=this.layoutVertexArray.length;this.processPolygon(e,n,t,i,r);const o=this.layoutVertexArray.length-s,a=Math.floor(e.x/e.sampleCount),h=Math.floor(e.y/e.sampleCount);for(let t=0;t<o;t++)this.centroidVertexArray.emplaceBack(a,h)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,canonical:n})}processPolygon(t,e,i,n,s){if(n.length<1)return;if(Wl(n[0]))return;for(const e of n)0!==e.length&&ql(t,e);const r={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=s.fill.getGranularityForZoomLevel(e.z),a="Polygon"===kl.types[i.type];for(const t of n){if(0===t.length)continue;if(Wl(t))continue;const e=xl(t,o,a);this._generateSideFaces(e,r)}if(!a)return;const h=bl(n,e,o,!1),l=this.layoutVertexArray;Sl(((t,e)=>{Gl(l,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,h.verticesFlattened,h.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let n=1;n<t.length;n++){const s=t[n],r=t[n-1];if(Zl(s,r))continue;e.segment.vertexLength+4>ha.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const o=s.sub(r)._perp()._unit(),a=r.dist(s);i+a>32768&&(i=0),Gl(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),Gl(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i),i+=a,Gl(this.layoutVertexArray,r.x,r.y,o.x,o.y,0,0,i),Gl(this.layoutVertexArray,r.x,r.y,o.x,o.y,0,1,i);const h=e.segment.vertexLength;this.indexArray.emplaceBack(h,h+2,h+1),this.indexArray.emplaceBack(h+1,h+2,h+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}}function ql(t,e){for(let i=0;i<e.length;i++){const n=e[i];i===e.length-1&&e[0].x===n.x&&e[0].y===n.y||(t.x+=n.x,t.y+=n.y,t.sampleCount++)}}function Zl(t,e){return t.x===e.x&&(t.x<0||t.x>P)||t.y===e.y&&(t.y<0||t.y>P)}function Wl(t){return t.every((t=>t.x<0))||t.every((t=>t.x>P))||t.every((t=>t.y<0))||t.every((t=>t.y>P))}let Hl;dr("FillExtrusionBucket",Vl,{omit:["layers","features"]});var Yl={get paint(){return Hl=Hl||new Xr({"fill-extrusion-opacity":new qr(bt["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Zr(bt["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new qr(bt["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new qr(bt["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Wr(bt["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Zr(bt["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Zr(bt["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new qr(bt["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Xl extends Qr{constructor(t,e){super(t,Yl,e)}createBucket(t){return new Vl(t)}queryRadius(){return oh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:n,geometry:s,transform:r,pixelsToTileUnits:o,pixelPosMatrix:a}){const h=ah(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-r.bearingInRadians,o),l=this.paint.get("fill-extrusion-height").evaluate(e,n),c=this.paint.get("fill-extrusion-base").evaluate(e,n),u=function(t,e){const n=[];for(const s of t){const t=[s.x,s.y,0,1];S(t,t,e),n.push(new i(t[0]/t[3],t[1]/t[3]))}return n}(h,a),f=function(t,e,n,s){const r=[],o=[],a=s[8]*e,h=s[9]*e,l=s[10]*e,c=s[11]*e,u=s[8]*n,f=s[9]*n,d=s[10]*n,p=s[11]*n;for(const e of t){const t=[],n=[];for(const r of e){const e=r.x,o=r.y,m=s[0]*e+s[4]*o+s[12],_=s[1]*e+s[5]*o+s[13],g=s[2]*e+s[6]*o+s[14],v=s[3]*e+s[7]*o+s[15],y=g+l,w=v+c,b=m+u,x=_+f,M=g+d,S=v+p,z=new i((m+a)/w,(_+h)/w);z.z=y/w,t.push(z);const T=new i(b/S,x/S);T.z=M/S,n.push(T)}r.push(t),o.push(n)}return[r,o]}(s,c,l,a);return function(t,e,i){let n=1/0;Xa(i,e)&&(n=Kl(i,e[0]));for(let s=0;s<e.length;s++){const r=e[s],o=t[s];for(let t=0;t<r.length-1;t++){const e=r[t],s=[e,r[t+1],o[t+1],o[t],e];Ha(i,s)&&(n=Math.min(n,Kl(i,s)))}}return n!==1/0&&n}(f[0],f[1],u)}}function Jl(t,e){return t.x*e.x+t.y*e.y}function Kl(t,e){if(1===t.length){let i=0;const n=e[i++];let s;for(;!s||n.equals(s);)if(s=e[i++],!s)return 1/0;for(;i<e.length;i++){const r=e[i],o=t[0],a=s.sub(n),h=r.sub(n),l=o.sub(n),c=Jl(a,a),u=Jl(a,h),f=Jl(h,h),d=Jl(l,a),p=Jl(l,h),m=c*f-u*u,_=(f*d-u*p)/m,g=(c*p-u*d)/m,v=n.z*(1-_-g)+s.z*_+r.z*g;if(isFinite(v))return v}return 1/0}{let t=1/0;for(const i of e)t=Math.min(t,i.z);return t}}const Ql=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class tc{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[e,i]=new Uint8Array(t,0,2);if(219!==e)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const s=Ql[15&i];if(!s)throw new Error("Unrecognized array type.");const[r]=new Uint16Array(t,2,1),[o]=new Uint32Array(t,4,1);return new tc(o,r,s,t)}constructor(t,e=64,i=Float64Array,n){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const s=Ql.indexOf(this.ArrayType),r=2*t*this.ArrayType.BYTES_PER_ELEMENT,o=t*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-o%8)%8;if(s<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+r+o+a),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+o+a,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+s]),new Uint16Array(this.data,2,1)[0]=e,new Uint32Array(this.data,4,1)[0]=t)}add(t,e){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return ec(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,n){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:s,coords:r,nodeSize:o}=this,a=[0,s.length-1,0],h=[];for(;a.length;){const l=a.pop()||0,c=a.pop()||0,u=a.pop()||0;if(c-u<=o){for(let o=u;o<=c;o++){const a=r[2*o],l=r[2*o+1];a>=t&&a<=i&&l>=e&&l<=n&&h.push(s[o])}continue}const f=u+c>>1,d=r[2*f],p=r[2*f+1];d>=t&&d<=i&&p>=e&&p<=n&&h.push(s[f]),(0===l?t<=d:e<=p)&&(a.push(u),a.push(f-1),a.push(1-l)),(0===l?i>=d:n>=p)&&(a.push(f+1),a.push(c),a.push(1-l))}return h}within(t,e,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:s,nodeSize:r}=this,o=[0,n.length-1,0],a=[],h=i*i;for(;o.length;){const l=o.pop()||0,c=o.pop()||0,u=o.pop()||0;if(c-u<=r){for(let i=u;i<=c;i++)rc(s[2*i],s[2*i+1],t,e)<=h&&a.push(n[i]);continue}const f=u+c>>1,d=s[2*f],p=s[2*f+1];rc(d,p,t,e)<=h&&a.push(n[f]),(0===l?t-i<=d:e-i<=p)&&(o.push(u),o.push(f-1),o.push(1-l)),(0===l?t+i>=d:e+i>=p)&&(o.push(f+1),o.push(c),o.push(1-l))}return a}}function ec(t,e,i,n,s,r){if(s-n<=i)return;const o=n+s>>1;ic(t,e,o,n,s,r),ec(t,e,i,n,o-1,1-r),ec(t,e,i,o+1,s,1-r)}function ic(t,e,i,n,s,r){for(;s>n;){if(s-n>600){const o=s-n+1,a=i-n+1,h=Math.log(o),l=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*l*(o-l)/o)*(a-o/2<0?-1:1);ic(t,e,i,Math.max(n,Math.floor(i-a*l/o+c)),Math.min(s,Math.floor(i+(o-a)*l/o+c)),r)}const o=e[2*i+r];let a=n,h=s;for(nc(t,e,n,i),e[2*s+r]>o&&nc(t,e,n,s);a<h;){for(nc(t,e,a,h),a++,h--;e[2*a+r]<o;)a++;for(;e[2*h+r]>o;)h--}e[2*n+r]===o?nc(t,e,n,h):(h++,nc(t,e,h,s)),h<=i&&(n=h+1),i<=h&&(s=h-1)}}function nc(t,e,i,n){sc(t,i,n),sc(e,2*i,2*n),sc(e,2*i+1,2*n+1)}function sc(t,e,i){const n=t[e];t[e]=t[i],t[i]=n}function rc(t,e,i,n){const s=t-i,r=e-n;return s*s+r*r}function oc(t,e,i,n){let s=n;const r=e+(i-e>>1);let o,a=i-e;const h=t[e],l=t[e+1],c=t[i],u=t[i+1];for(let n=e+3;n<i;n+=3){const e=ac(t[n],t[n+1],h,l,c,u);if(e>s)o=n,s=e;else if(e===s){const t=Math.abs(n-r);t<a&&(o=n,a=t)}}s>n&&(o-e>3&&oc(t,e,o,n),t[o+2]=s,i-o>3&&oc(t,o,i,n))}function ac(t,e,i,n,s,r){let o=s-i,a=r-n;if(0!==o||0!==a){const h=((t-i)*o+(e-n)*a)/(o*o+a*a);h>1?(i=s,n=r):h>0&&(i+=o*h,n+=a*h)}return o=t-i,a=e-n,o*o+a*a}function hc(t,e,i,n){const s={type:e,geom:i},r={id:null==t?null:t,type:s.type,geometry:s.geom,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};switch(s.type){case"Point":case"MultiPoint":cc(r,s.geom);break;case"LineString":cc(r,s.geom.points);break;case"Polygon":cc(r,s.geom[0].points);break;case"MultiLineString":for(const t of s.geom)cc(r,t.points);break;case"MultiPolygon":for(const t of s.geom)cc(r,t[0].points)}return r}function lc(t){t.points.length>64&&(t.points=new Float64Array(t.points))}function cc(t,e){for(let i=0;i<e.length;i+=3)t.minX=Math.min(t.minX,e[i]),t.minY=Math.min(t.minY,e[i+1]),t.maxX=Math.max(t.maxX,e[i]),t.maxY=Math.max(t.maxY,e[i+1])}function uc(t,e){const i=[];switch(t.type){case"FeatureCollection":for(let n=0;n<t.features.length;n++)fc(i,t.features[n],e,n);break;case"Feature":fc(i,t,e);break;default:fc(i,{geometry:t,properties:void 0},e)}return i}function fc(t,e,i,n){if(!e.geometry)return;if("GeometryCollection"===e.geometry.type)return void function(t,e,i,n,s){for(const r of i.geometries)fc(t,{id:e.id,geometry:r,properties:e.properties},n,s)}(t,e,e.geometry,i,n);const s=e.geometry.coordinates;if(!s?.length)return;const r=function(t,e,i){return e.promoteId?t.properties?.[e.promoteId]:e.generateId?i||0:t.id}(e,i,n),o=Math.pow(i.tolerance/((1<<i.maxZoom)*i.extent),2);switch(e.geometry.type){case"Point":return void function(t,e,i,n){const s=[];s.push(mc(i.coordinates[0]),_c(i.coordinates[1]),0),t.push(hc(e,"Point",s,n))}(t,r,e.geometry,e.properties);case"MultiPoint":return void function(t,e,i,n){const s=[];for(const t of i.coordinates)s.push(mc(t[0]),_c(t[1]),0);t.push(hc(e,"MultiPoint",s,n))}(t,r,e.geometry,e.properties);case"LineString":return void function(t,e,i,n,s){const r={points:[]};dc(i.coordinates,r,n,!1),t.push(hc(e,"LineString",r,s))}(t,r,e.geometry,o,e.properties);case"MultiLineString":return void function(t,e,i,n,s,r){if(s.lineMetrics)for(const s of i.coordinates){const i={points:[]};dc(s,i,n,!1),t.push(hc(e,"LineString",i,r))}else{const s=[];pc(i.coordinates,s,n,!1),t.push(hc(e,"MultiLineString",s,r))}}(t,r,e.geometry,o,i,e.properties);case"Polygon":return void function(t,e,i,n,s){const r=[];pc(i.coordinates,r,n,!0),t.push(hc(e,"Polygon",r,s))}(t,r,e.geometry,o,e.properties);case"MultiPolygon":return void function(t,e,i,n,s){const r=[];for(const t of i.coordinates){const e=[];pc(t,e,n,!0),r.push(e)}t.push(hc(e,"MultiPolygon",r,s))}(t,r,e.geometry,o,e.properties);default:throw new Error("Input data is not a valid GeoJSON object.")}}function dc(t,e,i,n){let s,r,o=0;for(let i=0;i<t.length;i++){const a=mc(t[i][0]),h=_c(t[i][1]);e.points.push(a,h,0),i>0&&(o+=n?(s*h-a*r)/2:Math.sqrt(Math.pow(a-s,2)+Math.pow(h-r,2))),s=a,r=h}const a=e.points.length-3;e.points[2]=1,i>0&&oc(e.points,0,a,i),e.points[a+2]=1,lc(e),e.size=Math.abs(o),e.start=0,e.end=e.size}function pc(t,e,i,n){for(let s=0;s<t.length;s++){const r={points:[]};dc(t[s],r,i,n),e.push(r)}}function mc(t){return t/360+.5}function _c(t){const e=Math.sin(t*Math.PI/180),i=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return i<0?0:i>1?1:i}function gc(t){const e={type:"Feature",geometry:vc(t),properties:t.tags};return null!=t.id&&(e.id=t.id),e}function vc(t){const{type:e,geometry:i}=t;switch(e){case"Point":return{type:e,coordinates:wc(i[0],i[1])};case"MultiPoint":return{type:e,coordinates:yc(i)};case"LineString":return{type:e,coordinates:yc(i.points)};case"MultiLineString":case"Polygon":return{type:e,coordinates:i.map((t=>yc(t.points)))};case"MultiPolygon":return{type:e,coordinates:i.map((t=>t.map((t=>yc(t.points)))))}}}function yc(t){const e=[];for(let i=0;i<t.length;i+=3)e.push(wc(t[i],t[i+1]));return e}function wc(t,e){return[bc(t),xc(e)]}function bc(t){return 360*(t-.5)}function xc(t){const e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}var Mc;function Sc(t,e,i,n,s,r,o,a){if(n/=e,r>=(i/=e)&&o<n)return t;if(o<i||r>=n)return null;const h=[];for(const e of t){const t=s===Mc.X?e.minX:e.minY,r=s===Mc.X?e.maxX:e.maxY;if(t>=i&&r<n)h.push(e);else if(!(r<i||t>=n))switch(e.type){case"Point":case"MultiPoint":zc(e,h,i,n,s);continue;case"LineString":Tc(e,h,i,n,s,a);continue;case"MultiLineString":Ec(e,h,i,n,s);continue;case"Polygon":Ac(e,h,i,n,s);continue;case"MultiPolygon":Pc(e,h,i,n,s);continue}}return h.length?h:null}function zc(t,e,i,n,s){const r=[];(function(t,e,i,n,s){for(let r=0;r<t.length;r+=3){const o=t[r+s];o>=i&&o<=n&&Ic(e,t[r],t[r+1],t[r+2])}})(t.geometry,r,i,n,s),r.length&&e.push(hc(t.id,3===r.length?"Point":"MultiPoint",r,t.tags))}function Tc(t,e,i,n,s,r){const o=[];if(Cc(t.geometry,o,i,n,s,!1,r.lineMetrics),o.length)if(r.lineMetrics)for(const i of o)e.push(hc(t.id,"LineString",i,t.tags));else e.push(o.length>1?hc(t.id,"MultiLineString",o,t.tags):hc(t.id,"LineString",o[0],t.tags))}function Ec(t,e,i,n,s){const r=[];Fc(t.geometry,r,i,n,s,!1),r.length&&e.push(1!==r.length?hc(t.id,"MultiLineString",r,t.tags):hc(t.id,"LineString",r[0],t.tags))}function Ac(t,e,i,n,s){const r=[];Fc(t.geometry,r,i,n,s,!0),r.length&&e.push(hc(t.id,"Polygon",r,t.tags))}function Pc(t,e,i,n,s){const r=[];for(const e of t.geometry){const t=[];Fc(e,t,i,n,s,!0),t.length&&r.push(t)}r.length&&e.push(hc(t.id,"MultiPolygon",r,t.tags))}function Cc(t,e,i,n,s,r,o){let a=Dc(t);const h=s===Mc.X?kc:$c;let l,c,u=t.start;for(let f=0;f<t.points.length-3;f+=3){const d=t.points[f],p=t.points[f+1],m=t.points[f+2],_=t.points[f+3],g=t.points[f+4],v=s===Mc.X?d:p,y=s===Mc.X?_:g;let w=!1;o&&(l=Math.sqrt(Math.pow(d-_,2)+Math.pow(p-g,2))),v<i?y>i&&(c=h(a,d,p,_,g,i),o&&(a.start=u+l*c)):v>n?y<n&&(c=h(a,d,p,_,g,n),o&&(a.start=u+l*c)):Ic(a.points,d,p,m),y<i&&v>=i&&(c=h(a,d,p,_,g,i),w=!0),y>n&&v<=n&&(c=h(a,d,p,_,g,n),w=!0),!r&&w&&(o&&(a.end=u+l*c),e.push(a),a=Dc(t)),o&&(u+=l)}let f=t.points.length-3;const d=t.points[f],p=t.points[f+1],m=s===Mc.X?d:p;m>=i&&m<=n&&Ic(a.points,d,p,t.points[f+2]),f=a.points.length-3,r&&f>=3&&(a.points[f]!==a.points[0]||a.points[f+1]!==a.points[1])&&Ic(a.points,a.points[0],a.points[1],a.points[2]),a.points.length&&(lc(a),e.push(a))}function Dc(t){return{points:[],size:t.size,start:t.start,end:t.end}}function Fc(t,e,i,n,s,r){for(const o of t)Cc(o,e,i,n,s,r,!1)}function Ic(t,e,i,n){t.push(e,i,n)}function kc(t,e,i,n,s,r){const o=(r-e)/(n-e);return Ic(t.points,r,i+(s-i)*o,1),o}function $c(t,e,i,n,s,r){const o=(r-i)/(s-i);return Ic(t.points,e+(n-e)*o,r,1),o}function Oc(t,e){const i=e.buffer/e.extent;let n=t;const s=Sc(t,1,-1-i,i,Mc.X,-1,2,e),r=Sc(t,1,1-i,2+i,Mc.X,-1,2,e);return s||r?(n=Sc(t,1,-i,1+i,Mc.X,-1,2,e)||[],s&&(n=jc(s,1).concat(n)),r&&(n=n.concat(jc(r,-1))),n):n}function jc(t,e){const i=[];for(const n of t)switch(n.type){case"Point":case"MultiPoint":{const t=Rc(n.geometry,e);i.push(hc(n.id,n.type,t,n.tags));continue}case"LineString":{const t=Lc(n.geometry,e);i.push(hc(n.id,n.type,t,n.tags));continue}case"MultiLineString":case"Polygon":{const t=[];for(const i of n.geometry)t.push(Lc(i,e));i.push(hc(n.id,n.type,t,n.tags));continue}case"MultiPolygon":{const t=[];for(const i of n.geometry){const n=[];for(const t of i)n.push(Lc(t,e));t.push(n)}i.push(hc(n.id,n.type,t,n.tags));continue}}return i}function Rc(t,e){const i=[];for(let n=0;n<t.length;n+=3)i.push(t[n]+e,t[n+1],t[n+2]);return i}function Lc(t,e){const i={points:[],size:t.size};void 0!==t.start&&(i.start=t.start,i.end=t.end);for(let n=0;n<t.points.length;n+=3)i.points.push(t.points[n]+e,t.points[n+1],t.points[n+2]);return lc(i),i}function Bc(t,e,i){const n=!!e.newGeometry,s=e.removeAllProperties||e.removeProperties?.length>0||e.addOrUpdateProperties?.length>0;if(n){const n=t[0];let r=uc({type:"FeatureCollection",features:[{type:"Feature",id:n.id,geometry:e.newGeometry,properties:s?Nc(n.tags,e):n.tags}]},i);return r=Oc(r,i),r}if(s){const i=[];for(const n of t){const t={...n};t.tags=Nc(t.tags,e),i.push(t)}return i}return t}function Nc(t,e){if(e.removeAllProperties)return{};const i={...t||{}};if(e.removeProperties)for(const t of e.removeProperties)delete i[t];if(e.addOrUpdateProperties)for(const{key:t,value:n}of e.addOrUpdateProperties)i[t]=n;return i}!function(t){t[t.X=0]="X",t[t.Y=1]="Y"}(Mc||(Mc={}));const Uc={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:t=>t};class Gc{constructor(t){this.options=Object.assign(Object.create(Uc),t),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[],this.points=[]}load(t){const e=[];for(const i of t){if(!i.geometry)continue;const[t,n]=i.geometry.coordinates,[s,r]=[mc(t),_c(n)];e.push({id:i.id,type:"Point",geometry:[s,r],tags:i.properties})}this.createIndex(e)}initialize(t){const e=[];for(const i of t)"Point"===i.type&&e.push(i);this.createIndex(e)}updateIndex(t,e,i){this.options=Object.assign(Object.create(Uc),i.clusterOptions),this.initialize(t)}createIndex(t){const{log:e,minZoom:i,maxZoom:n}=this.options;e&&console.time("total time");const s=`prepare ${t.length} points`;e&&console.time(s),this.points=t;const r=[];for(let e=0;e<t.length;e++){const i=t[e];if(!i?.geometry)continue;let[n,s]=i.geometry;n=Math.fround(n),s=Math.fround(s),r.push(n,s,1/0,e,-1,1),this.options.reduce&&r.push(0)}let o=this.trees[n+1]=this.createTree(r);e&&console.timeEnd(s);for(let t=n;t>=i;t--){const i=Date.now();o=this.trees[t]=this.createTree(this.cluster(o,t)),e&&console.log("z%d: %d clusters in %dms",t,o.numItems,Date.now()-i)}e&&console.timeEnd("total time")}getClusters(t,e){return this.getClustersInternal(t,e).map((t=>gc(t)))}getClustersInternal(t,e){let i=((t[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,t[1]));let s=180===t[2]?180:((t[2]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)i=-180,s=180;else if(i>s){const t=this.getClustersInternal([i,n,180,r],e),o=this.getClustersInternal([-180,n,s,r],e);return t.concat(o)}const o=this.trees[this.limitZoom(e)],a=o.range(mc(i),_c(r),mc(s),_c(n)),h=o.flatData,l=[];for(const t of a){const e=this.stride*t;l.push(h[e+5]>1?Vc(h,e,this.clusterProps):this.points[h[e+3]])}return l}getChildren(t){const e=this.getOriginId(t),i=this.getOriginZoom(t),n=new Error("No cluster with the specified id: "+t),s=this.trees[i];if(!s)throw n;const r=s.flatData;if(e*this.stride>=r.length)throw n;const o=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=s.within(r[e*this.stride],r[e*this.stride+1],o),h=[];for(const e of a){const i=e*this.stride;r[i+4]===t&&h.push(r[i+5]>1?qc(r,i,this.clusterProps):gc(this.points[r[i+3]]))}if(0===h.length)throw n;return h}getLeaves(t,e,i){const n=[];return this.appendLeaves(n,t,e=e||10,i=i||0,0),n}getTile(t,e,i){const n=this.trees[this.limitZoom(t)];if(!n)return null;const s=Math.pow(2,t),{extent:r,radius:o}=this.options,a=o/r,h=(i-a)/s,l=(i+1+a)/s,c={transformed:!0,features:[],source:null,x:e,y:i,z:t};return this.addTileFeatures(n.range((e-a)/s,h,(e+1+a)/s,l),n.flatData,e,i,s,c),0===e&&this.addTileFeatures(n.range(1-a/s,h,1,l),n.flatData,s,i,s,c),e===s-1&&this.addTileFeatures(n.range(0,h,a/s,l),n.flatData,-1,i,s,c),c}getClusterExpansionZoom(t){return this.getOriginZoom(t)}appendLeaves(t,e,i,n,s){const r=this.getChildren(e);for(const e of r){const r=e.properties;if(r?.cluster?s+r.point_count<=n?s+=r.point_count:s=this.appendLeaves(t,r.cluster_id,i,n,s):s<n?s++:t.push(e),t.length===i)break}return s}createTree(t){const e=new tc(t.length/this.stride|0,this.options.nodeSize,Float32Array);for(let i=0;i<t.length;i+=this.stride)e.add(t[i],t[i+1]);return e.finish(),e.flatData=t,e.data=null,e}addTileFeatures(t,e,i,n,s,r){for(const o of t){const t=o*this.stride,a=e[t+5]>1;let h,l,c;if(a)h=Zc(e,t,this.clusterProps),l=e[t],c=e[t+1];else{const i=this.points[e[t+3]];h=i.tags,[l,c]=i.geometry}const u={type:1,geometry:[[Math.round(this.options.extent*(l*s-i)),Math.round(this.options.extent*(c*s-n))]],tags:h};let f;f=a||this.options.generateId?e[t+3]:this.points[e[t+3]].id,void 0!==f&&(u.id=f),r.features.push(u)}}limitZoom(t){return Math.max(this.options.minZoom,Math.min(Math.floor(+t),this.options.maxZoom+1))}cluster(t,e){const{radius:i,extent:n,reduce:s,minPoints:r}=this.options,o=i/(n*Math.pow(2,e)),a=t.flatData,h=[],l=this.stride;for(let i=0;i<a.length;i+=l){if(a[i+2]<=e)continue;a[i+2]=e;const n=a[i],c=a[i+1],u=t.within(a[i],a[i+1],o),f=a[i+5];let d=f;for(const t of u){const i=t*l;a[i+2]>e&&(d+=a[i+5])}if(d>f&&d>=r){let t,r=n*f,o=c*f,p=-1;const m=(i/l<<5)+(e+1)+this.points.length;for(const n of u){const h=n*l;if(a[h+2]<=e)continue;a[h+2]=e;const c=a[h+5];r+=a[h]*c,o+=a[h+1]*c,a[h+4]=m,s&&(t||(t=this.map(a,i,!0),p=this.clusterProps.length,this.clusterProps.push(t)),s(t,this.map(a,h)))}a[i+4]=m,h.push(r/d,o/d,1/0,m,-1,d),s&&h.push(p)}else{for(let t=0;t<l;t++)h.push(a[i+t]);if(d>1)for(const t of u){const i=t*l;if(!(a[i+2]<=e)){a[i+2]=e;for(let t=0;t<l;t++)h.push(a[i+t])}}}}return h}getOriginId(t){return t-this.points.length>>5}getOriginZoom(t){return(t-this.points.length)%32}map(t,e,i){if(t[e+5]>1){const n=this.clusterProps[t[e+6]];return i?Object.assign({},n):n}const n=this.points[t[e+3]].tags,s=this.options.map(n);return i&&s===n?Object.assign({},s):s}}function Vc(t,e,i){return{id:t[e+3],type:"Point",tags:Zc(t,e,i),geometry:[t[e],t[e+1]]}}function qc(t,e,i){return{type:"Feature",id:t[e+3],properties:Zc(t,e,i),geometry:{type:"Point",coordinates:[bc(t[e]),xc(t[e+1])]}}}function Zc(t,e,i){const n=t[e+5],s=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,r=t[e+6],o=-1===r?{}:Object.assign({},i[r]);return Object.assign(o,{cluster:!0,cluster_id:t[e+3],point_count:n,point_count_abbreviated:s})}const Wc="geojsonvt_clip_start",Hc="geojsonvt_clip_end";function Yc(t,e,i,n,s){const r=e===s.maxZoom?0:s.tolerance/((1<<e)*s.extent),o={transformed:!1,features:[],source:null,x:i,y:n,z:e,minX:2,minY:1,maxX:-1,maxY:0,numPoints:0,numSimplified:0,numFeatures:t.length};for(const e of t)Xc(o,e,r,s);return o}function Xc(t,e,i,n){switch(t.minX=Math.min(t.minX,e.minX),t.minY=Math.min(t.minY,e.minY),t.maxX=Math.max(t.maxX,e.maxX),t.maxY=Math.max(t.maxY,e.maxY),e.type){case"Point":case"MultiPoint":return void function(t,e){const i=[];for(let n=0;n<e.geometry.length;n+=3)i.push(e.geometry[n],e.geometry[n+1]),t.numPoints++,t.numSimplified++;if(!i.length)return;const n={type:1,tags:e.tags||null,geometry:i};null!==e.id&&(n.id=e.id),t.features.push(n)}(t,e);case"LineString":return void function(t,e,i,n){const s=[];if(Jc(s,e.geometry,t,i,!1,!1),!s.length)return;let r=e.tags||null;if(n.lineMetrics){r={};for(const t in e.tags)r[t]=e.tags[t];r[Wc]=e.geometry.start/e.geometry.size,r[Hc]=e.geometry.end/e.geometry.size}const o={type:2,tags:r,geometry:s};null!==e.id&&(o.id=e.id),t.features.push(o)}(t,e,i,n);case"MultiLineString":case"Polygon":return void function(t,e,i){const n=[];for(let s=0;s<e.geometry.length;s++)Jc(n,e.geometry[s],t,i,"Polygon"===e.type,0===s);if(!n.length)return;const s={type:"Polygon"===e.type?3:2,tags:e.tags||null,geometry:n};null!==e.id&&(s.id=e.id),t.features.push(s)}(t,e,i);case"MultiPolygon":return void function(t,e,i){const n=[];for(let s=0;s<e.geometry.length;s++){const r=e.geometry[s];for(let e=0;e<r.length;e++)Jc(n,r[e],t,i,!0,0===e)}if(!n.length)return;const s={type:3,tags:e.tags||null,geometry:n};null!==e.id&&(s.id=e.id),t.features.push(s)}(t,e,i)}}function Jc(t,e,i,n,s,r){const o=n*n;if(n>0&&e.size<(s?o:n))return void(i.numPoints+=e.points.length/3);const a=[];for(let t=0;t<e.points.length;t+=3)(0===n||e.points[t+2]>o)&&(i.numSimplified++,a.push(e.points[t],e.points[t+1])),i.numPoints++;s&&function(t,e){let i=0;for(let e=0,n=t.length,s=n-2;e<n;s=e,e+=2)i+=(t[e]-t[s])*(t[e+1]+t[s+1]);if(i>0===e)for(let e=0,i=t.length;e<i/2;e+=2){const n=t[e],s=t[e+1];t[e]=t[i-2-e],t[e+1]=t[i-1-e],t[i-2-e]=n,t[i-1-e]=s}}(a,r),t.push(a)}function Kc(t,e){if(t.transformed)return t;const i=1<<t.z,n=t.x,s=t.y;for(const r of t.features)1===r.type?Qc(r,e,i,n,s):tu(r,e,i,n,s);return t.transformed=!0,t}function Qc(t,e,i,n,s){const r=t,o=t.geometry,a=[];for(let t=0;t<o.length;t+=2)a.push(eu(o[t],o[t+1],e,i,n,s));return r.geometry=a,r}function tu(t,e,i,n,s){const r=t,o=t.geometry,a=[];for(const t of o){const r=[];for(let o=0;o<t.length;o+=2)r.push(eu(t[o],t[o+1],e,i,n,s));a.push(r)}return r.geometry=a,r}function eu(t,e,i,n,s,r){return[Math.round(i*(t*n-s)),Math.round(i*(e*n-r))]}class iu{constructor(t){this.options=t,this.total=0,this.stats={},this.tiles={},this.tileCoords=[],this.stats={},this.total=0}initialize(t){this.splitTile(t,0,0,0),this.options.debug&&(t.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}updateIndex(t,e,i){i.debug>1&&(console.log("invalidating tiles"),console.time("invalidating")),this.invalidateTiles(e),i.debug>1&&console.timeEnd("invalidating");const[n,s,r]=[0,0,0],o=Yc(t,n,s,r,i);o.source=t;const a=nu(n,s,r);if(this.tiles[a]=o,this.tileCoords.push({z:n,x:s,y:r,id:a}),i.debug){const t=`z${n}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}}getClusterExpansionZoom(t){return null}getChildren(t){return null}getLeaves(t,e,i){return null}getTile(t,e,i){const{extent:n,debug:s}=this.options,r=1<<t,o=nu(t,e=e+r&r-1,i);if(this.tiles[o])return Kc(this.tiles[o],n);s>1&&console.log("drilling down to z%d-%d-%d",t,e,i);let a,h=t,l=e,c=i;for(;!a&&h>0;)h--,l>>=1,c>>=1,a=this.tiles[nu(h,l,c)];return a?.source?(s>1&&(console.log("found parent tile z%d-%d-%d",h,l,c),console.time("drilling down")),this.splitTile(a.source,h,l,c,t,e,i),s>1&&console.timeEnd("drilling down"),this.tiles[o]?Kc(this.tiles[o],n):null):null}splitTile(t,e,i,n,s,r,o){const a=[t,e,i,n],h=this.options,l=h.debug;for(;a.length;){n=a.pop(),i=a.pop(),e=a.pop(),t=a.pop();const c=1<<e,u=nu(e,i,n);let f=this.tiles[u];if(!f&&(l>1&&console.time("creation"),f=this.tiles[u]=Yc(t,e,i,n,h),this.tileCoords.push({z:e,x:i,y:n,id:u}),l)){l>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",e,i,n,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t=`z${e}`;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==s){if(e===h.indexMaxZoom||f.numPoints<=h.indexMaxPoints)continue}else{if(e===h.maxZoom||e===s)continue;if(null!=s){const t=s-e;if(i!==r>>t||n!==o>>t)continue}}if(f.source=null,!t.length)continue;l>1&&console.time("clipping");const d=.5*h.buffer/h.extent,p=.5-d,m=.5+d,_=1+d;let g=null,v=null,y=null,w=null;const b=Sc(t,c,i-d,i+m,Mc.X,f.minX,f.maxX,h),x=Sc(t,c,i+p,i+_,Mc.X,f.minX,f.maxX,h);b&&(g=Sc(b,c,n-d,n+m,Mc.Y,f.minY,f.maxY,h),v=Sc(b,c,n+p,n+_,Mc.Y,f.minY,f.maxY,h)),x&&(y=Sc(x,c,n-d,n+m,Mc.Y,f.minY,f.maxY,h),w=Sc(x,c,n+p,n+_,Mc.Y,f.minY,f.maxY,h)),l>1&&console.timeEnd("clipping"),a.push(g||[],e+1,2*i,2*n),a.push(v||[],e+1,2*i,2*n+1),a.push(y||[],e+1,2*i+1,2*n),a.push(w||[],e+1,2*i+1,2*n+1)}}invalidateTiles(t){if(!t.length)return;const e=this.options,{debug:i}=e;let n=1/0,s=-1/0,r=1/0,o=-1/0;for(const e of t)n=Math.min(n,e.minX),s=Math.max(s,e.maxX),r=Math.min(r,e.minY),o=Math.max(o,e.maxY);const a=e.buffer/e.extent,h=new Set;for(const e in this.tiles){const l=this.tiles[e],c=1<<l.z,u=(l.x-a)/c,f=(l.x+1+a)/c,d=(l.y-a)/c,p=(l.y+1+a)/c;if(s<u||n>=f||o<d||r>=p)continue;let m=!1;for(const e of t)if(e.maxX>=u&&e.minX<f&&e.maxY>=d&&e.minY<p){m=!0;break}if(m){if(i){i>1&&console.log("invalidate tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",l.z,l.x,l.y,l.numFeatures,l.numPoints,l.numSimplified);const t=`z${l.z}`;this.stats[t]=(this.stats[t]||0)-1,this.total--}delete this.tiles[e],h.add(e)}}h.size&&(this.tileCoords=this.tileCoords.filter((t=>!h.has(t.id))))}}function nu(t,e,i){return 32*((1<<t)*i+e)+t}const su={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,updateable:!1,cluster:!1,clusterOptions:Uc,debug:0},ru=oo([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4),{members:ou}=ru,au=oo([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]),{members:hu}=au,lu=Math.cos(Math.PI/180*37.5),cu=Math.pow(2,14)/.5;class uu{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=t.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={};for(const t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new Yo,this.layoutVertexArray2=new Xo,this.indexArray=new sa,this.programConfigurations=new Ra(t.layers,t.zoom),this.segments=new ha,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=Gh("line",this.layers,e)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),s=!n.isConstant(),r=[];for(const{feature:e,id:o,index:a,sourceLayerIndex:h}of t){const t=this.layers[0]._featureFilter.needGeometry,l=Va(e,t);if(!this.layers[0]._featureFilter.filter(new kr(this.zoom),l,i))continue;const c=s?n.evaluate(l,{},i):void 0,u={id:o,properties:e.properties,type:e.type,sourceLayerIndex:h,index:a,geometry:t?l.geometry:Ga(e),patterns:{},dashes:{},sortKey:c};r.push(u)}s&&r.sort(((t,e)=>t.sortKey-e.sortKey));for(const n of r){const{geometry:s,index:r,sourceLayerIndex:o}=n;this.hasDependencies?(Gh("line",this.layers,e)?Vh("line",this.layers,n,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,e),this.patternFeatures.push(n)):this.addFeature(n,s,r,i,{},{},e.subdivisionGranularity),e.featureIndex.insert(t[r].feature,s,r,o,this.index)}}update(t,e,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i,dashPositions:n})}addFeatures(t,e,i,n){for(const s of this.patternFeatures)this.addFeature(s,s.geometry,s.index,e,i,n,t.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,hu)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ou),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&Object.hasOwn(t.properties,Wc)&&Object.hasOwn(t.properties,Hc))return{start:+t.properties[Wc],end:+t.properties[Hc]}}addFeature(t,e,i,n,s,r,o){const a=this.layers[0].layout,h=a.get("line-join").evaluate(t,{}),l=a.get("line-cap").evaluate(t,{}),c=a.get("line-miter-limit").evaluate(t,{}),u=a.get("line-round-limit").evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(const i of e)this.addLine(i,t,h,l,c,u,n,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:s,dashPositions:r,canonical:n})}addLine(t,e,i,n,s,r,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=xl(t,o?a.line.getGranularityForZoomLevel(o.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const h="Polygon"===kl.types[e.type];let l=t.length;for(;l>=2&&t[l-1].equals(t[l-2]);)l--;let c=0;for(;c<l-1&&t[c].equals(t[c+1]);)c++;if(l<(h?3:2))return;"bevel"===i&&(s=1.05);const u=this.overscaling<=16?122880/(512*this.overscaling):0,f=this.segments.prepareSegment(10*l,this.layoutVertexArray,this.indexArray);let d,p,m,_,g;this.e1=this.e2=-1,h&&(d=t[l-2],g=t[c].sub(d)._unit()._perp());for(let e=c;e<l;e++){if(m=e===l-1?h?t[c+1]:void 0:t[e+1],m&&t[e].equals(m))continue;g&&(_=g),d&&(p=d),d=t[e],g=m?m.sub(d)._unit()._perp():_,_||(_=g);let o=_.add(g);0===o.x&&0===o.y||o._unit();const a=_.x*g.x+_.y*g.y,v=o.x*g.x+o.y*g.y,y=0!==v?1/v:1/0,w=2*Math.sqrt(2-2*v),b=v<lu&&p&&m,x=_.x*g.y-_.y*g.x>0;if(b&&e>c){const t=d.dist(p);if(t>2*u){const e=d.sub(d.sub(p)._mult(u/t)._round());this.updateDistance(p,e),this.addCurrentVertex(e,_,0,0,f),p=e}}const M=p&&m;let S=M?i:h?"butt":n;if(M&&"round"===S&&(y<r?S="miter":y<=2&&(S="fakeround")),"miter"===S&&y>s&&(S="bevel"),"bevel"===S&&(y>2&&(S="flipbevel"),y<s&&(S="miter")),p&&this.updateDistance(p,d),"miter"===S)o._mult(y),this.addCurrentVertex(d,o,0,0,f);else if("flipbevel"===S){if(y>100)o=g.mult(-1);else{const t=y*_.add(g).mag()/_.sub(g).mag();o._perp()._mult(t*(x?-1:1))}this.addCurrentVertex(d,o,0,0,f),this.addCurrentVertex(d,o.mult(-1),0,0,f)}else if("bevel"===S||"fakeround"===S){const t=-Math.sqrt(y*y-1),e=x?t:0,i=x?0:t;if(p&&this.addCurrentVertex(d,_,e,i,f),"fakeround"===S){const t=Math.round(180*w/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){const t=i-.5;i+=i*t*(i-1)*((1.0904+a*(a*(3.55645-1.43519*a)-3.2452))*t*t+(.848013+a*(.215638*a-1.06021)))}const n=g.sub(_)._mult(i)._add(_)._unit()._mult(x?-1:1);this.addHalfVertex(d,n.x,n.y,!1,x,0,f)}}m&&this.addCurrentVertex(d,g,-e,-i,f)}else if("butt"===S)this.addCurrentVertex(d,o,0,0,f);else if("square"===S){const t=p?1:-1;this.addCurrentVertex(d,o,t,t,f)}else"round"===S&&(p&&(this.addCurrentVertex(d,_,0,0,f),this.addCurrentVertex(d,_,1,1,f,!0)),m&&(this.addCurrentVertex(d,g,-1,-1,f,!0),this.addCurrentVertex(d,g,0,0,f)));if(b&&e<l-1){const t=d.dist(m);if(t>2*u){const e=d.add(m.sub(d)._mult(u/t)._round());this.updateDistance(d,e),this.addCurrentVertex(e,g,0,0,f),d=e}}}}addCurrentVertex(t,e,i,n,s,r=!1){const o=e.y*n-e.x,a=-e.y-e.x*n;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,r,!1,i,s),this.addHalfVertex(t,o,a,r,!0,-n,s),this.distance>cu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,n,s,r))}addHalfVertex({x:t,y:e},i,n,s,r,o,a){const h=.5*(this.lineClips?this.scaledDistance*(cu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((t<<1)+(s?1:0),(e<<1)+(r?1:0),Math.round(63*i)+128,Math.round(63*n)+128,1+(0===o?0:o<0?-1:1)|(63&h)<<2,h>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const l=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,l,this.e2),a.primitiveLength++),r?this.e2=l:this.e1=l}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(t,e){this.distance+=t.dist(e),this.updateScaledDistance()}hasLineDasharray(t){for(const e of t){const t=e.paint.get("line-dasharray");if(t&&!t.isConstant())return!0}return!1}addLineDashDependencies(t,e,i,n){for(const s of t){const t=s.paint.get("line-dasharray");if(!t||"constant"===t.value.kind)continue;const r="round"===s.layout.get("line-cap").evaluate(e,{}),o={dasharray:t.value.evaluate({zoom:i-1},e,{}),round:r},a={dasharray:t.value.evaluate({zoom:i},e,{}),round:r},h={dasharray:t.value.evaluate({zoom:i+1},e,{}),round:r},l=`${o.dasharray.join(",")},${o.round}`,c=`${a.dasharray.join(",")},${a.round}`,u=`${h.dasharray.join(",")},${h.round}`;n.dashDependencies[l]=o,n.dashDependencies[c]=a,n.dashDependencies[u]=h,e.dashes[s.id]={min:l,mid:c,max:u}}}}let fu,du;dr("LineBucket",uu,{omit:["layers","patternFeatures"]});var pu={get paint(){return du=du||new Xr({"line-opacity":new Zr(bt.paint_line["line-opacity"]),"line-color":new Zr(bt.paint_line["line-color"]),"line-translate":new qr(bt.paint_line["line-translate"]),"line-translate-anchor":new qr(bt.paint_line["line-translate-anchor"]),"line-width":new Zr(bt.paint_line["line-width"]),"line-gap-width":new Zr(bt.paint_line["line-gap-width"]),"line-offset":new Zr(bt.paint_line["line-offset"]),"line-blur":new Zr(bt.paint_line["line-blur"]),"line-dasharray":new Wr(bt.paint_line["line-dasharray"]),"line-pattern":new Wr(bt.paint_line["line-pattern"]),"line-gradient":new Yr(bt.paint_line["line-gradient"])})},get layout(){return fu=fu||new Xr({"line-cap":new Zr(bt.layout_line["line-cap"]),"line-join":new Zr(bt.layout_line["line-join"]),"line-miter-limit":new Zr(bt.layout_line["line-miter-limit"]),"line-round-limit":new Zr(bt.layout_line["line-round-limit"]),"line-sort-key":new Zr(bt.layout_line["line-sort-key"])})}};class mu extends Zr{possiblyEvaluate(t,e){return e=new kr(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,n){return e=L({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,n)}}let _u;class gu extends Qr{constructor(t,e){super(t,pu,e),this.gradientVersion=0,_u||(_u=new mu(pu.paint.properties["line-width"].specification),_u.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){const t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof li,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=_u.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new uu(t)}queryRadius(t){const e=t,i=vu(rh("line-width",this,e),rh("line-gap-width",this,e)),n=rh("line-offset",this,e);return i/2+Math.abs(n)+oh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:n,geometry:s,transform:r,pixelsToTileUnits:o}){const a=ah(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-r.bearingInRadians,o),h=o/2*vu(this.paint.get("line-width").evaluate(e,n),this.paint.get("line-gap-width").evaluate(e,n)),l=this.paint.get("line-offset").evaluate(e,n);return l&&(s=function(t,e){const n=[];for(const s of t){const t=hh(s),r=[];for(let n=0;n<t.length;n++){const s=t[n],o=t[n-1],a=t[n+1],h=0===n?new i(0,0):s.sub(o)._unit()._perp(),l=n===t.length-1?new i(0,0):a.sub(s)._unit()._perp(),c=h._add(l)._unit(),u=c.x*l.x+c.y*l.y;0!==u&&c._mult(1/u),r.push(c._mult(e)._add(s))}n.push(r)}return n}(s,l*o)),function(t,e,i){for(const n of e){if(t.length>=3)for(const e of n)if(nh(t,e))return!0;if(Ja(t,n,i))return!0}return!1}(a,s,h)}isTileClipped(){return!0}}function vu(t,e){return e>0?e+2*t:t}const yu=oo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),wu=oo([{name:"a_projected_pos",components:3,type:"Float32"}],4);oo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const bu=oo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);oo([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const xu=oo([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Mu=oo([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function Su(t,e,i){const n=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===n?t=t.toLocaleUpperCase():"lowercase"===n&&(t=t.toLocaleLowerCase()),Ir.applyArabicShaping&&(t=Ir.applyArabicShaping(t)),t}function zu(t,e,i){for(const n of t.sections)n.text=Su(n.text,e,i);return t}oo([{name:"triangle",components:3,type:"Uint16"}]),oo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),oo([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),oo([{type:"Float32",name:"offsetX"}]),oo([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),oo([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var Tu=24;const Eu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},Au={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},Pu={40:!0};function Cu(t,e,i,n,s,r){if("fontStack"in e){const n=i[e.fontStack],r=null==n?void 0:n[t];return r?r.metrics.advance*e.scale+s:0}{const t=n[e.imageName];return t?t.displaySize[0]*e.scale*Tu/r+s:0}}function Du(t,e,i,n){const s=Math.pow(t-e,2);return n?t<e?s/2:2*s:s+Math.abs(i)*i}function Fu(t,e,i){let n=0;return 10===t&&(n-=1e4),i&&(n+=150),40!==t&&65288!==t||(n+=50),41!==e&&65289!==e||(n+=50),n}function Iu(t,e,i,n,s,r){let o=null,a=Du(e,i,s,r);for(const t of n){const n=Du(e-t.x,i,s,r)+t.badness;n<=a&&(o=t,a=n)}return{index:t,x:e,priorBreak:o,badness:a}}function ku(t){return t?ku(t.priorBreak).concat(t.index):[]}class $u{constructor(t="",e=[],i=[]){this.text=t,this.sections=e,this.sectionIndex=i,this.imageSectionID=null}static fromFeature(t,e){const i=new $u;for(const n of t.sections)n.image?i.addImageSection(n):i.addTextSection(n,e);return i}length(){return[...this.text].length}getSection(t){return this.sections[this.sectionIndex[t]]}getSectionIndex(t){return this.sectionIndex[t]}verticalizePunctuation(){this.text=function(t){let e="",i={premature:!0,value:void 0};const n=t[Symbol.iterator]();let s=n.next();const r=t[Symbol.iterator]();r.next();let o=r.next();for(;!s.done;)e+=!o.done&&Ar(o.value.codePointAt(0))&&!Eu[o.value]||!i.premature&&Ar(i.value.codePointAt(0))&&!Eu[i.value]||!Eu[s.value]?s.value:Eu[s.value],i={value:s.value,premature:!1},s=n.next(),o=r.next();return e}(this.text)}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){const t=this.text.match(/^\s*/),e=t?t[0].length:0,i=this.text.match(/\S\s*$/),n=i?i[0].length-1:0;this.text=this.text.substring(e,this.text.length-n),this.sectionIndex=this.sectionIndex.slice(e,this.sectionIndex.length-n)}substring(t,e){const i=[...this.text].slice(t,e).join(""),n=this.sectionIndex.slice(t,e);return new $u(i,this.sections,n)}toCodeUnitIndex(t){return[...this.text].slice(0,t).join("").length}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce(((t,e)=>Math.max(t,this.sections[e].scale)),0)}getMaxImageSize(t){let e=0,i=0;for(let n=0;n<this.length();n++){const s=this.getSection(n);if("imageName"in s){const n=t[s.imageName];if(!n)continue;const r=n.displaySize;e=Math.max(e,r[0]),i=Math.max(i,r[1])}}return{maxImageWidth:e,maxImageHeight:i}}addTextSection(t,e){this.text+=t.text,this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||e});const i=this.sections.length-1;this.sectionIndex.push(...[...t.text].map((()=>i)))}addImageSection(t){const e=t.image?t.image.name:"";if(0===e.length)return void q("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:e}),this.sectionIndex.push(this.sections.length-1)):q("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(t,e,i,n,s){const r=[],o=this.determineAverageLineWidth(t,e,i,n,s),a=this.hasZeroWidthSpaces();let h=0,l=0;const c=this.text[Symbol.iterator]();let u=c.next();const f=this.text[Symbol.iterator]();f.next();let d=f.next();const p=this.text[Symbol.iterator]();p.next(),p.next();let m=p.next();for(;!u.done;){const e=this.getSection(l),_=u.value.codePointAt(0);if(xr(_)||(h+=Cu(_,e,i,n,t,s)),!d.done){const t=wr(_),i=d.value.codePointAt(0);(Au[_]||t||"imageName"in e||!m.done&&Pu[i])&&r.push(Iu(l+1,h,o,r,Fu(_,i,t&&a),!1))}l++,u=c.next(),d=f.next(),m=p.next()}return ku(Iu(this.length(),h,o,r,0,!0))}determineAverageLineWidth(t,e,i,n,s){let r=0,o=0;for(const e of this.text){const a=this.getSection(o);r+=Cu(e.codePointAt(0),a,i,n,t,s),o++}return r/Math.max(1,Math.ceil(r/e))}}const Ou=4294967296,ju=1/Ou,Ru="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class Lu{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,i=this.length){for(;this.pos<i;){const i=this.readVarint(),n=i>>3,s=this.pos;this.type=7&i,t(n,e,this),this.pos===s&&this.skip(i)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ou;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ou;return this.pos+=8,t}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const e=this.buf;let i,n;return n=e[this.pos++],i=127&n,n<128?i:(n=e[this.pos++],i|=(127&n)<<7,n<128?i:(n=e[this.pos++],i|=(127&n)<<14,n<128?i:(n=e[this.pos++],i|=(127&n)<<21,n<128?i:(n=e[this.pos],i|=(15&n)<<28,function(t,e,i){const n=i.buf;let s,r;if(r=n[i.pos++],s=(112&r)>>4,r<128)return Bu(t,s,e);if(r=n[i.pos++],s|=(127&r)<<3,r<128)return Bu(t,s,e);if(r=n[i.pos++],s|=(127&r)<<10,r<128)return Bu(t,s,e);if(r=n[i.pos++],s|=(127&r)<<17,r<128)return Bu(t,s,e);if(r=n[i.pos++],s|=(127&r)<<24,r<128)return Bu(t,s,e);if(r=n[i.pos++],s|=(1&r)<<31,r<128)return Bu(t,s,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Ru?Ru.decode(this.buf.subarray(e,t)):function(t,e,i){let n="",s=e;for(;s<i;){const e=t[s];let r,o,a,h=null,l=e>239?4:e>223?3:e>191?2:1;if(s+l>i)break;1===l?e<128&&(h=e):2===l?(r=t[s+1],128==(192&r)&&(h=(31&e)<<6|63&r,h<=127&&(h=null))):3===l?(r=t[s+1],o=t[s+2],128==(192&r)&&128==(192&o)&&(h=(15&e)<<12|(63&r)<<6|63&o,(h<=2047||h>=55296&&h<=57343)&&(h=null))):4===l&&(r=t[s+1],o=t[s+2],a=t[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(h=(15&e)<<18|(63&r)<<12|(63&o)<<6|63&a,(h<=65535||h>=1114112)&&(h=null))),null===h?(h=65533,l=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),s+=l}return n}(this.buf,e,t)}readBytes(){const t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const e=7&t;if(0===e)for(;this.buf[this.pos++]>127;);else if(2===e)this.pos=this.readVarint()+this.pos;else if(5===e)this.pos+=4;else{if(1!==e)throw new Error(`Unimplemented type: ${e}`);this.pos+=8}}writeTag(t,e){this.writeVarint(t<<3|e)}realloc(t){let e=this.length||16;for(;e<this.pos+t;)e*=2;if(e!==this.length){const t=new Uint8Array(e);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=e}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ju),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*ju),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,e){let i,n;if(t>=0?(i=t%4294967296|0,n=t/4294967296|0):(i=~(-t%4294967296),n=~(-t/4294967296),4294967295^i?i=i+1|0:(i=0,n=n+1|0)),t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),function(t,e,i){i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,t>>>=7,i.buf[i.pos++]=127&t|128,i.buf[i.pos]=127&(t>>>=7)}(i,0,e),function(t,e){const i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(n,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const e=this.pos;this.pos=function(t,e,i){for(let n,s,r=0;r<e.length;r++){if(n=e.charCodeAt(r),n>55295&&n<57344){if(!s){n>56319||r+1===e.length?(t[i++]=239,t[i++]=191,t[i++]=189):s=n;continue}if(n<56320){t[i++]=239,t[i++]=191,t[i++]=189,s=n;continue}n=s-55296<<10|n-56320|65536,s=null}else s&&(t[i++]=239,t[i++]=191,t[i++]=189,s=null);n<128?t[i++]=n:(n<2048?t[i++]=n>>6|192:(n<65536?t[i++]=n>>12|224:(t[i++]=n>>18|240,t[i++]=n>>12&63|128),t[i++]=n>>6&63|128),t[i++]=63&n|128)}return i}(this.buf,t,this.pos);const i=this.pos-e;i>=128&&Nu(e,i,this),this.pos=e-1,this.writeVarint(i),this.pos+=i}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const e=t.length;this.writeVarint(e),this.realloc(e);for(let i=0;i<e;i++)this.buf[this.pos++]=t[i]}writeRawMessage(t,e){this.pos++;const i=this.pos;t(e,this);const n=this.pos-i;n>=128&&Nu(i,n,this),this.pos=i-1,this.writeVarint(n),this.pos+=n}writeMessage(t,e,i){this.writeTag(t,2),this.writeRawMessage(e,i)}writePackedVarint(t,e){e.length&&this.writeMessage(t,Uu,e)}writePackedSVarint(t,e){e.length&&this.writeMessage(t,Gu,e)}writePackedBoolean(t,e){e.length&&this.writeMessage(t,Zu,e)}writePackedFloat(t,e){e.length&&this.writeMessage(t,Vu,e)}writePackedDouble(t,e){e.length&&this.writeMessage(t,qu,e)}writePackedFixed32(t,e){e.length&&this.writeMessage(t,Wu,e)}writePackedSFixed32(t,e){e.length&&this.writeMessage(t,Hu,e)}writePackedFixed64(t,e){e.length&&this.writeMessage(t,Yu,e)}writePackedSFixed64(t,e){e.length&&this.writeMessage(t,Xu,e)}writeBytesField(t,e){this.writeTag(t,2),this.writeBytes(e)}writeFixed32Field(t,e){this.writeTag(t,5),this.writeFixed32(e)}writeSFixed32Field(t,e){this.writeTag(t,5),this.writeSFixed32(e)}writeFixed64Field(t,e){this.writeTag(t,1),this.writeFixed64(e)}writeSFixed64Field(t,e){this.writeTag(t,1),this.writeSFixed64(e)}writeVarintField(t,e){this.writeTag(t,0),this.writeVarint(e)}writeSVarintField(t,e){this.writeTag(t,0),this.writeSVarint(e)}writeStringField(t,e){this.writeTag(t,2),this.writeString(e)}writeFloatField(t,e){this.writeTag(t,5),this.writeFloat(e)}writeDoubleField(t,e){this.writeTag(t,1),this.writeDouble(e)}writeBooleanField(t,e){this.writeVarintField(t,+e)}}function Bu(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}function Nu(t,e,i){const n=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));i.realloc(n);for(let e=i.pos-1;e>=t;e--)i.buf[e+n]=i.buf[e]}function Uu(t,e){for(let i=0;i<t.length;i++)e.writeVarint(t[i])}function Gu(t,e){for(let i=0;i<t.length;i++)e.writeSVarint(t[i])}function Vu(t,e){for(let i=0;i<t.length;i++)e.writeFloat(t[i])}function qu(t,e){for(let i=0;i<t.length;i++)e.writeDouble(t[i])}function Zu(t,e){for(let i=0;i<t.length;i++)e.writeBoolean(t[i])}function Wu(t,e){for(let i=0;i<t.length;i++)e.writeFixed32(t[i])}function Hu(t,e){for(let i=0;i<t.length;i++)e.writeSFixed32(t[i])}function Yu(t,e){for(let i=0;i<t.length;i++)e.writeFixed64(t[i])}function Xu(t,e){for(let i=0;i<t.length;i++)e.writeSFixed64(t[i])}function Ju(t,e,i){1===t&&i.readMessage(Ku,e)}function Ku(t,e,i){if(3===t){const{id:t,bitmap:n,width:s,height:r,left:o,top:a,advance:h}=i.readMessage(Qu,{});e.push({id:t,bitmap:new zh({width:s+6,height:r+6},n),metrics:{width:s,height:r,left:o,top:a,advance:h}})}}function Qu(t,e,i){1===t?e.id=i.readVarint():2===t?e.bitmap=i.readBytes():3===t?e.width=i.readVarint():4===t?e.height=i.readVarint():5===t?e.left=i.readSVarint():6===t?e.top=i.readSVarint():7===t&&(e.advance=i.readVarint())}function tf(t){let e=0,i=0;for(const n of t)e+=n.w*n.h,i=Math.max(i,n.w);t.sort(((t,e)=>e.h-t.h));const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let s=0,r=0;for(const e of t)for(let t=n.length-1;t>=0;t--){const i=n[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,r=Math.max(r,e.y+e.h),s=Math.max(s,e.x+e.w),e.w===i.w&&e.h===i.h){const e=n.pop();e&&t<n.length&&(n[t]=e)}else e.h===i.h?(i.x+=e.w,i.w-=e.w):e.w===i.w?(i.y+=e.h,i.h-=e.h):(n.push({x:i.x+e.w,y:i.y,w:i.w-e.w,h:e.h}),i.y+=e.h,i.h-=e.h);break}}return{w:s,h:r,fill:e/(s*r)||0}}class ef{constructor(t,{pixelRatio:e,version:i,stretchX:n,stretchY:s,content:r,textFitWidth:o,textFitHeight:a}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=n,this.stretchY=s,this.content=r,this.version=i,this.textFitWidth=o,this.textFitHeight=a}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get tlbr(){return this.tl.concat(this.br)}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class nf{constructor(t,e){const i={},n={};this.haveRenderCallbacks=[];const s=[];this.addImages(t,i,s),this.addImages(e,n,s);const{w:r,h:o}=tf(s),a=new Th({width:r||1,height:o||1});for(const e in t){const n=t[e],s=i[e].paddedRect;Th.copy(n.data,a,{x:0,y:0},{x:s.x+1,y:s.y+1},n.data)}for(const t in e){const i=e[t],s=n[t].paddedRect,r=s.x+1,o=s.y+1,h=i.data.width,l=i.data.height;Th.copy(i.data,a,{x:0,y:0},{x:r,y:o},i.data),Th.copy(i.data,a,{x:0,y:l-1},{x:r,y:o-1},{width:h,height:1}),Th.copy(i.data,a,{x:0,y:0},{x:r,y:o+l},{width:h,height:1}),Th.copy(i.data,a,{x:h-1,y:0},{x:r-1,y:o},{width:1,height:l}),Th.copy(i.data,a,{x:0,y:0},{x:r+h,y:o},{width:1,height:l})}this.image=a,this.iconPositions=i,this.patternPositions=n}addImages(t,e,i){for(const n in t){const s=t[n],r={x:0,y:0,w:s.data.width+2,h:s.data.height+2};i.push(r),e[n]=new ef(r,s),s.hasRenderCallback&&this.haveRenderCallbacks.push(n)}}patchUpdatedImages(t,e){t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const i in t.updatedImages)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e),this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}patchUpdatedImage(t,e,i){if(!t||!e)return;if(t.version===e.version)return;t.version=e.version;const[n,s]=t.tl;i.update(e.data,void 0,{x:n,y:s})}}var sf;function rf(e,i,n,s,r,o,a,h,l,c,u,f,d,p,m){const _=$u.fromFeature(e,r);let g;f===t.ax.vertical&&_.verticalizePunctuation();let v=_.determineLineBreaks(c,o,i,s,p);const{processBidirectionalText:y,processStyledBidirectionalText:w}=Ir;if(y&&1===_.sections.length){g=[],v=v.map((t=>_.toCodeUnitIndex(t)));const t=y(_.toString(),v);for(const e of t){const t=[...e].map((()=>0));g.push(new $u(e,_.sections,t))}}else if(w){g=[],v=v.map((t=>_.toCodeUnitIndex(t)));let t=0;const e=[];for(const i of _.text)e.push(...Array(i.length).fill(_.sectionIndex[t])),t++;const i=w(_.text,e,v);for(const t of i){const e=[];let i="";for(const n of t[0])e.push(t[1][i.length]),i+=n;g.push(new $u(t[0],_.sections,e))}}else g=function(t,e){const i=[];let n=0;for(const s of e)i.push(t.substring(n,s)),n=s;return n<t.length()&&i.push(t.substring(n,t.length())),i}(_,v);const b=[],x={positionedLines:b,text:_.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:f,iconsInText:!1,verticalizable:!1};return function(t,e,i,n,s,r,o,a,h,l,c,u){let f=0,d=0,p=0,m=0;const _="right"===a?1:"left"===a?0:.5,g=Tu/u;let v=0;for(const o of s){o.trim();const s=o.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[v]=a;const u=a.positionedGlyphs;let y=0;if(!o.length()){d+=r,++v;continue}const w=af(n,o,g);let b=0;for(const r of o.text){const a=o.getSection(b),p=r.codePointAt(0),m=lf(h,c,p),_={glyph:p,imageName:null,x:f,y:d+-17,vertical:m,scale:1,fontStack:"",sectionIndex:o.getSectionIndex(b),metrics:null,rect:null};let v;if("fontStack"in a){if(v=cf(a,p,m,w,e,i),!v)continue;_.fontStack=a.fontStack}else{if(t.iconsInText=!0,a.scale*=g,v=uf(a,m,s,w,n),!v)continue;y=Math.max(y,v.imageOffset),_.imageName=a.imageName}const{rect:x,metrics:M,baselineOffset:S}=v;_.y+=S,_.scale=a.scale,_.metrics=M,_.rect=x,u.push(_),m?(t.verticalizable=!0,f+=("imageName"in a?M.advance:Tu)*a.scale+l):f+=M.advance*a.scale+l,b++}0!==u.length&&(p=Math.max(f-l,p),ff(u,0,u.length-1,_)),f=0,a.lineOffset=Math.max(y,(s-1)*Tu);const x=r*s+y;d+=x,m=Math.max(x,m),++v}const{horizontalAlign:y,verticalAlign:w}=of(o);(function(t,e,i,n,s,r,o,a,h){const l=(e-i)*s;let c=0;c=r!==o?-a*n- -17:-n*h*o+.5*o;for(const e of t)for(const t of e.positionedGlyphs)t.x+=l,t.y+=c})(t.positionedLines,_,y,w,p,m,r,d,s.length),t.top+=-w*d,t.bottom=t.top+d,t.left+=-y*p,t.right=t.left+p}(x,i,n,s,g,a,h,l,f,c,d,m),!function(t){for(const e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(b)&&x}function of(t){let e=.5,i=.5;switch(t){case"right":case"top-right":case"bottom-right":e=1;break;case"left":case"top-left":case"bottom-left":e=0}switch(t){case"bottom":case"bottom-right":case"bottom-left":i=1;break;case"top":case"top-right":case"top-left":i=0}return{horizontalAlign:e,verticalAlign:i}}function af(t,e,i){const n=e.getMaxScale()*Tu,{maxImageWidth:s,maxImageHeight:r}=e.getMaxImageSize(t),o=Math.max(n,r*i);return{verticalLineContentWidth:Math.max(n,s*i),horizontalLineContentHeight:o}}function hf(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function lf(e,i,n){return!(e===t.ax.horizontal||!i&&!br(n)||i&&(xr(n)||(s=n,/\p{sc=Arab}/u.test(String.fromCodePoint(s)))));var s}function cf(t,e,i,n,s,r){const o=r[t.fontStack],a=function(t,e,i,n){if(null==t?void 0:t.rect)return t;const s=e[i.fontStack],r=null==s?void 0:s[n];return r?{rect:null,metrics:r.metrics}:null}(null==o?void 0:o[e],s,t,e);if(null===a)return null;let h;if(i)h=n.verticalLineContentWidth-t.scale*Tu;else{const e=hf(t.verticalAlign);h=(n.horizontalLineContentHeight-t.scale*Tu)*e}return{rect:a.rect,metrics:a.metrics,baselineOffset:h}}function uf(t,e,i,n,s){const r=s[t.imageName];if(!r)return null;const o=r.paddedRect,a=r.displaySize,h={width:a[0],height:a[1],left:1,top:-3,advance:e?a[1]:a[0]};let l;if(e)l=n.verticalLineContentWidth-a[1]*t.scale;else{const e=hf(t.verticalAlign);l=(n.horizontalLineContentHeight-a[1]*t.scale)*e}return{rect:o,metrics:h,baselineOffset:l,imageOffset:(e?a[0]:a[1])*t.scale-Tu*i}}function ff(t,e,i,n){if(0===n)return;const s=t[i],r=(t[i].x+s.metrics.advance*s.scale)*n;for(let n=e;n<=i;n++)t[n].x-=r}function df(t,e,i){const{horizontalAlign:n,verticalAlign:s}=of(i),r=e[0]-t.displaySize[0]*n,o=e[1]-t.displaySize[1]*s;return{image:t,top:o,bottom:o+t.displaySize[1],left:r,right:r+t.displaySize[0]}}function pf(t){var e,i;let n=t.left,s=t.top,r=t.right-n,o=t.bottom-s;const a=null!==(e=t.image.textFitWidth)&&void 0!==e?e:"stretchOrShrink",h=null!==(i=t.image.textFitHeight)&&void 0!==i?i:"stretchOrShrink",l=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===h){if("stretchOnly"===a&&r/o<l||"proportional"===a){const t=Math.ceil(o*l);n*=t/r,r=t}}else if("proportional"===a&&"stretchOnly"===h&&0!==l&&r/o>l){const t=Math.ceil(r/l);s*=t/o,o=t}return{x1:n,y1:s,x2:n+r,y2:s+o}}function mf(t,e,i,n,s,r){const o=t.image;let a;if(o.content){const t=o.content,e=o.pixelRatio||1;a=[t[0]/e,t[1]/e,o.displaySize[0]-t[2]/e,o.displaySize[1]-t[3]/e]}const h=e.left*r,l=e.right*r;let c,u,f,d;"width"===i||"both"===i?(d=s[0]+h-n[3],u=s[0]+l+n[1]):(d=s[0]+(h+l-o.displaySize[0])/2,u=d+o.displaySize[0]);const p=e.top*r,m=e.bottom*r;return"height"===i||"both"===i?(c=s[1]+p-n[0],f=s[1]+m+n[2]):(c=s[1]+(p+m-o.displaySize[1])/2,f=c+o.displaySize[1]),{image:o,top:c,right:u,bottom:f,left:d,collisionPadding:a}}dr("ImagePosition",ef),dr("ImageAtlas",nf),t.ax=void 0,(sf=t.ax||(t.ax={}))[sf.none=0]="none",sf[sf.horizontal=1]="horizontal",sf[sf.vertical=2]="vertical",sf[sf.horizontalOnly=3]="horizontalOnly";const _f=128,gf=32640;function vf(t,e){const{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new kr(t+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:e,interpolationType:n}=i;let s=0;for(;s<e.length&&e[s]<=t;)s++;s=Math.max(0,s-1);let r=s;for(;r<e.length&&e[r]<t+1;)r++;r=Math.min(e.length-1,r);const o=e[s],a=e[r];return"composite"===i.kind?{kind:"composite",minZoom:o,maxZoom:a,interpolationType:n}:{kind:"camera",minZoom:o,maxZoom:a,minSize:i.evaluate(new kr(o)),maxSize:i.evaluate(new kr(a)),interpolationType:n}}}function yf(t,e,i){let n="never";const s=t.get(e);return s?n=s:t.get(i)&&(n="always"),n}const wf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function bf(t,e,i,n,s,r,o,a,h,l,c,u,f){const d=a?Math.min(gf,Math.round(a[0])):0,p=a?Math.min(gf,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*n),Math.round(32*s),r,o,(d<<1)+(h?1:0),p,16*l,16*c,256*u,256*f)}function xf(t,e,i){t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i),t.emplaceBack(e.x,e.y,i)}function Mf(t){for(const e of t.sections)if(Fr(e.text))return!0;return!1}class Sf{constructor(t){this.layoutVertexArray=new Qo,this.indexArray=new sa,this.programConfigurations=t,this.segments=new ha,this.dynamicLayoutVertexArray=new ta,this.opacityVertexArray=new ea,this.hasVisibleVertices=!1,this.placedSymbolArray=new Oo}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,n){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,yu.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,wu.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,wf,!0),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy())}}dr("SymbolBuffers",Sf);class zf{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new ha,this.collisionVertexArray=new na}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,bu.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}}dr("CollisionBuffers",zf);class Tf{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map((t=>t.id)),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=vf(this.zoom,i["text-size"]),this.iconSizeData=vf(this.zoom,i["icon-size"]);const n=this.layers[0].layout,s=n.get("symbol-sort-key"),r=n.get("symbol-z-order");this.canOverlap="never"!==yf(n,"text-overlap","text-allow-overlap")||"never"!==yf(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==r&&!s.isConstant(),this.sortFeaturesByY=("viewport-y"===r||"auto"===r&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map((e=>t.ax[e]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=e.sourceID}createArrays(){this.text=new Sf(new Ra(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new Sf(new Ra(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new Lo,this.lineVertexArray=new Bo,this.symbolInstances=new Ro,this.textAnchorOffsets=new Uo}calculateGlyphDependencies(t,e,i,n,s){for(const r of t)if(e[r.codePointAt(0)]=!0,(i||n)&&s){const t=Eu[r];t&&(e[t.codePointAt(0)]=!0)}}populate(e,i,n){var s;const r=this.layers[0],o=r.layout,a=o.get("text-font"),h=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==h.value.kind||h.value.value instanceof Ie&&!h.value.value.isEmpty()||h.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,f=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,m=i.availableImages,_=new kr(this.zoom);for(const{feature:i,id:h,index:l,sourceLayerIndex:g}of e){const e=r._featureFilter.needGeometry,v=Va(i,e);if(!r._featureFilter.filter(_,v,n))continue;let y,w;if(e||(v.geometry=Ga(i)),c){const t=r.getValueAndResolveTokens("text-field",v,n,m),e=Ie.factory(t);this.hasRTLText||(this.hasRTLText=Mf(e)),(!this.hasRTLText||"unavailable"===Ir.getRTLTextPluginStatus()||this.hasRTLText&&Ir.isParsed())&&(y=zu(e,r,v))}if(u){const t=r.getValueAndResolveTokens("icon-image",v,n,m);w=t instanceof Be?t:Be.fromString(t)}if(!y&&!w)continue;const b=this.sortFeaturesByKey?f.evaluate(v,{},n):void 0;if(this.features.push({id:h,text:y,icon:w,index:l,sourceLayerIndex:g,geometry:v.geometry,properties:i.properties,type:kl.types[i.type],sortKey:b}),w&&(d[w.name]=!0),y){const e=a.evaluate(v,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=null===(s=this.writingModes)||void 0===s?void 0:s.includes(t.ax.vertical);for(const t of y.sections)if(t.image)d[t.image.name]=!0;else{const n=Mr(y.toString()),s=t.fontStack||e;p[s]||(p[s]={}),this.calculateGlyphDependencies(t.text,p[s],i,this.allowVerticalPlacement,n)}}}"line"===o.get("symbol-placement")&&(this.features=function(t){const e={},i={},n=[];let s=0;function r(e){n.push(t[e]),s++}function o(t,e,s){const r=i[t];return delete i[t],i[e]=r,n[r].geometry[0].pop(),n[r].geometry[0]=n[r].geometry[0].concat(s[0]),r}function a(t,i,s){const r=e[i];return delete e[i],e[t]=r,n[r].geometry[0].shift(),n[r].geometry[0]=s[0].concat(n[r].geometry[0]),r}function h(t,e,i){const n=i?e[0][e[0].length-1]:e[0][0];return`${t}:${n.x}:${n.y}`}for(let l=0;l<t.length;l++){const c=t[l],u=c.geometry,f=c.text?c.text.toString():null;if(!f){r(l);continue}const d=h(f,u),p=h(f,u,!0);if(d in i&&p in e&&i[d]!==e[p]){const t=a(d,p,u),s=o(d,p,n[t].geometry);delete e[d],delete i[p],i[h(f,n[s].geometry,!0)]=s,n[t].geometry=null}else d in i?o(d,p,u):p in e?a(d,p,u):(r(l),e[d]=s-1,i[p]=s-1)}return n.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,e){const i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),n=t.dist(e[t.segment]);const s={};for(let n=t.segment+1;n<e.length;n++)s[n]={x:e[n].x,y:e[n].y,tileUnitDistanceFromAnchor:i},n<e.length-1&&(i+=e[n+1].dist(e[n]));for(let i=t.segment||0;i>=0;i--)s[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){const e=s[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(e,i,n,s,r,o,a,h,l,c,u,f){const d=e.indexArray,p=e.layoutVertexArray,m=e.segments.prepareSegment(4*i.length,p,d,this.canOverlap?o.sortKey:void 0),_=this.glyphOffsetArray.length,g=m.vertexLength,v=this.allowVerticalPlacement&&a===t.ax.vertical?Math.PI/2:0,y=o.text&&o.text.sections;for(let t=0;t<i.length;t++){const{tl:s,tr:r,bl:a,br:l,tex:c,pixelOffsetTL:u,pixelOffsetBR:_,minFontScaleX:g,minFontScaleY:w,glyphOffset:b,isSDF:x,sectionIndex:M}=i[t],S=m.vertexLength,z=b[1];bf(p,h.x,h.y,s.x,z+s.y,c.x,c.y,n,x,u.x,u.y,g,w),bf(p,h.x,h.y,r.x,z+r.y,c.x+c.w,c.y,n,x,_.x,u.y,g,w),bf(p,h.x,h.y,a.x,z+a.y,c.x,c.y+c.h,n,x,u.x,_.y,g,w),bf(p,h.x,h.y,l.x,z+l.y,c.x+c.w,c.y+c.h,n,x,_.x,_.y,g,w),xf(e.dynamicLayoutVertexArray,h,v),d.emplaceBack(S,S+2,S+1),d.emplaceBack(S+1,S+2,S+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(b[0]),t!==i.length-1&&M===i[t+1].sectionIndex||e.programConfigurations.populatePaintArrays(p.length,o,o.index,{imagePositions:{},canonical:f,formattedSection:null==y?void 0:y[M]})}e.placedSymbolArray.emplaceBack(h.x,h.y,_,this.glyphOffsetArray.length-_,g,l,c,h.segment,n?n[0]:0,n?n[1]:0,s[0],s[1],a,0,!1,0,u)}_addCollisionDebugVertex(t,e,i,n,s,r){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,n,s,Math.round(r.x),Math.round(r.y))}addCollisionDebugVertices(t,e,n,s,r,o,a){const h=r.segments.prepareSegment(4,r.layoutVertexArray,r.indexArray),l=h.vertexLength,c=r.layoutVertexArray,u=r.collisionVertexArray,f=a.anchorX,d=a.anchorY;this._addCollisionDebugVertex(c,u,o,f,d,new i(t,e)),this._addCollisionDebugVertex(c,u,o,f,d,new i(n,e)),this._addCollisionDebugVertex(c,u,o,f,d,new i(n,s)),this._addCollisionDebugVertex(c,u,o,f,d,new i(t,s)),h.vertexLength+=4;const p=r.indexArray;p.emplaceBack(l,l+1),p.emplaceBack(l+1,l+2),p.emplaceBack(l+2,l+3),p.emplaceBack(l+3,l),h.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,n){for(let s=t;s<e;s++){const t=this.collisionBoxArray.get(s);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,n?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new zf(ia,xu.members,ra),this.iconCollisionBox=new zf(ia,xu.members,ra);for(let t=0;t<this.symbolInstances.length;t++){const e=this.symbolInstances.get(t);this.addDebugCollisionBoxes(e.textBoxStartIndex,e.textBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.verticalTextBoxStartIndex,e.verticalTextBoxEndIndex,e,!0),this.addDebugCollisionBoxes(e.iconBoxStartIndex,e.iconBoxEndIndex,e,!1),this.addDebugCollisionBoxes(e.verticalIconBoxStartIndex,e.verticalIconBoxEndIndex,e,!1)}}_deserializeCollisionBoxesForSymbol(t,e,i,n,s,r,o,a,h){const l={};for(let n=e;n<i;n++){const e=t.get(n);l.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},l.textFeatureIndex=e.featureIndex;break}for(let e=n;e<s;e++){const i=t.get(e);l.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},l.verticalTextFeatureIndex=i.featureIndex;break}for(let e=r;e<o;e++){const i=t.get(e);l.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},l.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<h;e++){const i=t.get(e);l.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},l.verticalIconFeatureIndex=i.featureIndex;break}return l}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){const i=this.symbolInstances.get(e);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,i.textBoxStartIndex,i.textBoxEndIndex,i.verticalTextBoxStartIndex,i.verticalTextBoxEndIndex,i.iconBoxStartIndex,i.iconBoxEndIndex,i.verticalIconBoxStartIndex,i.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,e){const i=t.placedSymbolArray.get(e),n=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<n;e+=4)t.indexArray.emplaceBack(e,e+2,e+1),t.indexArray.emplaceBack(e+1,e+2,e+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&void 0!==this.symbolInstanceIndexes)return this.symbolInstanceIndexes;const e=Math.sin(t),i=Math.cos(t),n=[],s=[],r=[];for(let t=0;t<this.symbolInstances.length;++t){r.push(t);const o=this.symbolInstances.get(t);n.push(0|Math.round(e*o.anchorX+i*o.anchorY)),s.push(o.featureIndex)}return r.sort(((t,e)=>n[t]-n[e]||s[e]-s[t])),r}addToSortKeyRanges(t,e){const i=this.sortKeyRanges[this.sortKeyRanges.length-1];(null==i?void 0:i.sortKey)===e?i.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:e,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const t of this.symbolInstanceIndexes){const e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);const i=[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex];for(let t=0;t<i.length;t++){const e=i[t];e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}e.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,e.verticalPlacedTextSymbolIndex),e.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.placedIconSymbolIndex),e.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,e.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let Ef,Af;dr("SymbolBucket",Tf,{omit:["layers","collisionBoxArray","features","compareText"]}),Tf.MAX_GLYPHS=65535,Tf.addDynamicAttributes=xf;var Pf={get paint(){return Af=Af||new Xr({"icon-opacity":new Zr(bt.paint_symbol["icon-opacity"]),"icon-color":new Zr(bt.paint_symbol["icon-color"]),"icon-halo-color":new Zr(bt.paint_symbol["icon-halo-color"]),"icon-halo-width":new Zr(bt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Zr(bt.paint_symbol["icon-halo-blur"]),"icon-translate":new qr(bt.paint_symbol["icon-translate"]),"icon-translate-anchor":new qr(bt.paint_symbol["icon-translate-anchor"]),"text-opacity":new Zr(bt.paint_symbol["text-opacity"]),"text-color":new Zr(bt.paint_symbol["text-color"],{runtimeType:Nt,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new Zr(bt.paint_symbol["text-halo-color"]),"text-halo-width":new Zr(bt.paint_symbol["text-halo-width"]),"text-halo-blur":new Zr(bt.paint_symbol["text-halo-blur"]),"text-translate":new qr(bt.paint_symbol["text-translate"]),"text-translate-anchor":new qr(bt.paint_symbol["text-translate-anchor"])})},get layout(){return Ef=Ef||new Xr({"symbol-placement":new qr(bt.layout_symbol["symbol-placement"]),"symbol-spacing":new qr(bt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new qr(bt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Zr(bt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new qr(bt.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new qr(bt.layout_symbol["icon-allow-overlap"]),"icon-overlap":new qr(bt.layout_symbol["icon-overlap"]),"icon-ignore-placement":new qr(bt.layout_symbol["icon-ignore-placement"]),"icon-optional":new qr(bt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new qr(bt.layout_symbol["icon-rotation-alignment"]),"icon-size":new Zr(bt.layout_symbol["icon-size"]),"icon-text-fit":new qr(bt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new qr(bt.layout_symbol["icon-text-fit-padding"]),"icon-image":new Zr(bt.layout_symbol["icon-image"]),"icon-rotate":new Zr(bt.layout_symbol["icon-rotate"]),"icon-padding":new Zr(bt.layout_symbol["icon-padding"]),"icon-keep-upright":new qr(bt.layout_symbol["icon-keep-upright"]),"icon-offset":new Zr(bt.layout_symbol["icon-offset"]),"icon-anchor":new Zr(bt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new qr(bt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new qr(bt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new qr(bt.layout_symbol["text-rotation-alignment"]),"text-field":new Zr(bt.layout_symbol["text-field"]),"text-font":new Zr(bt.layout_symbol["text-font"]),"text-size":new Zr(bt.layout_symbol["text-size"]),"text-max-width":new Zr(bt.layout_symbol["text-max-width"]),"text-line-height":new qr(bt.layout_symbol["text-line-height"]),"text-letter-spacing":new Zr(bt.layout_symbol["text-letter-spacing"]),"text-justify":new Zr(bt.layout_symbol["text-justify"]),"text-radial-offset":new Zr(bt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new qr(bt.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new Zr(bt.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new Zr(bt.layout_symbol["text-anchor"]),"text-max-angle":new qr(bt.layout_symbol["text-max-angle"]),"text-writing-mode":new qr(bt.layout_symbol["text-writing-mode"]),"text-rotate":new Zr(bt.layout_symbol["text-rotate"]),"text-padding":new qr(bt.layout_symbol["text-padding"]),"text-keep-upright":new qr(bt.layout_symbol["text-keep-upright"]),"text-transform":new Zr(bt.layout_symbol["text-transform"]),"text-offset":new Zr(bt.layout_symbol["text-offset"]),"text-allow-overlap":new qr(bt.layout_symbol["text-allow-overlap"]),"text-overlap":new qr(bt.layout_symbol["text-overlap"]),"text-ignore-placement":new qr(bt.layout_symbol["text-ignore-placement"]),"text-optional":new qr(bt.layout_symbol["text-optional"])})}};class Cf{constructor(t){if(void 0===t.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:jt,this.defaultValue=t}evaluate(t){if(t.formattedSection){const e=this.defaultValue.property.overrides;if(null==e?void 0:e.hasOverride(t.formattedSection))return e.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}dr("FormatSectionOverride",Cf,{omit:["defaultValue"]});class Df extends Qr{constructor(t,e){super(t,Pf,e)}recalculate(t,e){if(super.recalculate(t,e),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const t=this.layout.get("text-writing-mode");if(t){const e=[];for(const i of t)e.includes(i)||e.push(i);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(t,e,i,n){const s=this.layout.get(t).evaluate(e,{},i,n),r=this._unevaluatedLayout._values[t];return r.isDataDriven()||ns(r.value)||!s?s:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,s)}createBucket(t){return new Tf(t)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const t of Pf.paint.overridableProperties){if(!Df.hasPaintOverride(this.layout,t))continue;const e=this.paint.get(t),i=new Cf(e),n=new is(i,e.property.specification);let s=null;s="constant"===e.value.kind||"source"===e.value.kind?new rs("source",n):new os("composite",n,e.value.zoomStops),this.paint._values[t]=new Gr(e.property,s,e.parameters)}}_handleOverridablePaintPropertyUpdate(t,e,i){return!(!this.layout||e.isDataDriven()||i.isDataDriven())&&Df.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,e){const i=t.get("text-field"),n=Pf.paint.properties[e];let s=!1;const r=t=>{var e;for(const i of t)if(null===(e=n.overrides)||void 0===e?void 0:e.hasOverride(i))return void(s=!0)};if("constant"===i.value.kind&&i.value.value instanceof Ie)r(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const t=e=>{s||(e instanceof Ze&&Ve(e.value)===Zt?r(e.value.sections):e instanceof Pi?r(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return s}}let Ff;var If={get paint(){return Ff=Ff||new Xr({"background-color":new qr(bt.paint_background["background-color"]),"background-pattern":new Hr(bt.paint_background["background-pattern"]),"background-opacity":new qr(bt.paint_background["background-opacity"])})}};class kf extends Qr{constructor(t,e){super(t,If,e)}}class $f extends Qr{constructor(t,e){super(t,{},e),this.onAdd=t=>{this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)},this.onRemove=t=>{this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)},this.implementation=t}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Of{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){var t;this._triggered||(this._triggered=!0,null===(t=this._channel)||void 0===t||t.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const jf={once:!0},Rf=6371008.8;class Lf{constructor(t,e){if(isNaN(t)||isNaN(e))throw new Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Lf(R(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const e=Math.PI/180,i=this.lat*e,n=t.lat*e,s=Math.sin(i)*Math.sin(n)+Math.cos(i)*Math.cos(n)*Math.cos((t.lng-this.lng)*e);return Rf*Math.acos(Math.min(s,1))}static convert(t){if(t instanceof Lf)return t;if(Array.isArray(t)&&(2===t.length||3===t.length))return new Lf(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&"object"==typeof t&&null!==t)return new Lf(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}const Bf=2*Math.PI*Rf;function Nf(t){return Bf*Math.cos(t*Math.PI/180)}function Uf(t){return(180+t)/360}function Gf(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Vf(t,e){return t/Nf(e)}function qf(t){return 360*t-180}function Zf(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Wf(t,e){return t*Nf(Zf(e))}class Hf{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(t,e=0){const i=Lf.convert(t);return new Hf(Uf(i.lng),Gf(i.lat),Vf(e,i.lat))}toLngLat(){return new Lf(qf(this.x),Zf(this.y))}toAltitude(){return Wf(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Bf*(t=Zf(this.y),1/Math.cos(t*Math.PI/180));var t}}function Yf(t,e,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[t*n-2*Math.PI*6378137/2,e*n-2*Math.PI*6378137/2]}class Xf{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=Math.pow(2,t)||e<0||e>=Math.pow(2,t))}(t,e,i))throw new Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${Math.pow(2,t)}, 0<=y<${Math.pow(2,t)} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=Qf(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){const n=(r=this.y,o=this.z,a=Yf(256*(s=this.x),256*(r=Math.pow(2,o)-r-1),o),h=Yf(256*(s+1),256*(r+1),o),a[0]+","+a[1]+","+h[0]+","+h[1]);var s,r,o,a,h;const l=function(t,e,i){let n="";for(let s=t;s>0;s--){const t=1<<s-1;n+=(e&t?1:0)+(i&t?2:0)}return n}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace(/{prefix}/g,(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String("tms"===i?Math.pow(2,this.z)-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,l).replace(/{bbox-epsg-3857}/g,n)}isChildOf(t){const e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){const e=Math.pow(2,this.z);return new i((t.x*e-this.x)*P,(t.y*e-this.y)*P)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Jf{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Qf(t,e.z,e.z,e.x,e.y)}}class Kf{constructor(t,e,i,n,s){if(this.terrainRttPosMatrix32f=null,t<i)throw new Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Xf(i,+n,+s),this.key=Qf(e,t,i,n,s)}clone(){return new Kf(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const e=this.canonical.z-t;return t>this.canonical.z?new Kf(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Kf(t,this.wrap,t,this.canonical.x>>e,this.canonical.y>>e)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,e){if(t>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-t;return t>this.canonical.z?Qf(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Qf(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap)return!1;if(this.overscaledZ-t.overscaledZ<=0)return!1;if(0===t.overscaledZ)return this.overscaledZ>0;const e=this.canonical.z-t.canonical.z;return!(e<0)&&t.canonical.x===this.canonical.x>>e&&t.canonical.y===this.canonical.y>>e}children(t){if(this.overscaledZ>=t)return[new Kf(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const e=this.canonical.z+1,i=2*this.canonical.x,n=2*this.canonical.y;return[new Kf(e,this.wrap,e,i,n),new Kf(e,this.wrap,e,i+1,n),new Kf(e,this.wrap,e,i,n+1),new Kf(e,this.wrap,e,i+1,n+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new Kf(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new Kf(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Jf(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Hf(t.x-this.wrap,t.y))}normalizeCoordinates(t,e,i=8192){if(t>=0&&t<i&&e>=0&&e<i)return{tileID:this,x:t,y:e};const n=Math.floor(t/i),s=Math.floor(e/i),r=t-n*i,o=e-s*i,a=this.canonical.z,h=1<<a,l=this.canonical.y+s;if(l<0||l>=h)return null;let c=this.canonical.x+n,u=this.wrap;return c<0?(u-=Math.ceil(-c/h),c=(c%h+h)%h):c>=h&&(u+=Math.floor(c/h),c%=h),{tileID:new Kf(this.overscaledZ,u,a,c,l),x:r,y:o}}}function Qf(t,e,i,n,s){(t*=2)<0&&(t=-1*t-1);const r=1<<i;return(r*r*t+r*s+n).toString(36)+i.toString(36)+e.toString(36)}dr("CanonicalTileID",Xf),dr("OverscaledTileID",Kf,{omit:["terrainRttPosMatrix32f"]});class td{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(t){return this.minX=Math.min(this.minX,t.x),this.minY=Math.min(this.minY,t.y),this.maxX=Math.max(this.maxX,t.x),this.maxY=Math.max(this.maxY,t.y),this}expandBy(t){return this.minX-=t,this.minY-=t,this.maxX+=t,this.maxY+=t,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(t){return this.expandBy(-t)}map(t){const e=new td;return e.extend(t(new i(this.minX,this.minY))),e.extend(t(new i(this.maxX,this.minY))),e.extend(t(new i(this.minX,this.maxY))),e.extend(t(new i(this.maxX,this.maxY))),e}static fromPoints(t){const e=new td;for(const i of t)e.extend(i);return e}contains(t){return t.x>=this.minX&&t.x<=this.maxX&&t.y>=this.minY&&t.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(t){return!this.empty()&&!t.empty()&&t.minX>=this.minX&&t.maxX<=this.maxX&&t.minY>=this.minY&&t.maxY<=this.maxY}intersects(t){return!this.empty()&&!t.empty()&&t.minX<=this.maxX&&t.maxX>=this.minX&&t.minY<=this.maxY&&t.maxY>=this.minY}}class ed{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){const i=t[e];this._stringToNumber[i]=e,this._numberToString[e]=i}}encode(t){return this._stringToNumber[t]}decode(t){if(t>=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}}class id{constructor(t,e,i,n,s){this.type="Feature",this._vectorTileFeature=t,this._x=i,this._y=n,this._z=e,this.properties=t.properties,this.id=s}projectPoint(t,e,i,n){return[360*(t.x+e)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+i)/n)*Math.PI))-90]}projectLine(t,e,i,n){return t.map((t=>this.projectPoint(t,e,i,n)))}get geometry(){if(this._geometry)return this._geometry;const t=this._vectorTileFeature,e=t.extent*Math.pow(2,this._z),i=t.extent*this._x,n=t.extent*this._y,s=t.loadGeometry();switch(t.type){case 1:{const t=[];for(const e of s)t.push(e[0]);const r=this.projectLine(t,i,n,e);this._geometry=1===t.length?{type:"Point",coordinates:r[0]}:{type:"MultiPoint",coordinates:r};break}case 2:{const t=s.map((t=>this.projectLine(t,i,n,e)));this._geometry=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};break}case 3:{const t=Ol(s),r=[];for(const s of t)r.push(s.map((t=>this.projectLine(t,i,n,e))));this._geometry=1===r.length?{type:"Polygon",coordinates:r[0]}:{type:"MultiPolygon",coordinates:r};break}default:throw new Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={geometry:this.geometry};for(const e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"_x"!==e&&"_y"!==e&&"_z"!==e&&(t[e]=this[e]);return t}}class nd{constructor(t,e,i){this._name=t,this.dataBuffer=e,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(t){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(t)?null:this.getValueFromBuffer(t)}has(t){return this.nullabilityBuffer?.get(t)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class sd extends nd{}class rd extends sd{getValueFromBuffer(t){return this.dataBuffer[t]}}class od extends sd{getValueFromBuffer(t){return this.dataBuffer[t]}}class ad extends nd{constructor(t,e,i,n){super(t,e,n),this.delta=i}}class hd extends ad{constructor(t,e,i,n){super(t,Int32Array.of(e),i,n)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}}class ld extends nd{constructor(t,e,i,n){super(t,n?Int32Array.of(e):Uint32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}}class cd{constructor(t,e,i,n,s=4096){this._name=t,this._geometryVector=e,this._idVector=i,this._propertyVectors=n,this._extent=s}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(t){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map((t=>[t.name,t])))),this.propertyVectorsMap.get(t)}get numFeatures(){return this.geometryVector.numGeometries}get extent(){return this._extent}getFeatures(){const t=[],e=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let n;if(this.idVector){const t=this.idVector.getValue(i);n=this.containsMaxSafeIntegerValues(this.idVector)&&null!==t?Number(t):t}const s={coordinates:e[i],type:this.geometryVector.geometryType(i)},r={};for(const t of this.propertyVectors){if(!t)continue;const e=t.name,n=t.getValue(i);null!==n&&(r[e]=n)}t.push({id:n,geometry:s,properties:r})}return t}containsMaxSafeIntegerValues(t){return t instanceof rd||t instanceof ld||t instanceof hd||t instanceof od}}class ud{constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}increment(){return this.value++}add(t){this.value+=t}}var fd,dd;!function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON",t.PDE="PDE"}(fd||(fd={})),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT",t.ALP="ALP"}(dd||(dd={}));const pd=new Uint32Array(33);pd[0]=0;for(let t=1;t<=32;t++)pd[t]=32===t?4294967295:4294967295>>>32-t;const md=pd,_d=256;function gd(t,e){return t-t%e}function vd(t){const e=t>>>0;return((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const yd=function(){if(!Number.isFinite(65536))return 65536;const t=gd(Math.floor(65536),_d);return 0===t?_d:t}(),wd=3*yd/_d+yd|0;function bd(){const t=new Uint8Array(wd);return{dataToBePacked:new Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function xd(t,e,i,n,s){switch(s){case 1:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0;i[s++]=e>>>0&1,i[s++]=e>>>1&1,i[s++]=e>>>2&1,i[s++]=e>>>3&1,i[s++]=e>>>4&1,i[s++]=e>>>5&1,i[s++]=e>>>6&1,i[s++]=e>>>7&1,i[s++]=e>>>8&1,i[s++]=e>>>9&1,i[s++]=e>>>10&1,i[s++]=e>>>11&1,i[s++]=e>>>12&1,i[s++]=e>>>13&1,i[s++]=e>>>14&1,i[s++]=e>>>15&1,i[s++]=e>>>16&1,i[s++]=e>>>17&1,i[s++]=e>>>18&1,i[s++]=e>>>19&1,i[s++]=e>>>20&1,i[s++]=e>>>21&1,i[s++]=e>>>22&1,i[s++]=e>>>23&1,i[s++]=e>>>24&1,i[s++]=e>>>25&1,i[s++]=e>>>26&1,i[s++]=e>>>27&1,i[s++]=e>>>28&1,i[s++]=e>>>29&1,i[s++]=e>>>30&1,i[s++]=e>>>31&1}}(t,e,i,n);break;case 2:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0;i[s++]=e>>>0&3,i[s++]=e>>>2&3,i[s++]=e>>>4&3,i[s++]=e>>>6&3,i[s++]=e>>>8&3,i[s++]=e>>>10&3,i[s++]=e>>>12&3,i[s++]=e>>>14&3,i[s++]=e>>>16&3,i[s++]=e>>>18&3,i[s++]=e>>>20&3,i[s++]=e>>>22&3,i[s++]=e>>>24&3,i[s++]=e>>>26&3,i[s++]=e>>>28&3,i[s++]=e>>>30&3,i[s++]=n>>>0&3,i[s++]=n>>>2&3,i[s++]=n>>>4&3,i[s++]=n>>>6&3,i[s++]=n>>>8&3,i[s++]=n>>>10&3,i[s++]=n>>>12&3,i[s++]=n>>>14&3,i[s++]=n>>>16&3,i[s++]=n>>>18&3,i[s++]=n>>>20&3,i[s++]=n>>>22&3,i[s++]=n>>>24&3,i[s++]=n>>>26&3,i[s++]=n>>>28&3,i[s++]=n>>>30&3}}(t,e,i,n);break;case 3:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0;i[s++]=e>>>0&7,i[s++]=e>>>3&7,i[s++]=e>>>6&7,i[s++]=e>>>9&7,i[s++]=e>>>12&7,i[s++]=e>>>15&7,i[s++]=e>>>18&7,i[s++]=e>>>21&7,i[s++]=e>>>24&7,i[s++]=e>>>27&7,i[s++]=7&(e>>>30|(1&n)<<2),i[s++]=n>>>1&7,i[s++]=n>>>4&7,i[s++]=n>>>7&7,i[s++]=n>>>10&7,i[s++]=n>>>13&7,i[s++]=n>>>16&7,i[s++]=n>>>19&7,i[s++]=n>>>22&7,i[s++]=n>>>25&7,i[s++]=n>>>28&7,i[s++]=7&(n>>>31|(3&o)<<1),i[s++]=o>>>2&7,i[s++]=o>>>5&7,i[s++]=o>>>8&7,i[s++]=o>>>11&7,i[s++]=o>>>14&7,i[s++]=o>>>17&7,i[s++]=o>>>20&7,i[s++]=o>>>23&7,i[s++]=o>>>26&7,i[s++]=o>>>29&7}}(t,e,i,n);break;case 4:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0,a=t[r++]>>>0;i[s++]=e>>>0&15,i[s++]=e>>>4&15,i[s++]=e>>>8&15,i[s++]=e>>>12&15,i[s++]=e>>>16&15,i[s++]=e>>>20&15,i[s++]=e>>>24&15,i[s++]=e>>>28&15,i[s++]=n>>>0&15,i[s++]=n>>>4&15,i[s++]=n>>>8&15,i[s++]=n>>>12&15,i[s++]=n>>>16&15,i[s++]=n>>>20&15,i[s++]=n>>>24&15,i[s++]=n>>>28&15,i[s++]=o>>>0&15,i[s++]=o>>>4&15,i[s++]=o>>>8&15,i[s++]=o>>>12&15,i[s++]=o>>>16&15,i[s++]=o>>>20&15,i[s++]=o>>>24&15,i[s++]=o>>>28&15,i[s++]=a>>>0&15,i[s++]=a>>>4&15,i[s++]=a>>>8&15,i[s++]=a>>>12&15,i[s++]=a>>>16&15,i[s++]=a>>>20&15,i[s++]=a>>>24&15,i[s++]=a>>>28&15}}(t,e,i,n);break;case 5:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0,a=t[r++]>>>0,h=t[r++]>>>0;i[s++]=e>>>0&31,i[s++]=e>>>5&31,i[s++]=e>>>10&31,i[s++]=e>>>15&31,i[s++]=e>>>20&31,i[s++]=e>>>25&31,i[s++]=31&(e>>>30|(7&n)<<2),i[s++]=n>>>3&31,i[s++]=n>>>8&31,i[s++]=n>>>13&31,i[s++]=n>>>18&31,i[s++]=n>>>23&31,i[s++]=31&(n>>>28|(1&o)<<4),i[s++]=o>>>1&31,i[s++]=o>>>6&31,i[s++]=o>>>11&31,i[s++]=o>>>16&31,i[s++]=o>>>21&31,i[s++]=o>>>26&31,i[s++]=31&(o>>>31|(15&a)<<1),i[s++]=a>>>4&31,i[s++]=a>>>9&31,i[s++]=a>>>14&31,i[s++]=a>>>19&31,i[s++]=a>>>24&31,i[s++]=31&(a>>>29|(3&h)<<3),i[s++]=h>>>2&31,i[s++]=h>>>7&31,i[s++]=h>>>12&31,i[s++]=h>>>17&31,i[s++]=h>>>22&31,i[s++]=h>>>27&31}}(t,e,i,n);break;case 6:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0,a=t[r++]>>>0,h=t[r++]>>>0,l=t[r++]>>>0;i[s++]=e>>>0&63,i[s++]=e>>>6&63,i[s++]=e>>>12&63,i[s++]=e>>>18&63,i[s++]=e>>>24&63,i[s++]=63&(e>>>30|(15&n)<<2),i[s++]=n>>>4&63,i[s++]=n>>>10&63,i[s++]=n>>>16&63,i[s++]=n>>>22&63,i[s++]=63&(n>>>28|(3&o)<<4),i[s++]=o>>>2&63,i[s++]=o>>>8&63,i[s++]=o>>>14&63,i[s++]=o>>>20&63,i[s++]=o>>>26&63,i[s++]=a>>>0&63,i[s++]=a>>>6&63,i[s++]=a>>>12&63,i[s++]=a>>>18&63,i[s++]=a>>>24&63,i[s++]=63&(a>>>30|(15&h)<<2),i[s++]=h>>>4&63,i[s++]=h>>>10&63,i[s++]=h>>>16&63,i[s++]=h>>>22&63,i[s++]=63&(h>>>28|(3&l)<<4),i[s++]=l>>>2&63,i[s++]=l>>>8&63,i[s++]=l>>>14&63,i[s++]=l>>>20&63,i[s++]=l>>>26&63}}(t,e,i,n);break;case 7:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0,a=t[r++]>>>0,h=t[r++]>>>0,l=t[r++]>>>0,c=t[r++]>>>0;i[s++]=e>>>0&127,i[s++]=e>>>7&127,i[s++]=e>>>14&127,i[s++]=e>>>21&127,i[s++]=127&(e>>>28|(7&n)<<4),i[s++]=n>>>3&127,i[s++]=n>>>10&127,i[s++]=n>>>17&127,i[s++]=n>>>24&127,i[s++]=127&(n>>>31|(63&o)<<1),i[s++]=o>>>6&127,i[s++]=o>>>13&127,i[s++]=o>>>20&127,i[s++]=127&(o>>>27|(3&a)<<5),i[s++]=a>>>2&127,i[s++]=a>>>9&127,i[s++]=a>>>16&127,i[s++]=a>>>23&127,i[s++]=127&(a>>>30|(31&h)<<2),i[s++]=h>>>5&127,i[s++]=h>>>12&127,i[s++]=h>>>19&127,i[s++]=127&(h>>>26|(1&l)<<6),i[s++]=l>>>1&127,i[s++]=l>>>8&127,i[s++]=l>>>15&127,i[s++]=l>>>22&127,i[s++]=127&(l>>>29|(15&c)<<3),i[s++]=c>>>4&127,i[s++]=c>>>11&127,i[s++]=c>>>18&127,i[s++]=c>>>25&127}}(t,e,i,n);break;case 8:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<8;e++){const e=t[r++]>>>0,n=t[r++]>>>0,o=t[r++]>>>0,a=t[r++]>>>0,h=t[r++]>>>0,l=t[r++]>>>0,c=t[r++]>>>0,u=t[r++]>>>0;i[s++]=e>>>0&255,i[s++]=e>>>8&255,i[s++]=e>>>16&255,i[s++]=e>>>24&255,i[s++]=n>>>0&255,i[s++]=n>>>8&255,i[s++]=n>>>16&255,i[s++]=n>>>24&255,i[s++]=o>>>0&255,i[s++]=o>>>8&255,i[s++]=o>>>16&255,i[s++]=o>>>24&255,i[s++]=a>>>0&255,i[s++]=a>>>8&255,i[s++]=a>>>16&255,i[s++]=a>>>24&255,i[s++]=h>>>0&255,i[s++]=h>>>8&255,i[s++]=h>>>16&255,i[s++]=h>>>24&255,i[s++]=l>>>0&255,i[s++]=l>>>8&255,i[s++]=l>>>16&255,i[s++]=l>>>24&255,i[s++]=c>>>0&255,i[s++]=c>>>8&255,i[s++]=c>>>16&255,i[s++]=c>>>24&255,i[s++]=u>>>0&255,i[s++]=u>>>8&255,i[s++]=u>>>16&255,i[s++]=u>>>24&255}}(t,e,i,n);break;case 16:!function(t,e,i,n){let s=n,r=e;for(let e=0;e<128;e++){const e=t[r++]>>>0;i[s++]=65535&e,i[s++]=e>>>16&65535}}(t,e,i,n);break;default:!function(t,e,i,n,s){const r=md[s]>>>0;let o=e,a=0,h=t[o]>>>0,l=n;for(let e=0;e<8;e++){for(let e=0;e<32;e++)if(a+s<=32)i[l+e]=h>>>a&r,a+=s,32===a&&(a=0,o++,31!==e&&(h=t[o]>>>0));else{const n=32-a,c=h>>>a;o++,h=t[o]>>>0;const u=s-n;i[l+e]=(c|(h&-1>>>32-u>>>0)<<n)&r,a=u}l+=32,a=0,e<7&&(h=t[o]>>>0)}}(t,e,i,n,s)}return e+(s<<3)|0}function Md(t,e,i,n){if(i+2>e)throw new Error(`FastPFOR decode: byteContainer underflow at block=${n} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${e})`);const s=t[i++],r=t[i++];if(s>32)throw new Error(`FastPFOR decode: invalid bitWidth=${s} at block=${n} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:s,exceptionCount:r,bytePosIn:i}}function Sd(t,e,i,n,s,r,o,a,h){const{maxBits:l,exceptionBitWidth:c,bytePosIn:u}=function(t,e,i,n,s,r){if(i+1>e)throw new Error(`FastPFOR decode: exception header underflow at block=${r} (need 1 byte for maxBits, bytePos=${i}, byteSize=${e})`);const o=t[i++];if(o<n||o>32)throw new Error(`FastPFOR decode: invalid maxBits=${o} at block=${r} (bitWidth=${n}, expected ${n}..32)`);const a=o-n|0;if(a<1||a>32)throw new Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${r} (bitWidth=${n}, maxBits=${o})`);if(i+s>e)throw new Error(`FastPFOR decode: exception positions underflow at block=${r} (need=${s}, have=${e-i})`);return{maxBits:o,exceptionBitWidth:a,bytePosIn:i}}(s,r,o,i,n,h);if(o=u,1===c){const r=1<<i;for(let i=0;i<n;i=i+1|0)t[s[o++]+e|0]|=r;return o}const f=a.dataToBePacked[c];if(!f)throw new Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${c} (bitWidth=${i}, maxBits=${l}) at block ${h}`);const d=a.dataPointers;let p=0|d[c];const m=0|a.exceptionSizes[c];if(p+n>m)throw new Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${c} (ptr=${p}, need ${n}, size=${m}) at block ${h}`);for(let r=0;r<n;r=r+1|0){const n=s[o++],r=0|f[p++];t[n+e|0]|=r<<i}return d[c]=p,o}function zd(t,e,i,n,s,r){const o=0|i,a=0|t[o];if(a<=0||o+a>t.length-1)throw new Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);const h=o+1|0,l=o+a|0,c=t[l]>>>0,u=c+3>>>2,f=l+1,d=f+u;if(d>=t.length)throw new Error(`FastPFOR decode: invalid byteSize=${c} (metaInts=${u}, pageStart=${o}, packedEnd=${l}, byteContainerStart=${f}) causes bitmapPos=${d} out of bounds (encoded.length=${t.length})`);const p=function(t,e,i,n){n.byteContainer.length<i&&(n.byteContainer=new Uint8Array(2*i),n.byteContainerI32=void 0);const s=n.byteContainer,r=i>>>2;if(3&s.byteOffset)for(let i=0;i<r;i=i+1|0){const n=0|t[e+i|0],r=i<<2;s[r]=255&n,s[r+1|0]=n>>>8&255,s[r+2|0]=n>>>16&255,s[r+3|0]=n>>>24&255}else{let i=n.byteContainerI32;(!i||i.buffer!==s.buffer||i.byteOffset!==s.byteOffset||i.length<r)&&(i=n.byteContainerI32=new Int32Array(s.buffer,s.byteOffset,s.byteLength>>>2)),i.set(t.subarray(e,e+r))}const o=3&i;if(o>0){const i=0|t[e+r|0],n=r<<2;for(let t=0;t<o;t=t+1|0)s[n+t|0]=i>>>(t<<3)&255}return s}(t,f,c,r),m=c,_=function(t,e,i){const n=0|t[e++],s=i.dataToBePacked;for(let r=2;r<=32;r=r+1|0){if(!(n>>>r-1&1))continue;if(e>=t.length)throw new Error(`FastPFOR decode: truncated exception stream header (bitWidth=${r}, streamWordIndex=${e}, needWords=1, availableWords=${t.length-e}, encodedWords=${t.length})`);const o=t[e++]>>>0,a=gd(o+31,32),h=o*r+31>>>5;if(e+h>t.length)throw new Error(`FastPFOR decode: truncated exception stream (bitWidth=${r}, size=${o}, streamWordIndex=${e}, needWords=${h}, availableWords=${t.length-e}, encodedWords=${t.length})`);let l=s[r];(!l||l.length<a)&&(l=s[r]=new Uint32Array(a));let c=0;for(;c<o;c=c+32|0)Td(t,e,l,c,r),e=e+r|0;e=e-((c-o|0)*r>>>5)|0,i.exceptionSizes[r]=o}return e}(t,d,r);return r.dataPointers.fill(0),function(t,e,i,n,s,r,o,a,h,l){let c=0|i,u=0;for(let e=0;e<o;e=e+1|0){const i=Md(a,h,u,e);u=i.bytePosIn;const n=i.bitWidth,o=i.exceptionCount,f=r+e*_d|0;switch(n){case 0:s.fill(0,f,f+_d);break;case 32:for(let e=0;e<_d;e=e+1|0)s[f+e|0]=0|t[c+e|0];c=c+_d|0;break;default:c=xd(t,c,s,f,n)}o>0&&(u=Sd(s,f,n,o,a,h,u,l,e))}if(c!==n)throw new Error(`FastPFOR decode: packed region mismatch (pageStart=${e}, packedStart=${i}, consumedPackedEnd=${c}, expectedPackedEnd=${n}, packedWords=${n-i}, encoded.length=${t.length})`)}(t,o,h,l,e,0|n,s/_d|0,p,m,r),_}function Td(t,e,i,n,s){switch(s){case 2:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0;i[s++]=r>>>0&3,i[s++]=r>>>2&3,i[s++]=r>>>4&3,i[s++]=r>>>6&3,i[s++]=r>>>8&3,i[s++]=r>>>10&3,i[s++]=r>>>12&3,i[s++]=r>>>14&3,i[s++]=r>>>16&3,i[s++]=r>>>18&3,i[s++]=r>>>20&3,i[s++]=r>>>22&3,i[s++]=r>>>24&3,i[s++]=r>>>26&3,i[s++]=r>>>28&3,i[s++]=r>>>30&3,i[s++]=o>>>0&3,i[s++]=o>>>2&3,i[s++]=o>>>4&3,i[s++]=o>>>6&3,i[s++]=o>>>8&3,i[s++]=o>>>10&3,i[s++]=o>>>12&3,i[s++]=o>>>14&3,i[s++]=o>>>16&3,i[s++]=o>>>18&3,i[s++]=o>>>20&3,i[s++]=o>>>22&3,i[s++]=o>>>24&3,i[s++]=o>>>26&3,i[s++]=o>>>28&3,i[s]=o>>>30&3}(t,e,i,n);case 3:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0;i[s++]=r>>>0&7,i[s++]=r>>>3&7,i[s++]=r>>>6&7,i[s++]=r>>>9&7,i[s++]=r>>>12&7,i[s++]=r>>>15&7,i[s++]=r>>>18&7,i[s++]=r>>>21&7,i[s++]=r>>>24&7,i[s++]=r>>>27&7,i[s++]=7&(r>>>30|(1&o)<<2),i[s++]=o>>>1&7,i[s++]=o>>>4&7,i[s++]=o>>>7&7,i[s++]=o>>>10&7,i[s++]=o>>>13&7,i[s++]=o>>>16&7,i[s++]=o>>>19&7,i[s++]=o>>>22&7,i[s++]=o>>>25&7,i[s++]=o>>>28&7,i[s++]=7&(o>>>31|(3&a)<<1),i[s++]=a>>>2&7,i[s++]=a>>>5&7,i[s++]=a>>>8&7,i[s++]=a>>>11&7,i[s++]=a>>>14&7,i[s++]=a>>>17&7,i[s++]=a>>>20&7,i[s++]=a>>>23&7,i[s++]=a>>>26&7,i[s]=a>>>29&7}(t,e,i,n);case 4:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0;i[s++]=r>>>0&15,i[s++]=r>>>4&15,i[s++]=r>>>8&15,i[s++]=r>>>12&15,i[s++]=r>>>16&15,i[s++]=r>>>20&15,i[s++]=r>>>24&15,i[s++]=r>>>28&15,i[s++]=o>>>0&15,i[s++]=o>>>4&15,i[s++]=o>>>8&15,i[s++]=o>>>12&15,i[s++]=o>>>16&15,i[s++]=o>>>20&15,i[s++]=o>>>24&15,i[s++]=o>>>28&15,i[s++]=a>>>0&15,i[s++]=a>>>4&15,i[s++]=a>>>8&15,i[s++]=a>>>12&15,i[s++]=a>>>16&15,i[s++]=a>>>20&15,i[s++]=a>>>24&15,i[s++]=a>>>28&15,i[s++]=h>>>0&15,i[s++]=h>>>4&15,i[s++]=h>>>8&15,i[s++]=h>>>12&15,i[s++]=h>>>16&15,i[s++]=h>>>20&15,i[s++]=h>>>24&15,i[s]=h>>>28&15}(t,e,i,n);case 5:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0;i[s++]=r>>>0&31,i[s++]=r>>>5&31,i[s++]=r>>>10&31,i[s++]=r>>>15&31,i[s++]=r>>>20&31,i[s++]=r>>>25&31,i[s++]=31&(r>>>30|(7&o)<<2),i[s++]=o>>>3&31,i[s++]=o>>>8&31,i[s++]=o>>>13&31,i[s++]=o>>>18&31,i[s++]=o>>>23&31,i[s++]=31&(o>>>28|(1&a)<<4),i[s++]=a>>>1&31,i[s++]=a>>>6&31,i[s++]=a>>>11&31,i[s++]=a>>>16&31,i[s++]=a>>>21&31,i[s++]=a>>>26&31,i[s++]=31&(a>>>31|(15&h)<<1),i[s++]=h>>>4&31,i[s++]=h>>>9&31,i[s++]=h>>>14&31,i[s++]=h>>>19&31,i[s++]=h>>>24&31,i[s++]=31&(h>>>29|(3&l)<<3),i[s++]=l>>>2&31,i[s++]=l>>>7&31,i[s++]=l>>>12&31,i[s++]=l>>>17&31,i[s++]=l>>>22&31,i[s]=l>>>27&31}(t,e,i,n);case 6:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0;i[s++]=r>>>0&63,i[s++]=r>>>6&63,i[s++]=r>>>12&63,i[s++]=r>>>18&63,i[s++]=r>>>24&63,i[s++]=63&(r>>>30|(15&o)<<2),i[s++]=o>>>4&63,i[s++]=o>>>10&63,i[s++]=o>>>16&63,i[s++]=o>>>22&63,i[s++]=63&(o>>>28|(3&a)<<4),i[s++]=a>>>2&63,i[s++]=a>>>8&63,i[s++]=a>>>14&63,i[s++]=a>>>20&63,i[s++]=a>>>26&63,i[s++]=h>>>0&63,i[s++]=h>>>6&63,i[s++]=h>>>12&63,i[s++]=h>>>18&63,i[s++]=h>>>24&63,i[s++]=63&(h>>>30|(15&l)<<2),i[s++]=l>>>4&63,i[s++]=l>>>10&63,i[s++]=l>>>16&63,i[s++]=l>>>22&63,i[s++]=63&(l>>>28|(3&c)<<4),i[s++]=c>>>2&63,i[s++]=c>>>8&63,i[s++]=c>>>14&63,i[s++]=c>>>20&63,i[s]=c>>>26&63}(t,e,i,n);case 7:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0;i[s++]=r>>>0&127,i[s++]=r>>>7&127,i[s++]=r>>>14&127,i[s++]=r>>>21&127,i[s++]=127&(r>>>28|(7&o)<<4),i[s++]=o>>>3&127,i[s++]=o>>>10&127,i[s++]=o>>>17&127,i[s++]=o>>>24&127,i[s++]=127&(o>>>31|(63&a)<<1),i[s++]=a>>>6&127,i[s++]=a>>>13&127,i[s++]=a>>>20&127,i[s++]=127&(a>>>27|(3&h)<<5),i[s++]=h>>>2&127,i[s++]=h>>>9&127,i[s++]=h>>>16&127,i[s++]=h>>>23&127,i[s++]=127&(h>>>30|(31&l)<<2),i[s++]=l>>>5&127,i[s++]=l>>>12&127,i[s++]=l>>>19&127,i[s++]=127&(l>>>26|(1&c)<<6),i[s++]=c>>>1&127,i[s++]=c>>>8&127,i[s++]=c>>>15&127,i[s++]=c>>>22&127,i[s++]=127&(c>>>29|(15&u)<<3),i[s++]=u>>>4&127,i[s++]=u>>>11&127,i[s++]=u>>>18&127,i[s]=u>>>25&127}(t,e,i,n);case 8:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0;i[s++]=r>>>0&255,i[s++]=r>>>8&255,i[s++]=r>>>16&255,i[s++]=r>>>24&255,i[s++]=o>>>0&255,i[s++]=o>>>8&255,i[s++]=o>>>16&255,i[s++]=o>>>24&255,i[s++]=a>>>0&255,i[s++]=a>>>8&255,i[s++]=a>>>16&255,i[s++]=a>>>24&255,i[s++]=h>>>0&255,i[s++]=h>>>8&255,i[s++]=h>>>16&255,i[s++]=h>>>24&255,i[s++]=l>>>0&255,i[s++]=l>>>8&255,i[s++]=l>>>16&255,i[s++]=l>>>24&255,i[s++]=c>>>0&255,i[s++]=c>>>8&255,i[s++]=c>>>16&255,i[s++]=c>>>24&255,i[s++]=u>>>0&255,i[s++]=u>>>8&255,i[s++]=u>>>16&255,i[s++]=u>>>24&255,i[s++]=f>>>0&255,i[s++]=f>>>8&255,i[s++]=f>>>16&255,i[s]=f>>>24&255}(t,e,i,n);case 9:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0,d=t[e+8]>>>0;i[s++]=r>>>0&511,i[s++]=r>>>9&511,i[s++]=r>>>18&511,i[s++]=511&(r>>>27|(15&o)<<5),i[s++]=o>>>4&511,i[s++]=o>>>13&511,i[s++]=o>>>22&511,i[s++]=511&(o>>>31|(255&a)<<1),i[s++]=a>>>8&511,i[s++]=a>>>17&511,i[s++]=511&(a>>>26|(7&h)<<6),i[s++]=h>>>3&511,i[s++]=h>>>12&511,i[s++]=h>>>21&511,i[s++]=511&(h>>>30|(127&l)<<2),i[s++]=l>>>7&511,i[s++]=l>>>16&511,i[s++]=511&(l>>>25|(3&c)<<7),i[s++]=c>>>2&511,i[s++]=c>>>11&511,i[s++]=c>>>20&511,i[s++]=511&(c>>>29|(63&u)<<3),i[s++]=u>>>6&511,i[s++]=u>>>15&511,i[s++]=511&(u>>>24|(1&f)<<8),i[s++]=f>>>1&511,i[s++]=f>>>10&511,i[s++]=f>>>19&511,i[s++]=511&(f>>>28|(31&d)<<4),i[s++]=d>>>5&511,i[s++]=d>>>14&511,i[s]=d>>>23&511}(t,e,i,n);case 10:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0,d=t[e+8]>>>0,p=t[e+9]>>>0;i[s++]=r>>>0&1023,i[s++]=r>>>10&1023,i[s++]=r>>>20&1023,i[s++]=1023&(r>>>30|(255&o)<<2),i[s++]=o>>>8&1023,i[s++]=o>>>18&1023,i[s++]=1023&(o>>>28|(63&a)<<4),i[s++]=a>>>6&1023,i[s++]=a>>>16&1023,i[s++]=1023&(a>>>26|(15&h)<<6),i[s++]=h>>>4&1023,i[s++]=h>>>14&1023,i[s++]=1023&(h>>>24|(3&l)<<8),i[s++]=l>>>2&1023,i[s++]=l>>>12&1023,i[s++]=l>>>22&1023,i[s++]=c>>>0&1023,i[s++]=c>>>10&1023,i[s++]=c>>>20&1023,i[s++]=1023&(c>>>30|(255&u)<<2),i[s++]=u>>>8&1023,i[s++]=u>>>18&1023,i[s++]=1023&(u>>>28|(63&f)<<4),i[s++]=f>>>6&1023,i[s++]=f>>>16&1023,i[s++]=1023&(f>>>26|(15&d)<<6),i[s++]=d>>>4&1023,i[s++]=d>>>14&1023,i[s++]=1023&(d>>>24|(3&p)<<8),i[s++]=p>>>2&1023,i[s++]=p>>>12&1023,i[s]=p>>>22&1023}(t,e,i,n);case 11:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0,d=t[e+8]>>>0,p=t[e+9]>>>0,m=t[e+10]>>>0;i[s++]=r>>>0&2047,i[s++]=r>>>11&2047,i[s++]=2047&(r>>>22|(1&o)<<10),i[s++]=o>>>1&2047,i[s++]=o>>>12&2047,i[s++]=2047&(o>>>23|(3&a)<<9),i[s++]=a>>>2&2047,i[s++]=a>>>13&2047,i[s++]=2047&(a>>>24|(7&h)<<8),i[s++]=h>>>3&2047,i[s++]=h>>>14&2047,i[s++]=2047&(h>>>25|(15&l)<<7),i[s++]=l>>>4&2047,i[s++]=l>>>15&2047,i[s++]=2047&(l>>>26|(31&c)<<6),i[s++]=c>>>5&2047,i[s++]=c>>>16&2047,i[s++]=2047&(c>>>27|(63&u)<<5),i[s++]=u>>>6&2047,i[s++]=u>>>17&2047,i[s++]=2047&(u>>>28|(127&f)<<4),i[s++]=f>>>7&2047,i[s++]=f>>>18&2047,i[s++]=2047&(f>>>29|(255&d)<<3),i[s++]=d>>>8&2047,i[s++]=d>>>19&2047,i[s++]=2047&(d>>>30|(511&p)<<2),i[s++]=p>>>9&2047,i[s++]=p>>>20&2047,i[s++]=2047&(p>>>31|(1023&m)<<1),i[s++]=m>>>10&2047,i[s]=m>>>21&2047}(t,e,i,n);case 12:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0,d=t[e+8]>>>0,p=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0;i[s++]=r>>>0&4095,i[s++]=r>>>12&4095,i[s++]=4095&(r>>>24|(15&o)<<8),i[s++]=o>>>4&4095,i[s++]=o>>>16&4095,i[s++]=4095&(o>>>28|(255&a)<<4),i[s++]=a>>>8&4095,i[s++]=a>>>20&4095,i[s++]=h>>>0&4095,i[s++]=h>>>12&4095,i[s++]=4095&(h>>>24|(15&l)<<8),i[s++]=l>>>4&4095,i[s++]=l>>>16&4095,i[s++]=4095&(l>>>28|(255&c)<<4),i[s++]=c>>>8&4095,i[s++]=c>>>20&4095,i[s++]=u>>>0&4095,i[s++]=u>>>12&4095,i[s++]=4095&(u>>>24|(15&f)<<8),i[s++]=f>>>4&4095,i[s++]=f>>>16&4095,i[s++]=4095&(f>>>28|(255&d)<<4),i[s++]=d>>>8&4095,i[s++]=d>>>20&4095,i[s++]=p>>>0&4095,i[s++]=p>>>12&4095,i[s++]=4095&(p>>>24|(15&m)<<8),i[s++]=m>>>4&4095,i[s++]=m>>>16&4095,i[s++]=4095&(m>>>28|(255&_)<<4),i[s++]=_>>>8&4095,i[s]=_>>>20&4095}(t,e,i,n);case 16:return void function(t,e,i,n){let s=n;const r=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,h=t[e+3]>>>0,l=t[e+4]>>>0,c=t[e+5]>>>0,u=t[e+6]>>>0,f=t[e+7]>>>0,d=t[e+8]>>>0,p=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0,g=t[e+12]>>>0,v=t[e+13]>>>0,y=t[e+14]>>>0,w=t[e+15]>>>0;i[s++]=r>>>0&65535,i[s++]=r>>>16&65535,i[s++]=o>>>0&65535,i[s++]=o>>>16&65535,i[s++]=a>>>0&65535,i[s++]=a>>>16&65535,i[s++]=h>>>0&65535,i[s++]=h>>>16&65535,i[s++]=l>>>0&65535,i[s++]=l>>>16&65535,i[s++]=c>>>0&65535,i[s++]=c>>>16&65535,i[s++]=u>>>0&65535,i[s++]=u>>>16&65535,i[s++]=f>>>0&65535,i[s++]=f>>>16&65535,i[s++]=d>>>0&65535,i[s++]=d>>>16&65535,i[s++]=p>>>0&65535,i[s++]=p>>>16&65535,i[s++]=m>>>0&65535,i[s++]=m>>>16&65535,i[s++]=_>>>0&65535,i[s++]=_>>>16&65535,i[s++]=g>>>0&65535,i[s++]=g>>>16&65535,i[s++]=v>>>0&65535,i[s++]=v>>>16&65535,i[s++]=y>>>0&65535,i[s++]=y>>>16&65535,i[s++]=w>>>0&65535,i[s]=w>>>16&65535}(t,e,i,n);case 32:for(let s=0;s<32;s=s+1|0)i[n+s|0]=0|t[e+s|0];return}const r=md[s]>>>0;let o=e,a=0,h=t[o]>>>0;for(let e=0;e<32;e++)if(a+s<=32)i[n+e]=h>>>a&r,a+=s,32===a&&(a=0,o++,31!==e&&(h=t[o]>>>0));else{const l=32-a,c=h>>>a;o++,h=t[o]>>>0,i[n+e]=(c|(h&md[s-l]>>>0)<<l)&r,a=s-l}}function Ed(t,e,i){const n=new Uint32Array(i);let s=0,r=e.get();for(let e=0;e<n.length;e++){let e=t[r++],i=127&e;e<128||(e=t[r++],i|=(127&e)<<7,e<128||(e=t[r++],i|=(127&e)<<14,e<128||(e=t[r++],i|=(127&e)<<21,e<128||(e=t[r++],i|=(15&e)<<28)))),n[s++]=i}return e.set(r),n}function Ad(t,e,i){const n=new BigUint64Array(i);for(let i=0;i<n.length;i++)n[i]=Pd(t,e);return n}function Pd(t,e){let i=0n,n=0,s=e.get();for(;s<t.length;){const e=t[s++];if(i|=BigInt(127&e)<<BigInt(n),!(128&e))break;if(n+=7,n>=64)throw new Error("Varint too long")}return e.set(s),i}function Cd(t,e){let i,n;return n=t[e.get()],e.increment(),i=127&n,n<128?i:(n=t[e.get()],e.increment(),i|=(127&n)<<7,n<128?i:(n=t[e.get()],e.increment(),i|=(127&n)<<14,n<128?i:(n=t[e.get()],e.increment(),i|=(127&n)<<21,n<128?i:(n=t[e.get()],i|=(15&n)<<28,function(t,e,i){let n,s;if(s=e[i.get()],i.increment(),n=(112&s)>>4,s<128)return 4294967296*n+(t>>>0);if(s=e[i.get()],i.increment(),n|=(127&s)<<3,s<128)return 4294967296*n+(t>>>0);if(s=e[i.get()],i.increment(),n|=(127&s)<<10,s<128)return 4294967296*n+(t>>>0);if(s=e[i.get()],i.increment(),n|=(127&s)<<17,s<128)return 4294967296*n+(t>>>0);if(s=e[i.get()],i.increment(),n|=(127&s)<<24,s<128)return 4294967296*n+(t>>>0);if(s=e[i.get()],i.increment(),n|=(1&s)<<31,s<128)return 4294967296*n+(t>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,t,e)))))}function Dd(t){return t>>>1^-(1&t)}function Fd(t){return t>>1n^-(1n&t)}function Id(t){return t%2==1?(t+1)/-2:t/2}function kd(t,e,i){if(void 0===i){i=0;for(let n=0;n<e;n++)i+=t[n]}const n=new Uint32Array(i);let s=0;for(let i=0;i<e;i++){const r=t[i];n.fill(t[i+e],s,s+r),s+=r}return n}function $d(t,e,i){if(void 0===i){i=0;for(let n=0;n<e;n++)i+=Number(t[n])}const n=new BigUint64Array(i);let s=0;for(let i=0;i<e;i++){const r=Number(t[i]);n.fill(t[i+e],s,s+r),s+=r}return n}function Od(t,e,i){const n=new Float64Array(i);let s=0;for(let i=0;i<e;i++){const r=t[i];n.fill(t[i+e],s,s+r),s+=r}return n}function jd(t){const e=new Int32Array(t.length);e[0]=Dd(t[0]);const i=t.length/4*4;let n=1;if(i>=4)for(;n<i-4;n+=4){const i=t[n+1],s=t[n+2],r=t[n+3];e[n]=Dd(t[n])+e[n-1],e[n+1]=Dd(i)+e[n],e[n+2]=Dd(s)+e[n+1],e[n+3]=Dd(r)+e[n+2]}for(;n!==t.length;++n)e[n]=Dd(t[n])+e[n-1];return e}function Rd(t){const e=new BigInt64Array(t.length);e[0]=Fd(t[0]);const i=t.length/4*4;let n=1;if(i>=4)for(;n<i-4;n+=4){const i=t[n+1],s=t[n+2],r=t[n+3];e[n]=Fd(t[n])+e[n-1],e[n+1]=Fd(i)+e[n],e[n+2]=Fd(s)+e[n+1],e[n+3]=Fd(r)+e[n+2]}for(;n!==e.length;++n)e[n]=Fd(t[n])+e[n-1];return e}function Ld(t){const e=t.length/4*4;let i=1;if(e>=4)for(let n=t[0];i<e-4;i+=4)n=t[i]+=n,n=t[i+1]+=n,n=t[i+2]+=n,n=t[i+3]+=n;for(;i!==t.length;)t[i]+=t[i-1],++i}var Bd,Nd,Ud,Gd,Vd,qd,Zd,Wd;function Hd(t,e){const i=function(t,e){const i=t[e.get()],n=Object.values(Bd)[i>>4];let s=null;switch(n){case Bd.DATA:s={dictionaryType:Object.values(Nd)[15&i]};break;case Bd.OFFSET:s={offsetType:Object.values(Ud)[15&i]};break;case Bd.LENGTH:s={lengthType:Object.values(Gd)[15&i]}}e.increment();const r=t[e.get()],o=Object.values(fd)[r>>5],a=Object.values(fd)[r>>2&7],h=Object.values(dd)[3&r];e.increment();const l=Ed(t,e,2),c=l[0];return{physicalStreamType:n,logicalStreamType:s,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:h,numValues:c,byteLength:l[1],decompressedCount:c}}(t,e);return i.logicalLevelTechnique1===fd.MORTON?function(t,e,i){const n=Ed(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:t.decompressedCount,numBits:n[0],coordinateShift:n[1]}}(i,t,e):fd.RLE!==i.logicalLevelTechnique1&&fd.RLE!==i.logicalLevelTechnique2||dd.NONE===i.physicalLevelTechnique?i:function(t,e,i){const n=Ed(e,i,2);return{physicalStreamType:t.physicalStreamType,logicalStreamType:t.logicalStreamType,logicalLevelTechnique1:t.logicalLevelTechnique1,logicalLevelTechnique2:t.logicalLevelTechnique2,physicalLevelTechnique:t.physicalLevelTechnique,numValues:t.numValues,byteLength:t.byteLength,decompressedCount:n[1],runs:n[0],numRleValues:n[1]}}(i,t,e)}!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(Bd||(Bd={})),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(Nd||(Nd={})),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(Ud||(Ud={})),function(t){t.VAR_BINARY="VAR_BINARY",t.GEOMETRIES="GEOMETRIES",t.PARTS="PARTS",t.RINGS="RINGS",t.TRIANGLES="TRIANGLES",t.SYMBOL="SYMBOL",t.DICTIONARY="DICTIONARY"}(Gd||(Gd={})),function(t){t[t.FLAT=0]="FLAT",t[t.CONST=1]="CONST",t[t.SEQUENCE=2]="SEQUENCE",t[t.DICTIONARY=3]="DICTIONARY",t[t.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(Vd||(Vd={}));class Yd{constructor(t,e){this.values=t,this._size=e}get(t){const e=Math.floor(t/8);return 1==(this.values[e]>>t%8&1)}set(t,e){const i=Math.floor(t/8);this.values[i]=this.values[i]|(e?1:0)<<t%8}getInt(t){const e=Math.floor(t/8);return this.values[e]>>t%8&1}size(){return this._size}getBuffer(){return this.values}}function Xd(t,e,i){if(!e)return t;const n=e.size(),s=new t.constructor(n);let r=0;for(let o=0;o<n;o++)s[o]=e.get(o)?t[r++]:i;return s}function Jd(t,e,i,n,s){return function(t,e,i,n){let s;switch(e.logicalLevelTechnique1){case fd.DELTA:if(e.logicalLevelTechnique2===fd.RLE){const i=e;if(!n)return function(t,e,i){const n=new Int32Array(i);let s=0,r=0;for(let i=0;i<e;i++){const o=t[i],a=Dd(t[i+e]);for(let t=0;t<o;t++)r+=a,n[s++]=r}return n}(t,i.runs,i.numRleValues);s=jd(t=kd(t,i.runs,i.numRleValues))}else s=jd(t);break;case fd.RLE:s=function(t,e,i){if(void 0===i){i=0;for(let n=0;n<e;n++)i+=t[n]}const n=new Int32Array(i);let s=0;for(let i=0;i<e;i++){const r=t[i];let o=t[i+e];o=Dd(o),n.fill(o,s,s+r),s+=r}return n}(t,e.runs,e.numRleValues);break;case fd.MORTON:Ld(t),s=new Int32Array(t);break;case fd.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Int32Array(t);const e=new Int32Array(t.length);e[0]=Dd(t[0]),e[1]=Dd(t[1]);const i=t.length/4*4;let n=2;if(i>=4)for(;n<i-4;n+=4){const i=t[n+1],s=t[n+2],r=t[n+3];e[n]=Dd(t[n])+e[n-2],e[n+1]=Dd(i)+e[n-1],e[n+2]=Dd(s)+e[n],e[n+3]=Dd(r)+e[n+1]}for(;n!==t.length;n+=2)e[n]=Dd(t[n])+e[n-2],e[n+1]=Dd(t[n+1])+e[n-1];return e}(t);break;case fd.NONE:s=function(t){const e=new Int32Array(t.length);for(let i=0;i<t.length;i++)e[i]=Dd(t[i]);return e}(t);break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return n?Xd(s,n,0):s}(tp(t,e,i),i,0,s)}function Kd(t,e,i,n,s){return function(t,e,i,n){let s;switch(e.logicalLevelTechnique1){case fd.DELTA:s=function(t){const e=new Uint32Array(t.length);e[0]=Dd(t[0])>>>0;for(let i=1;i<t.length;i++)e[i]=e[i-1]+Dd(t[i])>>>0;return e}(e.logicalLevelTechnique2===fd.RLE?kd(t,e.runs,e.numRleValues):t);break;case fd.RLE:s=kd(t,e.runs,e.numRleValues);break;case fd.MORTON:Ld(t),s=t;break;case fd.COMPONENTWISE_DELTA:s=function(t){if(t.length<2)return new Uint32Array(t);const e=new Uint32Array(t.length);e[0]=Dd(t[0])>>>0,e[1]=Dd(t[1])>>>0;for(let i=2;i<t.length;i+=2)e[i]=e[i-2]+Dd(t[i])>>>0,e[i+1]=e[i-1]+Dd(t[i+1])>>>0;return e}(t);break;case fd.NONE:s=t;break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return n?Xd(s,n,0):s}(tp(t,e,i),i,0,s)}function Qd(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===fd.DELTA&&e.logicalLevelTechnique2===fd.NONE)return function(t){const e=new Int32Array(t.length+1);e[0]=0,e[1]=Dd(t[0]);let i=e[1];for(let n=2;n!==e.length;++n)i+=Dd(t[n-1]),e[n]=e[n-1]+i;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===fd.RLE&&e.logicalLevelTechnique2===fd.NONE)return function(t,e,i){const n=new Uint32Array(i+1);n[0]=0;let s=1,r=n[0];for(let i=0;i<e;i++){const o=t[i],a=t[i+e];for(let t=s;t<s+o;t++)n[t]=a+r,r=n[t];s+=o}return n}(t,e.runs,e.numRleValues);if(e.logicalLevelTechnique1===fd.NONE&&e.logicalLevelTechnique2===fd.NONE){!function(t){let e=0;for(let i=0;i<t.length;i++)t[i]+=e,e=t[i]}(t);const i=new Uint32Array(e.numValues+1);return i[0]=0,i.set(t,1),i}if(e.logicalLevelTechnique1===fd.DELTA&&e.logicalLevelTechnique2===fd.RLE){const i=function(t,e,i){const n=new Int32Array(i+1);n[0]=0;let s=1,r=n[0];for(let i=0;i<e;i++){const o=t[i];let a=t[i+e];a=Dd(a);for(let t=s;t<s+o;t++)n[t]=a+r,r=n[t];s+=o}return n}(t,e.runs,e.numRleValues);return Ld(i),new Uint32Array(i)}throw new Error("Only delta encoding is supported for transforming length to offset streams yet.")}(tp(t,e,i),i)}function tp(t,e,i){const n=i.physicalLevelTechnique;switch(n){case dd.FAST_PFOR:return function(t,e,i,n){return function(t,e,i,n,s){const r=n.get();if(3&i)throw new Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${r} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);const o=i>>>2,a=function(t,e){if(e<=t.encodedWords.length)return t.encodedWords;const i=new Uint32Array(Math.max(16,2*e));return t.encodedWords=i,i}(s,o);!function(t,e,i,n){if(e<0||i<0||e+i>t.length)throw new RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${e}, byteLength=${i}, bytes.length=${t.length})`);const s=Math.floor(i/4),r=i%4!=0,o=r?s+1:s;if(n.length<o)throw new RangeError(`decodeBigEndianInt32sInto: out.length=${n.length} < ${o}`);if(s>0){const i=t.byteOffset+e;if(3&i)for(let i=0;i<s;i++){const s=e+4*i;n[i]=t[s]<<24|t[s+1]<<16|t[s+2]<<8|t[s+3]}else{const e=new Uint32Array(t.buffer,i,s);for(let t=0;t<s;t++)n[t]=0|vd(e[t])}}if(r){const r=e+4*s,o=i-4*s;let a=0;for(let e=0;e<o;e++)a|=t[r+e]<<24-8*e;n[s]=0|a}}(t,r,i,a);const h=function(t,e,i){let n=0,s=0;const r=new Uint32Array(e),o=i??bd();if(t.length>0){const e=0|t[n];if(n=n+1|0,255&e)throw new Error(`FastPFOR decode: invalid alignedLength=${e} (expected multiple of 256)`);if(s+e>r.length)throw new Error(`FastPFOR decode: output buffer too small (outPos=${s}, alignedLength=${e}, out.length=${r.length})`);n=function(t,e,i,n,s,r){const o=n+gd(s,_d);let a=n,h=i;for(;a!==o;){const i=Math.min(yd,o-a);h=zd(t,e,h,a,i,r),a=a+i|0}return h}(t,r,n,s,e,o),s=s+e|0}return function(t,e,i,n,s,r){if(0===r)return e;let o=0,a=e;const h=e+i,l=s;let c=s;const u=s+r;let f=0,d=0;for(;a<h&&c<u;){const e=t[a]>>>o&255;if(o+=8,a+=o>>>5,o&=31,f|=(127&e)<<d,128&e)n[c++]=0|f,f=0,d=0;else if(d+=7,d>28)throw new Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${d}, partial=${f}, decoded=${c-l}/${r}, inPos=${a}, inEnd=${h})`)}if(c!==u)throw new Error(`FastPFOR VByte: truncated stream (decoded=${c-l}, expected=${r}, consumedWords=${a-e}/${i}, vbyteStart=${e}, vbyteEnd=${h})`)}(t,n,t.length-n|0,r,s,e-s|0),r}(a.subarray(0,o),e,s.decoderWorkspace);return n.add(i),h}(t,e,i,n,function(t=16){if(t<0)throw new RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);const e=Math.max(16,0|t);return{encodedWords:new Uint32Array(e),decoderWorkspace:bd()}}(i>>>2))}(t,i.numValues,i.byteLength,e);case dd.VARINT:return Ed(t,e,i.numValues);case dd.NONE:{const n=e.get();e.add(i.byteLength);const s=t.subarray(n,e.get());return new Uint32Array(s)}default:throw new Error(`Specified physicalLevelTechnique ${n} is not supported (yet).`)}}function ep(t,e,i){const n=tp(t,e,i);return 1===n.length?n[0]:function(t){return t[1]}(n)}function ip(t,e,i){return function(t){if(2===t.length){const e=Dd(t[1]);return[e,e]}return[Dd(t[2]),Dd(t[3])]}(tp(t,e,i))}function np(t,e,i){return function(t){if(2===t.length){const e=Fd(t[1]);return[e,e]}return[Fd(t[2]),Fd(t[3])]}(Ad(t,e,i.numValues))}function sp(t,e,i,n){return function(t,e,i){let n;switch(e.logicalLevelTechnique1){case fd.DELTA:n=function(t){const e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,Fd(t[0]));for(let i=1;i<t.length;i++)e[i]=BigInt.asUintN(64,e[i-1]+Fd(t[i]));return e}(e.logicalLevelTechnique2===fd.RLE?$d(t,e.runs,e.numRleValues):t);break;case fd.RLE:n=$d(t,e.runs,e.numRleValues);break;case fd.NONE:n=t;break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Xd(n,i,0n):n}(Ad(t,e,i.numValues),i,n)}function rp(t,e,i){const n=Ad(t,e,i.numValues);return 1===n.length?n[0]:function(t){return t[1]}(n)}function op(t,e,i,n,s="int32"){const r=t.logicalLevelTechnique1;if(r===fd.RLE)return 1===t.runs?Vd.CONST:Vd.FLAT;if(r!==fd.DELTA||t.logicalLevelTechnique2!==fd.RLE)return 1===t.numValues?Vd.CONST:Vd.FLAT;const o=e instanceof Yd?e.size():e;if(t.numRleValues!==o)return Vd.FLAT;if(1===t.runs)return Vd.SEQUENCE;if(2!==t.runs)return 1===t.numValues?Vd.CONST:Vd.FLAT;const a=n.get();if(t.physicalLevelTechnique===dd.VARINT)return function(t,e,i){const n=new ud(e.get());if("int64"===i){const e=Ad(t,n,4);return 2n===e[2]&&2n===e[3]}const s=Ed(t,n,4);return 2===s[2]&&2===s[3]}(i,n,s)?Vd.SEQUENCE:1===t.numValues?Vd.CONST:Vd.FLAT;const h=n.get(),l=new Int32Array(i.buffer,i.byteOffset+h,4);return n.set(a),2===l[2]&&2===l[3]?Vd.SEQUENCE:1===t.numValues?Vd.CONST:Vd.FLAT}class ap extends sd{getValueFromBuffer(t){return this.dataBuffer[t]}}class hp extends ad{constructor(t,e,i,n){super(t,BigInt64Array.of(e),i,n)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}}function lp(t,e,i){return{x:cp(t,e)-i,y:cp(t>>1,e)-i}}function cp(t,e){let i=0;for(let n=0;n<e;n++)i|=(t&1<<2*n)>>n;return i}function up(t,e,n,s,r,o,a){return t===Wd.MORTON?function(t,e,n,s,r,o){const a=new Array(r?s+1:s);for(let r=0;r<s;r++){const s=lp(t[e[n+r]],o.numBits,o.coordinateShift);a[r]=new i(s.x,s.y)}return r&&(a[a.length-1]=a[0]),a}(e,n,s,r,o,a):function(t,e,n,s,r){const o=new Array(r?s+1:s);for(let r=0;r<2*s;r+=2){const s=2*e[n+r/2];o[r/2]=new i(t[s],t[s+1])}return r&&(o[o.length-1]=o[0]),o}(e,n,s,r,o)}function fp(t,e,n,s){const r=new Array(s?n+1:n);for(let s=0;s<2*n;s+=2)r[s/2]=new i(t[e+s],t[e+s+1]);return s&&(r[r.length-1]=r[0]),r}!function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON",t[t.MULTIPOINT=3]="MULTIPOINT",t[t.MULTILINESTRING=4]="MULTILINESTRING",t[t.MULTIPOLYGON=5]="MULTIPOLYGON"}(qd||(qd={})),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(Zd||(Zd={})),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(Wd||(Wd={}));class dp{constructor(t,e,i,n,s){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=i,this._vertexBuffer=n,this._mortonSettings=s}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(t){const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){const e=lp(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[e.x,e.y]}const e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return function(t){const e=new Array(t.numGeometries);let n=1,s=1,r=1,o=0,a=0,h=0;const l=t.mortonSettings,c=t.topologyVector,u=c.geometryOffsets,f=c.partOffsets,d=c.ringOffsets,p=t.vertexOffsets,m=!p||0===p.length,_=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let c=0;c<t.numGeometries;c++)switch(t.geometryType(c)){case qd.POINT:{let c,_;if(m)c=g[a++],_=g[a++];else if(t.vertexBufferType===Wd.MORTON){const t=lp(g[p[h++]],l.numBits,l.coordinateShift);c=t.x,_=t.y}else{const t=2*p[h++];c=g[t],_=g[t+1]}e[o++]=[[new i(c,_)]],u&&r++,f&&n++,d&&s++}break;case qd.MULTIPOINT:{const t=u[r]-u[r-1];r++;const l=new Array(t);if(m)for(let e=0;e<t;e++){const t=g[a++],n=g[a++];l[e]=new i(t,n)}else for(let e=0;e<t;e++){const t=2*p[h++];l[e]=new i(g[t],g[t+1])}e[o++]=l.map((t=>[t])),n+=t,s+=t}break;case qd.LINESTRING:{let i,c;_?(i=d[s]-d[s-1],s++):i=f[n]-f[n-1],n++,m?(c=fp(g,a,i,!1),a+=2*i):(c=up(t.vertexBufferType,g,p,h,i,!1,l),h+=i),e[o++]=[c],u&&r++}break;case qd.POLYGON:{const i=f[n]-f[n-1];n++;const c=new Array(i-1);let _,v=d[s]-d[s-1];if(s++,m){_=fp(g,a,v,!0),a+=2*v;for(let t=0;t<c.length;t++)v=d[s]-d[s-1],s++,c[t]=fp(g,a,v,!0),a+=2*v}else{_=up(t.vertexBufferType,g,p,h,v,!0,l),h+=v;for(let e=0;e<c.length;e++)v=d[s]-d[s-1],s++,c[e]=up(t.vertexBufferType,g,p,h,v,!0,l),h+=v}e[o++]=[_].concat(c),u&&r++}break;case qd.MULTILINESTRING:{const i=u[r]-u[r-1];r++;const c=new Array(i);for(let e=0;e<i;e++){let i;if(_?(i=d[s]-d[s-1],s++):i=f[n]-f[n-1],n++,m)c[e]=fp(g,a,i,!1),a+=2*i;else{const n=up(t.vertexBufferType,g,p,h,i,!1,l);c[e]=n,h+=i}}e[o++]=c}break;case qd.MULTIPOLYGON:{const i=u[r]-u[r-1];r++;const c=new Array(i);for(let e=0;e<i;e++){const i=f[n]-f[n-1];let r;n++;const o=new Array(i-1),u=d[s]-d[s-1];s++,m?(r=fp(g,a,u,!0),a+=2*u):(r=up(t.vertexBufferType,g,p,h,u,!0,l),h+=u);for(let e=0;e<o.length;e++){const i=d[s]-d[s-1];s++,m?(o[e]=fp(g,a,i,!0),a+=2*i):(o[e]=up(t.vertexBufferType,g,p,h,i,!0,l),h+=i)}c[e]=[r].concat(o)}e[o++]=c.flat()}break;default:throw new Error("The specified geometry type is currently not supported.")}return e}(this)}get mortonSettings(){return this._mortonSettings}}class pp extends dp{constructor(t,e,i,n,s,r,o){super(i,n,s,r,o),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===qd.POLYGON||this._geometryType===qd.MULTIPOLYGON}containsSingleGeometryType(){return!0}}class mp extends dp{constructor(t,e,i,n,s,r){super(t,i,n,s,r),this._geometryTypes=e}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsPolygonGeometry(){for(let t=0;t<this.numGeometries;t++)if(this.geometryType(t)===qd.POLYGON||this.geometryType(t)===qd.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}}class _p{constructor(t,e,i,n){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=i,this._topologyVector=n}get triangleOffsets(){return this._triangleOffsets}get indexBuffer(){return this._indexBuffer}get vertexBuffer(){return this._vertexBuffer}get topologyVector(){return this._topologyVector}getGeometries(){if(!this._topologyVector)throw new Error("Cannot convert GpuVector to coordinates without topology information");const t=new Array(this.numGeometries),e=this._topologyVector,n=e.partOffsets,s=e.ringOffsets,r=e.geometryOffsets;let o=0,a=1,h=1,l=1;for(let e=0;e<this.numGeometries;e++)switch(this.geometryType(e)){case qd.POLYGON:{const c=n[a]-n[a-1];a++;const u=[];for(let t=0;t<c;t++){const t=s[h]-s[h-1];h++;const e=[];for(let n=0;n<t;n++){const t=this._vertexBuffer[o++],n=this._vertexBuffer[o++];e.push(new i(t,n))}e.length>0&&e.push(e[0]),u.push(e)}t[e]=u,r&&l++}break;case qd.MULTIPOLYGON:{const c=r[l]-r[l-1];l++;const u=[];for(let t=0;t<c;t++){const t=n[a]-n[a-1];a++;for(let e=0;e<t;e++){const t=s[h]-s[h-1];h++;const e=[];for(let n=0;n<t;n++){const t=this._vertexBuffer[o++],n=this._vertexBuffer[o++];e.push(new i(t,n))}e.length>0&&e.push(e[0]),u.push(e)}}t[e]=u}}return t}[Symbol.iterator](){return null}}function gp(t,e,i,n,s,r){return new vp(t,e,i,n,s,r)}class vp extends _p{constructor(t,e,i,n,s,r){super(i,n,s,r),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}function yp(t,e,i,n,s){return new wp(t,e,i,n,s)}class wp extends _p{constructor(t,e,i,n,s){super(e,i,n,s),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function bp(t,e,i,n){const s=Hd(t,i);let r,o,a,h;if(op(s,n,t,i)===Vd.CONST){const l=ep(t,i,s);let c,u,f,d;for(let n=0;n<e-1;n++){const e=Hd(t,i);switch(e.physicalStreamType){case Bd.LENGTH:switch(e.logicalStreamType.lengthType){case Gd.GEOMETRIES:c=Qd(t,i,e);break;case Gd.PARTS:u=Qd(t,i,e);break;case Gd.RINGS:f=Qd(t,i,e);break;case Gd.TRIANGLES:d=Qd(t,i,e)}break;case Bd.OFFSET:switch(e.logicalStreamType.offsetType){case Ud.VERTEX:r=Kd(t,i,e);break;case Ud.INDEX:h=Kd(t,i,e)}break;case Bd.DATA:Nd.VERTEX===e.logicalStreamType.dictionaryType?o=Jd(t,i,e):(a={numBits:e.numBits,coordinateShift:e.coordinateShift},o=Kd(t,i,e))}}return h?void 0!==c||void 0!==u?gp(n,l,d,h,o,{geometryOffsets:c,partOffsets:u,ringOffsets:f}):gp(n,l,d,h,o):void 0===a?function(t,e,i,n,s){return new pp(t,e,Wd.VEC_2,i,n,s)}(n,l,{geometryOffsets:c,partOffsets:u,ringOffsets:f},r,o):function(t,e,i,n,s,r){return new pp(t,e,Wd.MORTON,i,n,s,r)}(n,l,{geometryOffsets:c,partOffsets:u,ringOffsets:f},r,o,a)}const l=Kd(t,i,s);let c,u,f,d,p,m,_;for(let n=0;n<e-1;n++){const e=Hd(t,i);switch(e.physicalStreamType){case Bd.LENGTH:switch(e.logicalStreamType.lengthType){case Gd.GEOMETRIES:c=Kd(t,i,e);break;case Gd.PARTS:u=Kd(t,i,e);break;case Gd.RINGS:f=Kd(t,i,e);break;case Gd.TRIANGLES:d=Qd(t,i,e)}break;case Bd.OFFSET:switch(e.logicalStreamType.offsetType){case Ud.VERTEX:r=Kd(t,i,e);break;case Ud.INDEX:h=Kd(t,i,e)}break;case Bd.DATA:Nd.VERTEX===e.logicalStreamType.dictionaryType?o=Jd(t,i,e):(a={numBits:e.numBits,coordinateShift:e.coordinateShift},o=Kd(t,i,e))}}return c?(p=xp(l,c,2),u&&f?(m=Mp(l,p,u,!1),_=function(t,e,i,n){const s=new Uint32Array(i[i.length-1]+1);let r=0;s[0]=r;let o=1,a=1,h=0;for(let l=0;l<t.length;l++){const c=t[l],u=e[l+1]-e[l];if(0!==c&&3!==c)for(let t=0;t<u;t++){const t=i[o]-i[o-1];o++;for(let e=0;e<t;e++)r=s[a++]=r+n[h++]}else for(let t=0;t<u;t++)s[a++]=++r,o++}return s}(l,p,m,f)):u&&(m=function(t,e,i){const n=new Uint32Array(e[e.length-1]+1);let s=0;n[0]=s;let r=1,o=0;for(let a=0;a<t.length;a++){const h=t[a],l=e[a+1]-e[a];if(4===h||1===h)for(let t=0;t<l;t++)s=n[r++]=s+i[o++];else for(let t=0;t<l;t++)n[r++]=++s}return n}(l,p,u))):u&&f?(m=xp(l,u,1),_=Mp(l,m,f,!0)):u&&(m=xp(l,u,0)),h&&!m?yp(l,d,h,o):h?yp(l,d,h,o,{geometryOffsets:p,partOffsets:m,ringOffsets:_}):void 0===a?function(t,e,i,n){return new mp(Wd.VEC_2,t,e,i,n)}(l,{geometryOffsets:p,partOffsets:m,ringOffsets:_},r,o):function(t,e,i,n,s){return new mp(Wd.MORTON,t,e,i,n,s)}(l,{geometryOffsets:p,partOffsets:m,ringOffsets:_},r,o,a)}function xp(t,e,i){const n=new Uint32Array(t.length+1);let s=0;n[0]=s;let r=0;for(let o=0;o<t.length;o++)s=n[o+1]=s+(t[o]>i?e[r++]:1);return n}function Mp(t,e,i,n){const s=new Uint32Array(e[e.length-1]+1);let r=0;s[0]=r;let o=1,a=0;for(let h=0;h<t.length;h++){const l=t[h],c=e[h+1]-e[h];if(5===l||2===l||n&&(4===l||1===l))for(let t=0;t<c;t++)r=s[o++]=r+i[a++];else for(let t=0;t<c;t++)s[o++]=++r}return s}class Sp extends nd{constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}}class zp extends sd{getValueFromBuffer(t){return this.dataBuffer[t]}}class Tp extends nd{constructor(t,e,i,n){super(t,n?BigInt64Array.of(e):BigUint64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}}function Ep(t,e,i,n,s){const r=function(t,e,i,n){const s=new Uint8Array(e);let r=0;const o=n.get()+i;for(;r<e&&!(n.get()>=o);){const i=t[n.increment()];if(i<=127){const o=i+3,a=t[n.increment()],h=Math.min(r+o,e);s.fill(a,r,h),r=h}else{const o=256-i;for(let i=0;i<o&&r<e;i++)s[r++]=t[n.increment()]}}return n.set(o),s}(t,Math.ceil(e/8),i,n);return s?function(t,e,i){if(!i)return t;const n=i.size(),s=new Yd(t,e),r=new Yd(new Uint8Array(Math.ceil(n/8)),n);let o=0;for(let t=0;t<n;t++){const e=!!i.get(t)&&s.get(o++);r.set(t,e)}return r.getBuffer()}(r,e,s):r}const Ap=new TextDecoder;function Pp(t,e,i){return i-e>=12?Ap.decode(t.subarray(e,i)):function(t,e,i){let n="",s=e;for(;s<i;){const e=t[s];let r,o,a,h=null,l=e>239?4:e>223?3:e>191?2:1;if(s+l>i)break;1===l?e<128&&(h=e):2===l?(r=t[s+1],128==(192&r)&&(h=(31&e)<<6|63&r,h<=127&&(h=null))):3===l?(r=t[s+1],o=t[s+2],128==(192&r)&&128==(192&o)&&(h=(15&e)<<12|(63&r)<<6|63&o,(h<=2047||h>=55296&&h<=57343)&&(h=null))):4===l&&(r=t[s+1],o=t[s+2],a=t[s+3],128==(192&r)&&128==(192&o)&&128==(192&a)&&(h=(15&e)<<18|(63&r)<<12|(63&o)<<6|63&a,(h<=65535||h>=1114112)&&(h=null))),null===h?(h=65533,l=1):h>65535&&(h-=65536,n+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),n+=String.fromCharCode(h),s+=l}return n}(t,e,i)}class Cp extends nd{constructor(t,e,i,n){super(t,i,n),this.offsetBuffer=e}}class Dp extends Cp{constructor(t,e,i,n){super(t,e,i,n??e.length-1)}getValueFromBuffer(t){return Pp(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class Fp extends Cp{constructor(t,e,i,n,s){super(t,i,n,s??e.length),this.indexBuffer=e,this.indexBuffer=e}getValueFromBuffer(t){const e=this.indexBuffer[t];return Pp(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class Ip extends Cp{constructor(t,e,i,n,s,r,o){super(t,i,n,o),this.indexBuffer=e,this.symbolOffsetBuffer=s,this.symbolTableBuffer=r}getValueFromBuffer(t){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer)),this.decodedDictionary=function(t,e,i){const n=[],s=new Array(e.length).fill(0);for(let t=1;t<e.length;t++)s[t]=s[t-1]+e[t-1];for(let r=0;r<i.length;r++)if(255===i[r])n.push(i[++r]);else{const o=e[i[r]],a=s[i[r]];for(let e=0;e<o;e++)n.push(t[a+e])}return new Uint8Array(n)}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer));const e=this.indexBuffer[t];return Pp(this.decodedDictionary,this.offsetBuffer[e],this.offsetBuffer[e+1])}offsetToLengthBuffer(t){const e=new Uint32Array(t.length-1);let i=t[0];for(let n=1;n<t.length;n++){const s=t[n];e[n-1]=s-i,i=s}return e}}function kp(t,e,i,n,s){return"scalarType"===i.type?function(t,e,i,n,s,r){let o=null;if(0===t)return null;if(r.nullable){const t=Hd(e,i),n=t.numValues,s=i.get(),r=Ep(e,n,t.byteLength,i);i.set(s+t.byteLength),o=new Yd(r,t.numValues)}const a=o??n;switch(s.physicalType){case 4:case 3:return function(t,e,i,n,s){const r=Hd(t,e),o=op(r,s,t,e),a=3===n.physicalType;if(o===Vd.FLAT){const n=$p(s)?s:void 0,o=a?Jd(t,e,r,0,n):Kd(t,e,r,0,n);return new rd(i.name,o,s)}if(o===Vd.SEQUENCE){const n=ip(t,e,r);return new hd(i.name,n[0],n[1],r.numRleValues)}const h=a?function(t,e,i){const n=tp(t,e,i);return 1===n.length?Dd(n[0]):function(t){return Dd(t[1])}(n)}(t,e,r):ep(t,e,r);return new ld(i.name,h,s,a)}(e,i,r,s,a);case 9:return function(t,e,i,n,s){let r=null,o=null,a=null,h=null,l=null,c=s??null,u=null,f=null;for(let t=0;t<n;t++){const t=Hd(e,i);switch(t.physicalStreamType){case Bd.PRESENT:{const n=Ep(e,t.numValues,t.byteLength,i),r=new Yd(n,t.numValues);c=s??r;break}case Bd.OFFSET:o=Kd(e,i,t,0,c);break;case Bd.LENGTH:{const n=Qd(e,i,t);Gd.DICTIONARY===t.logicalStreamType.lengthType?r=n:Gd.SYMBOL===t.logicalStreamType.lengthType?h=n:u=n;break}case Bd.DATA:{const n=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);const s=t.logicalStreamType.dictionaryType;Nd.FSST===s?l=n:Nd.SINGLE===s||Nd.SHARED===s?a=n:Nd.NONE===s&&(f=n);break}}}return function(t,e,i,n,s,r,o){return e?new Ip(t,i,n,s,r,e,o):null}(t,l,o,r,a,h,c)??function(t,e,i,n,s){return e?s?new Fp(t,i,n,e,s):new Fp(t,i,n,e):null}(t,a,o,r,c)??function(t,e,i,n,s){if(!e||!i)return null;if(n)return s?new Fp(t,n,e,i,s):new Fp(t,n,e,i);if(s&&s.size()!==e.length-1){const n=new Uint32Array(s.size());let r=0;for(let t=0;t<s.size();t++)n[t]=s.get(t)?r++:0;return new Fp(t,n,e,i,s)}return s?new Dp(t,e,i,s):new Dp(t,e,i)}(t,u,f,o,c)}(r.name,e,i,r.nullable?t-1:t,o);case 0:return function(t,e,i,n,s){const r=Hd(t,e),o=r.numValues,a=e.get(),h=$p(s)?s:void 0,l=Ep(t,o,r.byteLength,e,h);e.set(a+r.byteLength);const c=new Yd(l,o);return new Sp(i.name,c,s)}(e,i,r,0,a);case 6:case 5:return function(t,e,i,n,s){const r=Hd(t,e),o=op(r,n,t,e,"int64"),a=5===s.physicalType;if(o===Vd.FLAT){const s=$p(n)?n:void 0,o=a?function(t,e,i,n){return function(t,e,i){let n;switch(e.logicalLevelTechnique1){case fd.DELTA:if(e.logicalLevelTechnique2===fd.RLE){const s=e;if(!i)return function(t,e,i){const n=new BigInt64Array(i);let s=0,r=0n;for(let i=0;i<e;i++){const o=Number(t[i]),a=Fd(t[i+e]);for(let t=0;t<o;t++)r+=a,n[s++]=r}return n}(t,s.runs,s.numRleValues);n=Rd(t=$d(t,s.runs,s.numRleValues))}else n=Rd(t);break;case fd.RLE:n=function(t,e,i){if(void 0===i){i=0;for(let n=0;n<e;n++)i+=Number(t[n])}const n=new BigInt64Array(i);let s=0;for(let i=0;i<e;i++){const r=Number(t[i]);let o=t[i+e];o=Fd(o),n.fill(o,s,s+r),s+=r}return n}(t,e.runs,e.numRleValues);break;case fd.NONE:n=function(t){const e=new BigInt64Array(t.length);for(let i=0;i<t.length;i++)e[i]=Fd(t[i]);return e}(t);break;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Xd(n,i,0n):n}(Ad(t,e,i.numValues),i,n)}(t,e,r,s):sp(t,e,r,s);return new ap(i.name,o,n)}if(o===Vd.SEQUENCE){const n=np(t,e,r);return new hp(i.name,n[0],n[1],r.numRleValues)}const h=a?function(t,e,i){const n=Ad(t,e,i.numValues);return 1===n.length?Fd(n[0]):function(t){return Fd(t[1])}(n)}(t,e,r):rp(t,e,r);return new Tp(i.name,h,n,a)}(e,i,r,a,s);case 7:return function(t,e,i,n){const s=Hd(t,e),r=$p(n)?n:void 0,o=function(t,e,i,n){const s=e.get(),r=s+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(s,r)).buffer,a=new Float32Array(o);return e.set(r),n?Xd(a,n,0):a}(t,e,s.numValues,r);return new zp(i.name,o,n)}(e,i,r,a);case 8:return function(t,e,i,n){const s=Hd(t,e),r=$p(n)?n:void 0,o=function(t,e,i,n){const s=e.get(),r=s+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(s,r)).buffer,a=new Float64Array(o);return e.set(r),n?Xd(a,n,0):a}(t,e,s.numValues,r);return new od(i.name,o,n)}(e,i,r,a);default:throw new Error(`The specified data type for the field is currently not supported: ${s}`)}}(n,t,e,s,i.scalarType,i):0===n?null:function(t,e,i,n){let s=null,r=null,o=null,a=null,h=!1;for(;!h;){const i=Hd(t,e);switch(i.physicalStreamType){case Bd.LENGTH:Gd.DICTIONARY===i.logicalStreamType.lengthType?s=Qd(t,e,i):o=Qd(t,e,i);break;case Bd.DATA:Nd.SINGLE===i.logicalStreamType.dictionaryType||Nd.SHARED===i.logicalStreamType.dictionaryType?(r=t.subarray(e.get(),e.get()+i.byteLength),h=!0):a=t.subarray(e.get(),e.get()+i.byteLength),e.add(i.byteLength)}}const l=i.complexType.children,c=[];let u=0;for(const h of l){const l=Ed(t,e,1)[0];if(0===l)continue;const f=h.name?`${i.name}${h.name}`:i.name;if(2!==l||"scalarField"!==h.type||9!==h.scalarField.physicalType)throw new Error("Currently only optional string fields are implemented for a struct.");const d=Hd(t,e),p=Ep(t,d.numValues,d.byteLength,e),m=Hd(t,e),_=Kd(t,e,m,0,m.decompressedCount!==n?new Yd(p,d.numValues):void 0);c[u++]=a?new Ip(f,_,s,r,o,a,new Yd(p,d.numValues)):new Fp(f,_,s,r,new Yd(p,d.numValues))}return c}(t,e,i,s)}function $p(t){return t instanceof Yd}function Op(t){switch(t){case 0:case 1:case 2:case 3:{const e={};e.nullable=!!(1&t),e.columnScope=0;const i={type:"logicalType",logicalType:0};return i.longID=!!(2&t),e.scalarType=i,e.type="scalarType",e}case 4:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:0};return t.type="complexType",t.complexType=e,t}case 30:{const t={nullable:!1,columnScope:0},e={type:"physicalType",physicalType:1};return t.type="complexType",t.complexType=e,t}default:return function(t){let e;switch(t){case 10:case 11:e=0;break;case 12:case 13:e=1;break;case 14:case 15:e=2;break;case 16:case 17:e=3;break;case 18:case 19:e=4;break;case 20:case 21:e=5;break;case 22:case 23:e=6;break;case 24:case 25:e=7;break;case 26:case 27:e=8;break;case 28:case 29:e=9;break;default:return null}const i={};i.nullable=!!(1&t),i.columnScope=0;const n={type:"physicalType"};return n.physicalType=e,i.type="scalarType",i.scalarType=n,i}(t)}}function jp(t){return t>=10}function Rp(t){return 30===t}function Lp(t){if("scalarType"===t.type){const e=t.scalarType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}if("logicalType"===e.type)return!1}else if("complexType"===t.type){const e=t.complexType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}function Bp(t){return"complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const Np=new TextDecoder;function Up(t,e){const i=Ed(t,e,1)[0];if(0===i)return"";const n=e.get(),s=t.subarray(n,n+i);return e.add(i),Np.decode(s)}function Gp(t,e){const i=Ed(t,e,1)[0]>>>0;if(i<10||i>30)throw new Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT)`);const n=Op(i);if(jp(i)&&(n.name=Up(t,e)),Rp(i)){const i=Ed(t,e,1)[0]>>>0;n.complexType.children=new Array(i);for(let s=0;s<i;s++)n.complexType.children[s]=Gp(t,e)}return function(t){return{name:t.name,nullable:t.nullable,scalarField:t.scalarType,complexField:t.complexType,type:"scalarType"===t.type?"scalarField":"complexField"}}(n)}function Vp(t,e){const i=Ed(t,e,1)[0]>>>0,n=Op(i);if(!n)throw new Error(`Unsupported column type code ${i}. Supported: 0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT)`);if(jp(i)?n.name=Up(t,e):i>=0&&i<=3?n.name="id":4===i&&(n.name="geometry"),Rp(i)){const i=Ed(t,e,1)[0]>>>0,s=n.complexType;s.children=new Array(i);for(let n=0;n<i;n++)s.children[n]=Gp(t,e)}return n}function qp(t,e){const i={featureTables:[]},n={};n.name=Up(t,e);const s=Ed(t,e,1)[0]>>>0,r=Ed(t,e,1)[0]>>>0;n.columns=new Array(r);for(let i=0;i<r;i++)n.columns[i]=Vp(t,e);return i.featureTables.push(n),[i,s]}function Zp(t,e,i,n,s,r,o=!1){const a=e.scalarType;if(!a||"logicalType"!==a.type||0!==a.logicalType)throw new Error(`ID column must be a logical ID scalar type: ${n}`);const h=a.longID?6:4,l="number"==typeof r?void 0:r,c=op(s,r,t,i,6===h?"int64":"int32");if(4===h)switch(c){case Vd.FLAT:{const e=Kd(t,i,s,0,l);return new rd(n,e,r)}case Vd.SEQUENCE:{const e=ip(t,i,s);return new hd(n,e[0],e[1],s.numRleValues)}case Vd.CONST:{const e=ep(t,i,s);return new ld(n,e,r,!1)}}switch(c){case Vd.FLAT:{if(o){const e=function(t,e,i){const n=function(t,e,i){const n=new Float64Array(i);for(let s=0;s<i;s++)n[s]=Cd(t,e);return n}(t,e,i.numValues);return function(t,e){switch(e.logicalLevelTechnique1){case fd.DELTA:return e.logicalLevelTechnique2===fd.RLE&&(t=Od(t,e.runs,e.numRleValues)),function(t){t[0]=Id(t[0]);const e=t.length/4*4;let i=1;if(e>=4)for(;i<e-4;i+=4){const e=t[i+1],n=t[i+2],s=t[i+3];t[i]=Id(t[i])+t[i-1],t[i+1]=Id(e)+t[i],t[i+2]=Id(n)+t[i+1],t[i+3]=Id(s)+t[i+2]}for(;i!==t.length;++i)t[i]=Id(t[i])+t[i-1]}(t),t;case fd.RLE:return function(t,e){return Od(t,e.runs,e.numRleValues)}(t,e);case fd.NONE:return t;default:throw new Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(n,i)}(t,i,s);return new od(n,e,r)}const e=sp(t,i,s,l);return new ap(n,e,r)}case Vd.SEQUENCE:{const e=np(t,i,s);return new hp(n,e[0],e[1],s.numRleValues)}case Vd.CONST:{const e=rp(t,i,s);return new Tp(n,e,r,!1)}}throw new Error("Vector type not supported for id column.")}class Wp{constructor(t,e){var i;switch(this._featureData=t,this.properties=this._featureData.properties||{},null===(i=this._featureData.geometry)||void 0===i?void 0:i.type){case qd.POINT:case qd.MULTIPOINT:this.type=1;break;case qd.LINESTRING:case qd.MULTILINESTRING:this.type=2;break;case qd.POLYGON:case qd.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=e,this.id=Number(this._featureData.id)}loadGeometry(){const t=[];for(const e of this._featureData.geometry.coordinates){const n=[];for(const t of e)n.push(new i(t.x,t.y));t.push(n)}return t}}class Hp{constructor(t){this.features=[],this.featureTable=t,this.name=t.name,this.extent=t.extent,this.version=2,this.features=t.getFeatures(),this.length=this.features.length}feature(t){return new Wp(this.features[t],this.extent)}}class Yp{constructor(t){this.layers={};const e=function(t,e,i=!0){const n=new ud(0),s=[];for(;n.get()<t.length;){const e=Ed(t,n,1)[0]>>>0,o=n.get()+e;if(o>t.length)throw new Error(`Block overruns tile: ${o} > ${t.length}`);if(1!=Ed(t,n,1)[0]>>>0){n.set(o);continue}const[a,h]=qp(t,n),l=a.featureTables[0];let c=null,u=null;const f=[];let d=0;for(const e of l.columns){const s=e.name;if("scalarType"===(r=e).type&&"logicalType"===r.scalarType?.type&&0===r.scalarType.logicalType){let r=null;if(e.nullable){const e=Hd(t,n),i=n.get(),s=Ep(t,e.numValues,e.byteLength,n);n.set(i+e.byteLength),r=new Yd(s,e.numValues)}const o=Hd(t,n);d=r?r.size():o.decompressedCount,c=Zp(t,e,n,s,o,r??d,i)}else if(Bp(e)){const e=Ed(t,n,1)[0];if(0===d){const e=n.get();d=Hd(t,n).decompressedCount,n.set(e)}u=bp(t,e,n,d)}else{const i=Lp(e)?Ed(t,n,1)[0]:1;if(0===i)continue;const s=kp(t,n,e,i,d);if(s)if(Array.isArray(s))for(const t of s)f.push(t);else f.push(s)}}const p=new cd(l.name,u,c,f,h);s.push(p),n.set(o)}var r;return s}(new Uint8Array(t));this.layers=e.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e.name]:new Hp(e)})),{})}}class Xp{constructor(t,e){this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},this.extent=e,"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],e=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of e){const e=[];for(const t of n)e.push(new i(t[0],t[1]));t.push(e)}return t}}const Jp="_geojsonTileLayer";function Kp(t,e,i=""){e.writeVarintField(15,t.version||1),e.writeStringField(1,t.name||""),e.writeVarintField(5,t.extent||4096);const n={jsonPrefix:i,keys:[],values:[],keycache:{},valuecache:{}};for(let i=0;i<t.length;i++)n.feature=t.feature(i),e.writeMessage(2,Qp,n);const s=n.keys;for(const t of s)e.writeStringField(3,t);const r=n.values;for(const t of r)e.writeMessage(4,sm,t)}function Qp(t,e){if(!t.feature)return;const i=t.feature;void 0!==i.id&&e.writeVarintField(1,i.id),e.writeMessage(2,tm,t),e.writeVarintField(3,i.type),e.writeMessage(4,nm,i)}function tm(t,e){for(const i in t.feature?.properties){let n=t.feature.properties[i],s=t.keycache[i];if(null==n)continue;void 0===s&&(t.keys.push(i),s=t.keys.length-1,t.keycache[i]=s),e.writeVarint(s),"string"!=typeof n&&"boolean"!=typeof n&&"number"!=typeof n&&(n=t.jsonPrefix+JSON.stringify(n));const r=typeof n+":"+n;let o=t.valuecache[r];void 0===o&&(t.values.push(n),o=t.values.length-1,t.valuecache[r]=o),e.writeVarint(o)}}function em(t,e){return(e<<3)+(7&t)}function im(t){return t<<1^t>>31}function nm(t,e){const i=t.loadGeometry(),n=t.type;let s=0,r=0;for(const o of i){let i=1;1===n&&(i=o.length),e.writeVarint(em(1,i));const a=3===n?o.length-1:o.length;for(let t=0;t<a;t++){1===t&&1!==n&&e.writeVarint(em(2,a-1));const i=o[t].x-s,h=o[t].y-r;e.writeVarint(im(i)),e.writeVarint(im(h)),s+=i,r+=h}3===t.type&&e.writeVarint(em(7,1))}}function sm(t,e){const i=typeof t;"string"===i?e.writeStringField(1,t):"boolean"===i?e.writeBooleanField(7,t):"number"===i&&(t%1!=0?e.writeDoubleField(3,t):t<0?e.writeSVarintField(6,t):e.writeVarintField(5,t))}class rm{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new ur(P,16,0),this.grid3D=new ur(P,16,0),this.featureIndexArray=new Vo,this.promoteId=e}insert(t,e,i,n,s,r){const o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,s);const a=r?this.grid3D:this.grid;for(const t of e){const e=[1/0,1/0,-1/0,-1/0];for(const i of t)e[0]=Math.min(e[0],i.x),e[1]=Math.min(e[1],i.y),e[2]=Math.max(e[2],i.x),e[3]=Math.max(e[3],i.y);e[0]<P&&e[1]<P&&e[2]>=0&&e[3]>=0&&a.insert(o,e[0],e[1],e[2],e[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Bl(new Lu(this.rawTileData)).layers:new Yp(this.rawTileData).layers,this.sourceLayerCoder=new ed(this.vtLayers?Object.keys(this.vtLayers).sort():[Jp])),this.vtLayers}query(t,e,n,s){this.loadVTLayers();const r=t.params,o=P/t.tileSize/t.scale,a=ps(r.filter,r.globalState),h=t.queryGeometry,l=t.queryPadding*o,c=td.fromPoints(h),u=this.grid.query(c.minX-l,c.minY-l,c.maxX+l,c.maxY+l),f=td.fromPoints(t.cameraQueryGeometry).expandBy(l),d=this.grid3D.query(f.minX,f.minY,f.maxX,f.maxY,((e,n,s,r)=>function(t,e,n,s,r){for(const i of t)if(e<=i.x&&n<=i.y&&s>=i.x&&r>=i.y)return!0;const o=[new i(e,n),new i(e,r),new i(s,r),new i(s,n)];if(t.length>2)for(const e of o)if(nh(t,e))return!0;for(let e=0;e<t.length-1;e++)if(sh(t[e],t[e+1],o))return!0;return!1}(t.cameraQueryGeometry,e-l,n-l,s+l,r+l)));for(const t of d)u.push(t);u.sort(am);const p={};let m;for(const i of u){if(i===m)continue;m=i;const l=this.featureIndexArray.get(i);let c=null;this.loadMatchingFeature(p,l.bucketIndex,l.sourceLayerIndex,l.featureIndex,a,r.layers,r.availableImages,e,n,s,((e,i,n)=>(c||(c=Ga(e)),i.queryIntersectsFeature({queryGeometry:h,feature:e,featureState:n,geometry:c,zoom:this.z,transform:t.transform,pixelsToTileUnits:o,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))))}return p}loadMatchingFeature(t,e,i,n,s,r,o,a,h,l,c){const u=this.bucketLayerIDs[e];if(r&&!u.some((t=>r.has(t))))return;const f=this.sourceLayerCoder.decode(i),d=this.vtLayers[f].feature(n);if(s.needGeometry){const t=Va(d,!0);if(!s.filter(new kr(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!s.filter(new kr(this.tileID.overscaledZ),d))return;const p=this.getId(d,f);for(const e of u){if(r&&!r.has(e))continue;const i=a[e];if(!i)continue;let s={};p&&l&&(s=l.getState(i.sourceLayer||Jp,p));const u=L({},h[e]);u.paint=om(u.paint,i.paint,d,s,o),u.layout=om(u.layout,i.layout,d,s,o);const f=!c||c(d,i,s);if(!f)continue;const m=new id(d,this.z,this.x,this.y,p);m.layer=u;let _=t[e];void 0===_&&(_=t[e]=[]),_.push({featureIndex:n,feature:m,intersectionZ:f})}}lookupSymbolFeatures(t,e,i,n,s,r,o,a){const h={};this.loadVTLayers();const l=ps(s.filterSpec,s.globalState);for(const s of t)this.loadMatchingFeature(h,i,n,s,l,r,o,a,e);return h}hasLayer(t){for(const e of this.bucketLayerIDs)for(const i of e)if(t===i)return!0;return!1}getId(t,e){var i;let n=t.id;return this.promoteId&&(n=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof n&&(n=Number(n)),void 0===n&&(null===(i=t.properties)||void 0===i?void 0:i.cluster)&&this.promoteId&&(n=Number(t.properties.cluster_id))),n}}function om(t,e,i,n,s){return N(t,((t,r)=>{const o=e instanceof Vr?e.get(r):null;return(null==o?void 0:o.evaluate)?o.evaluate(i,n,s):o}))}function am(t,e){return e-t}function hm(t,e,n,s,r){const o=[];for(const a of t){let t;for(let h=0;h<a.length-1;h++){let l=a[h],c=a[h+1];l.x<e&&c.x<e||(l.x<e?l=new i(e,l.y+(e-l.x)/(c.x-l.x)*(c.y-l.y))._round():c.x<e&&(c=new i(e,l.y+(e-l.x)/(c.x-l.x)*(c.y-l.y))._round()),l.y<n&&c.y<n||(l.y<n?l=new i(l.x+(n-l.y)/(c.y-l.y)*(c.x-l.x),n)._round():c.y<n&&(c=new i(l.x+(n-l.y)/(c.y-l.y)*(c.x-l.x),n)._round()),l.x>=s&&c.x>=s||(l.x>=s?l=new i(s,l.y+(s-l.x)/(c.x-l.x)*(c.y-l.y))._round():c.x>=s&&(c=new i(s,l.y+(s-l.x)/(c.x-l.x)*(c.y-l.y))._round()),l.y>=r&&c.y>=r||(l.y>=r?l=new i(l.x+(r-l.y)/(c.y-l.y)*(c.x-l.x),r)._round():c.y>=r&&(c=new i(l.x+(r-l.y)/(c.y-l.y)*(c.x-l.x),r)._round()),t&&l.equals(t[t.length-1])||(t=[l],o.push(t)),t.push(c)))))}}return o}function lm(t,e,i,n,s){switch(e){case 1:return function(t,e,i,n){const s=[];for(const r of t)for(const t of r){const r=0===n?t.x:t.y;r>=e&&r<=i&&s.push([t])}return s}(t,i,n,s);case 2:return um(t,i,n,s,!1);case 3:return um(t,i,n,s,!0)}return[]}function cm(t,e,n,s,r){const o=0===s?fm:dm;let a=[];const h=[];for(let i=0;i<t.length-1;i++){const l=t[i],c=t[i+1],u=0===s?l.x:l.y,f=0===s?c.x:c.y;let d=!1;u<e?f>e&&a.push(o(l,c,e)):u>n?f<n&&a.push(o(l,c,n)):a.push(l),f<e&&u>=e&&(a.push(o(l,c,e)),d=!0),f>n&&u<=n&&(a.push(o(l,c,n)),d=!0),!r&&d&&(h.push(a),a=[])}const l=t.length-1,c=0===s?t[l].x:t[l].y;return c>=e&&c<=n&&a.push(t[l]),r&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&h.push(a),h}function um(t,e,i,n,s){const r=[];for(const o of t){const t=cm(o,e,i,n,s);t.length>0&&r.push(...t)}return r}function fm(t,e,n){return new i(n,t.y+(n-t.x)/(e.x-t.x)*(e.y-t.y))}function dm(t,e,n){return new i(t.x+(n-t.y)/(e.y-t.y)*(e.x-t.x),n)}dr("FeatureIndex",rm,{omit:["rawTileData","sourceLayerCoder"]});class pm extends i{constructor(t,e,i,n){super(t,e),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new pm(this.x,this.y,this.angle,this.segment)}}function mm(t,e,i,n,s){if(void 0===e.segment||0===i)return!0;let r=e,o=e.segment+1,a=0;for(;a>-i/2;){if(o--,o<0)return!1;a-=t[o].dist(r),r=t[o]}a+=t[o].dist(t[o+1]),o++;const h=[];let l=0;for(;a<i/2;){const e=t[o],i=t[o+1];if(!i)return!1;let r=t[o-1].angleTo(e)-e.angleTo(i);for(r=Math.abs((r+3*Math.PI)%(2*Math.PI)-Math.PI),h.push({distance:a,angleDelta:r}),l+=r;a-h[0].distance>n;)l-=h.shift().angleDelta;if(l>s)return!1;o++,a+=e.dist(i)}return!0}function _m(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function gm(t,e,i){return t?.6*e*i:0}function vm(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function ym(t,e,i,n,s,r){const o=gm(i,s,r),a=vm(i,n)*r;let h=0;const l=_m(t)/2;for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1],r=n.dist(s);if(h+r>l){const c=(l-h)/r,u=_i.number(n.x,s.x,c),f=_i.number(n.y,s.y,c),d=new pm(u,f,s.angleTo(n),i);return d._round(),!o||mm(t,d,a,o,e)?d:void 0}h+=r}}function wm(t,e,i,n,s,r,o,a,h){const l=gm(n,r,o),c=vm(n,s),u=c*o,f=0===t[0].x||t[0].x===h||0===t[0].y||t[0].y===h;return e-u<e/4&&(e=u+e/4),bm(t,f?e/2*a%e:(c/2+2*r)*o*a%e,e,l,i,u,f,!1,h)}function bm(t,e,i,n,s,r,o,a,h){const l=r/2,c=_m(t);let u=0,f=e-i,d=[];for(let e=0;e<t.length-1;e++){const o=t[e],a=t[e+1],p=o.dist(a),m=a.angleTo(o);for(;f+i<u+p;){f+=i;const _=(f-u)/p,g=_i.number(o.x,a.x,_),v=_i.number(o.y,a.y,_);if(g>=0&&g<h&&v>=0&&v<h&&f-l>=0&&f+l<=c){const i=new pm(g,v,m,e);i._round(),n&&!mm(t,i,r,n,s)||d.push(i)}}u+=p}return a||d.length||o||(d=bm(t,u/2,i,n,s,r,o,!0,h)),d}function xm(t,e,n,s){const r=[],o=t.image,a=o.pixelRatio,h=o.paddedRect.w-2,l=o.paddedRect.h-2;let c={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom};const u=o.stretchX||[[0,h]],f=o.stretchY||[[0,l]],d=(t,e)=>t+e[1]-e[0],p=u.reduce(d,0),m=f.reduce(d,0),_=h-p,g=l-m;let v=0,y=p,w=0,b=m,x=0,M=_,S=0,z=g;if(o.content&&s){const e=o.content,i=e[2]-e[0],n=e[3]-e[1];(o.textFitWidth||o.textFitHeight)&&(c=pf(t)),v=Mm(u,0,e[0]),w=Mm(f,0,e[1]),y=Mm(u,e[0],e[2]),b=Mm(f,e[1],e[3]),x=e[0]-v,S=e[1]-w,M=i-y,z=n-b}const T=c.x1,E=c.y1,A=c.x2-T,P=c.y2-E,C=(t,s,r,h)=>{const l=zm(t.stretch-v,y,A,T),c=Tm(t.fixed-x,M,t.stretch,p),u=zm(s.stretch-w,b,P,E),f=Tm(s.fixed-S,z,s.stretch,m),d=zm(r.stretch-v,y,A,T),_=Tm(r.fixed-x,M,r.stretch,p),g=zm(h.stretch-w,b,P,E),C=Tm(h.fixed-S,z,h.stretch,m),D=new i(l,u),F=new i(d,u),I=new i(d,g),k=new i(l,g),$=new i(c/a,f/a),O=new i(_/a,C/a),j=e*Math.PI/180;if(j){const t=Math.sin(j),e=Math.cos(j),i=[e,-t,t,e];D._matMult(i),F._matMult(i),k._matMult(i),I._matMult(i)}const R=t.stretch+t.fixed,L=s.stretch+s.fixed;return{tl:D,tr:F,bl:k,br:I,tex:{x:o.paddedRect.x+1+R,y:o.paddedRect.y+1+L,w:r.stretch+r.fixed-R,h:h.stretch+h.fixed-L},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:$,pixelOffsetBR:O,minFontScaleX:M/a/A,minFontScaleY:z/a/P,isSDF:n}};if(s&&(o.stretchX||o.stretchY)){const t=Sm(u,_,p),e=Sm(f,g,m);for(let i=0;i<t.length-1;i++){const n=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)r.push(C(n,e[t],s,e[t+1]))}}else r.push(C({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:h+1},{fixed:0,stretch:l+1}));return r}function Mm(t,e,i){let n=0;for(const s of t)n+=Math.max(e,Math.min(i,s[1]))-Math.max(e,Math.min(i,s[0]));return n}function Sm(t,e,i){const n=[{fixed:-1,stretch:0}];for(const[e,i]of t){const t=n[n.length-1];n.push({fixed:e-t.stretch,stretch:t.stretch}),n.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return n.push({fixed:e+1,stretch:i}),n}function zm(t,e,i,n){return t/e*i+n}function Tm(t,e,i,n){return t-e*i/n}dr("Anchor",pm);class Em{constructor(t,e,n,s,r,o,a,h,l,c){var u;if(this.boxStartIndex=t.length,l){let t=o.top,e=o.bottom;const i=o.collisionPadding;i&&(t-=i[1],e+=i[3]);let n=e-t;n>0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const l=(null===(u=o.image)||void 0===u?void 0:u.content)&&(o.image.textFitWidth||o.image.textFitHeight)?pf(o):{x1:o.left,y1:o.top,x2:o.right,y2:o.bottom};l.y1=l.y1*a-h[0],l.y2=l.y2*a+h[2],l.x1=l.x1*a-h[3],l.x2=l.x2*a+h[1];const f=o.collisionPadding;if(f&&(l.x1-=f[0]*a,l.y1-=f[1]*a,l.x2+=f[2]*a,l.y2+=f[3]*a),c){const t=new i(l.x1,l.y1),e=new i(l.x2,l.y1),n=new i(l.x1,l.y2),s=new i(l.x2,l.y2),r=c*Math.PI/180;t._rotate(r),e._rotate(r),n._rotate(r),s._rotate(r),l.x1=Math.min(t.x,e.x,n.x,s.x),l.x2=Math.max(t.x,e.x,n.x,s.x),l.y1=Math.min(t.y,e.y,n.y,s.y),l.y2=Math.max(t.y,e.y,n.y,s.y)}t.emplaceBack(e.x,e.y,l.x1,l.y1,l.x2,l.y2,n,s,r)}this.boxEndIndex=t.length}}class Am{constructor(t=[],e=(t,e)=>t<e?-1:t>e?1:0){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this._down(t)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return--this.length>0&&(this.data[0]=e,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:e,compare:i}=this,n=e[t];for(;t>0;){const s=t-1>>1,r=e[s];if(i(n,r)>=0)break;e[t]=r,t=s}e[t]=n}_down(t){const{data:e,compare:i}=this,n=this.length>>1,s=e[t];for(;t<n;){let n=1+(t<<1);const r=n+1;if(r<this.length&&i(e[r],e[n])<0&&(n=r),i(e[n],s)>=0)break;e[t]=e[n],t=n}e[t]=s}}function Pm(t,e=1){const n=td.fromPoints(t[0]),s=Math.min(n.width(),n.height());let r=s/2;const o=new Am([],Cm),{minX:a,minY:h,maxX:l,maxY:c}=n;if(0===s)return new i(a,h);for(let e=a;e<l;e+=s)for(let i=h;i<c;i+=s)o.push(new Dm(e+r,i+r,r,t));const u=function(t){let e=0,i=0,n=0;const s=t[0];for(let t=0,r=s.length,o=r-1;t<r;o=t++){const r=s[t],a=s[o],h=r.x*a.y-a.x*r.y;i+=(r.x+a.x)*h,n+=(r.y+a.y)*h,e+=3*h}return new Dm(i/e,n/e,0,t)}(t);let f=u;for(;o.length;){const i=o.pop();(i.d>f.d||!f.d)&&(f=i),i.max-f.d<=e||(r=i.h/2,o.push(new Dm(i.p.x-r,i.p.y-r,r,t)),o.push(new Dm(i.p.x+r,i.p.y-r,r,t)),o.push(new Dm(i.p.x-r,i.p.y+r,r,t)),o.push(new Dm(i.p.x+r,i.p.y+r,r,t)))}return u.d>0&&f.d-u.d<=e?u.p:f.p}function Cm(t,e){return e.max-t.max}class Dm{constructor(t,e,n,s){this.p=new i(t,e),this.h=n,this.d=function(t,e){let i=!1,n=1/0;for(const s of e)for(let e=0,r=s.length,o=r-1;e<r;o=e++){const r=s[e],a=s[o];r.y>t.y!=a.y>t.y&&t.x<(a.x-r.x)*(t.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,eh(t,r,a))}return(i?1:-1)*Math.sqrt(n)}(this.p,s),this.max=this.d+this.h*Math.SQRT2}}var Fm;t.aM=void 0,(Fm=t.aM||(t.aM={}))[Fm.center=1]="center",Fm[Fm.left=2]="left",Fm[Fm.right=3]="right",Fm[Fm.top=4]="top",Fm[Fm.bottom=5]="bottom",Fm[Fm["top-left"]=6]="top-left",Fm[Fm["top-right"]=7]="top-right",Fm[Fm["bottom-left"]=8]="bottom-left",Fm[Fm["bottom-right"]=9]="bottom-right";const Im=Number.POSITIVE_INFINITY;function km(t,e){return e[1]!==Im?function(t,e,i){let n=0,s=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":s=i-7;break;case"bottom-right":case"bottom-left":case"bottom":s=7-i}switch(t){case"top-right":case"bottom-right":case"right":n=-e;break;case"top-left":case"bottom-left":case"left":n=e}return[n,s]}(t,e[0],e[1]):function(t,e){let i=0,n=0;e<0&&(e=0);const s=e/Math.SQRT2;switch(t){case"top-right":case"top-left":n=s-7;break;case"bottom-right":case"bottom-left":n=7-s;break;case"bottom":n=7-e;break;case"top":n=e-7}switch(t){case"top-right":case"bottom-right":i=-s;break;case"top-left":case"bottom-left":i=s;break;case"left":i=e;break;case"right":i=-e}return[i,n]}(t,e[0])}function $m(t,e,i){var n;const s=t.layout,r=null===(n=s.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(e,{},i);if(r){const t=r.values,e=[];for(let i=0;i<t.length;i+=2){const n=e[i]=t[i],s=t[i+1].map((t=>t*Tu));n.startsWith("top")?s[1]-=7:n.startsWith("bottom")&&(s[1]+=7),e[i+1]=s}return new Le(e)}const o=s.get("text-variable-anchor");if(o){let n;n=void 0!==t._unevaluatedLayout.getValue("text-radial-offset")?[s.get("text-radial-offset").evaluate(e,{},i)*Tu,Im]:s.get("text-offset").evaluate(e,{},i).map((t=>t*Tu));const r=[];for(const t of o)r.push(t,km(t,n));return new Le(r)}return null}function Om(t){switch(t){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function jm(e,i,n,s,r,o,a,h,l,c,u,f){let d=o.textMaxSize.evaluate(i,{});void 0===d&&(d=a);const p=e.layers[0].layout,m=p.get("icon-offset").evaluate(i,{},u),_=Lm(n.horizontal),g=a/24,v=e.tilePixelRatio*g,y=e.tilePixelRatio*d/24,w=e.tilePixelRatio*h,b=e.tilePixelRatio*p.get("symbol-spacing"),x=p.get("text-padding")*e.tilePixelRatio,M=function(t,e,i,n=1){const s=t.get("icon-padding").evaluate(e,{},i),r=null==s?void 0:s.values;return[r[0]*n,r[1]*n,r[2]*n,r[3]*n]}(p,i,u,e.tilePixelRatio),S=p.get("text-max-angle")/180*Math.PI,z="viewport"!==p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),T="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),E=p.get("symbol-placement"),A=b/2,C=p.get("icon-text-fit");let D;s&&"none"!==C&&(e.allowVerticalPlacement&&n.vertical&&(D=mf(s,n.vertical,C,p.get("icon-text-fit-padding"),m,g)),_&&(s=mf(s,_,C,p.get("icon-text-fit-padding"),m,g)));const F=u?f.line.getGranularityForZoomLevel(u.z):1,I=(h,f)=>{f.x<0||f.x>=P||f.y<0||f.y>=P||function(e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y,w,b,x,M,S,z){const T=e.addToLineVertexArray(i,n);let E,A,P,C,D=0,F=0,I=0,k=0,$=-1,O=-1;const j={};let R=ya("");if(e.allowVerticalPlacement&&s.vertical){const t=h.layout.get("text-rotate").evaluate(b,{},S)+90;P=new Em(l,i,c,u,f,s.vertical,d,p,m,t),a&&(C=new Em(l,i,c,u,f,a,g,v,m,t))}if(r){const n=h.layout.get("icon-rotate").evaluate(b,{}),s="none"!==h.layout.get("icon-text-fit"),o=xm(r,n,M,s),d=a?xm(a,n,M,s):void 0;A=new Em(l,i,c,u,f,r,g,v,!1,n),D=4*o.length;const p=e.iconSizeData;let m=null;"source"===p.kind?(m=[_f*h.layout.get("icon-size").evaluate(b,{})],m[0]>gf&&q(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===p.kind&&(m=[_f*x.compositeIconSizes[0].evaluate(b,{},S),_f*x.compositeIconSizes[1].evaluate(b,{},S)],(m[0]>gf||m[1]>gf)&&q(`${e.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),e.addSymbols(e.icon,o,m,w,y,b,t.ax.none,i,T.lineStartIndex,T.lineLength,-1,S),$=e.icon.placedSymbolArray.length-1,d&&(F=4*d.length,e.addSymbols(e.icon,d,m,w,y,b,t.ax.vertical,i,T.lineStartIndex,T.lineLength,-1,S),O=e.icon.placedSymbolArray.length-1)}const L=Object.keys(s.horizontal);for(const n of L){const r=s.horizontal[n];if(!E){R=ya(r.text);const t=h.layout.get("text-rotate").evaluate(b,{},S);E=new Em(l,i,c,u,f,r,d,p,m,t)}const a=1===r.positionedLines.length;if(I+=Rm(e,i,r,o,h,m,b,_,T,s.vertical?t.ax.horizontal:t.ax.horizontalOnly,a?L:[n],j,$,x,S),a)break}s.vertical&&(k+=Rm(e,i,s.vertical,o,h,m,b,_,T,t.ax.vertical,["vertical"],j,O,x,S));const B=E?E.boxStartIndex:e.collisionBoxArray.length,N=E?E.boxEndIndex:e.collisionBoxArray.length,U=P?P.boxStartIndex:e.collisionBoxArray.length,G=P?P.boxEndIndex:e.collisionBoxArray.length,V=A?A.boxStartIndex:e.collisionBoxArray.length,Z=A?A.boxEndIndex:e.collisionBoxArray.length,W=C?C.boxStartIndex:e.collisionBoxArray.length,H=C?C.boxEndIndex:e.collisionBoxArray.length;let Y=-1;const X=(t,e)=>(null==t?void 0:t.circleDiameter)?Math.max(t.circleDiameter,e):e;Y=X(E,Y),Y=X(P,Y),Y=X(A,Y),Y=X(C,Y);const J=Y>-1?1:0;J&&(Y*=z/Tu),e.glyphOffsetArray.length>=Tf.MAX_GLYPHS&&q("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==b.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,b.sortKey);const K=$m(h,b,S),[Q,tt]=function(e,i){const n=e.length,s=null==i?void 0:i.values;if((null==s?void 0:s.length)>0)for(let i=0;i<s.length;i+=2){const n=s[i+1];e.emplaceBack(t.aM[s[i]],n[0],n[1])}return[n,e.length]}(e.textAnchorOffsets,K);e.symbolInstances.emplaceBack(i.x,i.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical||-1,$,O,R,B,N,U,G,V,Z,W,H,c,I,k,D,F,J,0,d,Y,Q,tt)}(e,f,h,n,s,r,D,e.layers[0],e.collisionBoxArray,i.index,i.sourceLayerIndex,e.index,v,[x,x,x,x],z,l,w,M,T,m,i,o,c,u,a)};if("line"===E)for(const t of hm(i.geometry,0,0,P,P)){const i=xl(t,F),r=wm(i,b,S,n.vertical||_,s,24,y,e.overscaling,P);for(const t of r)_&&Bm(e,_.text,A,t)||I(i,t)}else if("line-center"===E){for(const t of i.geometry)if(t.length>1){const e=xl(t,F),i=ym(e,S,n.vertical||_,s,24,y);i&&I(e,i)}}else if("Polygon"===i.type)for(const t of en(i.geometry,0)){const e=Pm(t,16);I(xl(t[0],F,!0),new pm(e.x,e.y,0))}else if("LineString"===i.type)for(const t of i.geometry){const e=xl(t,F);I(e,new pm(e[0].x,e[0].y,0))}else if("Point"===i.type)for(const t of i.geometry)for(const e of t)I([e],new pm(e.x,e.y,0))}function Rm(t,e,n,s,r,o,a,h,l,c,u,f,d,p,m){const _=function(t,e,n,s,r,o,a,h){const l=s.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=[];for(const t of e.positionedLines)for(const s of t.positionedGlyphs){if(!s.rect)continue;const o=s.rect||{};let u=4,f=!0,d=1,p=0;const m=(r||h)&&s.vertical,_=s.metrics.advance*s.scale/2;if(h&&e.verticalizable&&(p=t.lineOffset/2-(s.imageName?-(Tu-s.metrics.width*s.scale)/2:(s.scale-1)*Tu)),s.imageName){const t=a[s.imageName];f=t.sdf,d=t.pixelRatio,u=1/d}const g=r?[s.x+_,s.y]:[0,0];let v=r?[0,0]:[s.x+_+n[0],s.y+n[1]-p],y=[0,0];m&&(y=v,v=[0,0]);const w=s.metrics.isDoubleResolution?2:1,b=(s.metrics.left-u)*s.scale-_+v[0],x=(-s.metrics.top-u)*s.scale+v[1],M=b+o.w/w*s.scale/d,S=x+o.h/w*s.scale/d,z=new i(b,x),T=new i(M,x),E=new i(b,S),A=new i(M,S);if(m){const t=new i(-_,_- -17),e=-Math.PI/2,n=12-_,r=new i(22-n,-(s.imageName?n:0)),o=new i(...y);z._rotateAround(e,t)._add(r)._add(o),T._rotateAround(e,t)._add(r)._add(o),E._rotateAround(e,t)._add(r)._add(o),A._rotateAround(e,t)._add(r)._add(o)}if(l){const t=Math.sin(l),e=Math.cos(l),i=[e,-t,t,e];z._matMult(i),T._matMult(i),E._matMult(i),A._matMult(i)}const P=new i(0,0),C=new i(0,0);c.push({tl:z,tr:T,bl:E,br:A,tex:o,writingMode:e.writingMode,glyphOffset:g,sectionIndex:s.sectionIndex,isSDF:f,pixelOffsetTL:P,pixelOffsetBR:C,minFontScaleX:0,minFontScaleY:0})}return c}(0,n,h,r,o,a,s,t.allowVerticalPlacement),g=t.textSizeData;let v=null;"source"===g.kind?(v=[_f*r.layout.get("text-size").evaluate(a,{})],v[0]>gf&&q(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(v=[_f*p.compositeTextSizes[0].evaluate(a,{},m),_f*p.compositeTextSizes[1].evaluate(a,{},m)],(v[0]>gf||v[1]>gf)&&q(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,_,v,h,o,a,c,e,l.lineStartIndex,l.lineLength,d,m);for(const e of u)f[e]=t.text.placedSymbolArray.length-1;return 4*_.length}function Lm(t){for(const e in t)return t[e];return null}function Bm(t,e,i,n){const s=t.compareText;if(e in s){const t=s[e];for(let e=t.length-1;e>=0;e--)if(n.dist(t[e])<i)return!0}else s[e]=[];return s[e].push(n),!1}t.$=at,t.A=d,t.B=Or,t.C=cr,t.D=qr,t.E=wt,t.F=rr,t.G=function([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,{x:t*Math.cos(e)*Math.sin(i),y:t*Math.sin(e)*Math.sin(i),z:t*Math.cos(i)}},t.H=_i,t.I=ef,t.J=kr,t.K=ar,t.L=function(t){if(null==H){const e=t.navigator?t.navigator.userAgent:null;H=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return H},t.M=ut,t.N=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Of((()=>this.process())),this.subscription=tt(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=W(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,e){return new Promise(((i,n)=>{const s=Math.round(1e18*Math.random()).toString(36).substring(0,10),r=e?tt(e.signal,"abort",(()=>{null==r||r.unsubscribe(),delete this.resolveRejects[s];const e={id:s,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(e)}),jf):null;this.resolveRejects[s]={resolve:t=>{null==r||r.unsubscribe(),i(t)},reject:t=>{null==r||r.unsubscribe(),n(t)}};const o=[],a=Object.assign(Object.assign({},t),{id:s,sourceMapId:this.mapId,origin:location.origin,data:gr(t.data,o)});this.target.postMessage(a,{transfer:o})}))}receive(t){const e=t.data,i=e.id,n=["file://","resource://android","null"],s=[e.origin,location.origin],r=e.origin===location.origin,o=s.some((t=>n.includes(t)));if((r||o)&&(!e.targetMapId||this.mapId===e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];const t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(W(self)||e.mustQueue)return this.tasks[i]=e,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,e)}}process(){if(0===this.taskQueue.length)return;const t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}processTask(t,i){return e(this,void 0,void 0,(function*(){if("<response>"===i.type){const e=this.resolveRejects[t];if(delete this.resolveRejects[t],!e)return;return void(i.error?e.reject(D(vr(i.error))):e.resolve(vr(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(t,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const e=vr(i.data),n=new AbortController;this.abortControllers[t]=n;try{const s=yield this.messageHandlers[i.type](i.sourceMapId,e,n);this.completeTask(t,null,s)}catch(e){this.completeTask(t,D(e))}}))}completeTask(t,e,i){const n=[];delete this.abortControllers[t];const s={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?gr(e):null,data:gr(i,n)};this.target.postMessage(s,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},t.O=function(){var t=new d(16);return d!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t},t.P=i,t.Q=function(t,e,i){var n,s,r,o,a,h,l,c,u,f,d,p,m=i[0],_=i[1],g=i[2];return e===t?(t[12]=e[0]*m+e[4]*_+e[8]*g+e[12],t[13]=e[1]*m+e[5]*_+e[9]*g+e[13],t[14]=e[2]*m+e[6]*_+e[10]*g+e[14],t[15]=e[3]*m+e[7]*_+e[11]*g+e[15]):(s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],c=e[7],u=e[8],f=e[9],d=e[10],p=e[11],t[0]=n=e[0],t[1]=s,t[2]=r,t[3]=o,t[4]=a,t[5]=h,t[6]=l,t[7]=c,t[8]=u,t[9]=f,t[10]=d,t[11]=p,t[12]=n*m+a*_+u*g+e[12],t[13]=s*m+h*_+f*g+e[13],t[14]=r*m+l*_+d*g+e[14],t[15]=o*m+c*_+p*g+e[15]),t},t.R=Th,t.S=function(t,e,i){var n=i[0],s=i[1],r=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.T=jh,t.U=function(t,e,i){var n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],h=e[5],l=e[6],c=e[7],u=e[8],f=e[9],d=e[10],p=e[11],m=e[12],_=e[13],g=e[14],v=e[15],y=i[0],w=i[1],b=i[2],x=i[3];return t[0]=y*n+w*a+b*u+x*m,t[1]=y*s+w*h+b*f+x*_,t[2]=y*r+w*l+b*d+x*g,t[3]=y*o+w*c+b*p+x*v,t[4]=(y=i[4])*n+(w=i[5])*a+(b=i[6])*u+(x=i[7])*m,t[5]=y*s+w*h+b*f+x*_,t[6]=y*r+w*l+b*d+x*g,t[7]=y*o+w*c+b*p+x*v,t[8]=(y=i[8])*n+(w=i[9])*a+(b=i[10])*u+(x=i[11])*m,t[9]=y*s+w*h+b*f+x*_,t[10]=y*r+w*l+b*d+x*g,t[11]=y*o+w*c+b*p+x*v,t[12]=(y=i[12])*n+(w=i[13])*a+(b=i[14])*u+(x=i[15])*m,t[13]=y*s+w*h+b*f+x*_,t[14]=y*r+w*l+b*d+x*g,t[15]=y*o+w*c+b*p+x*v,t},t.V=function(t,e){const i={};for(const n of e)n in t&&(i[n]=t[n]);return i},t.W=Lf,t.X=R,t.Y=Gf,t.Z=Uf,t._=e,t.a=ot,t.a$=function(t){var e=new d(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},t.a0=c,t.a1=u,t.a2=J,t.a3=Kf,t.a4=qf,t.a5=Zf,t.a6=P,t.a7=Hf,t.a8=td,t.a9=25,t.aA=function(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)},t.aB=function(t){return t[0]=0,t[1]=0,t},t.aC=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t},t.aD=xf,t.aE=S,t.aF=function(t,e,n,s){const r=e.y-t.y,o=e.x-t.x,a=s.y-n.y,h=s.x-n.x,l=a*o-h*r;if(0===l)return null;const c=(h*(t.y-n.y)-a*(t.x-n.x))/l;return new i(t.x+c*o,t.y+c*r)},t.aG=hm,t.aH=Ha,t.aI=function(t){let e=1/0,i=1/0,n=-1/0,s=-1/0;for(const r of t)e=Math.min(e,r.x),i=Math.min(i,r.y),n=Math.max(n,r.x),s=Math.max(s,r.y);return[e,i,n,s]},t.aJ=Tu,t.aK=C,t.aL=function(t,e,i,n,s=!1){if(!i[0]&&!i[1])return[0,0];const r=s?"map"===n?-t.bearingInRadians:0:"viewport"===n?t.bearingInRadians:0;if(r){const t=Math.sin(r),e=Math.cos(r);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[s?i[0]:C(e,i[0],t.zoom),s?i[1]:C(e,i[1],t.zoom)]},t.aN=yf,t.aO=Om,t.aP=of,t.aQ=t=>"symbol"===t.type,t.aR=tc,t.aS=oo,t.aT=gl,t.aU=qo,t.aV=ha,t.aW=sa,t.aX=it,t.aY=Wf,t.aZ=w,t.a_=y,t.aa=Xf,t.ab=t=>{const e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(const i of t){const t=window.document.createElement("source");mt(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))},t.ac=It,t.ad=function(){return B++},t.ae=ko,t.af=Tf,t.ag=Jp,t.ah=ps,t.ai=Va,t.aj=id,t.ak=function(t){const e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,n,s)=>{const r=n||s;return e[i]=!r||r.toLowerCase(),""})),e["max-age"]){const t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e},t.al=j,t.am=85.051129,t.an=et,t.ao=function(t){return Math.pow(2,t)},t.ap=m,t.aq=Vf,t.ar=function(t){return Math.log(t)/Math.LN2},t.as=function(t){var e=t[0],i=t[1];return e*e+i*i},t.at=function(t){if(!t.length)return new Set;const e=Math.max(...t.map((t=>t.canonical.z)));let i=1/0,n=-1/0,s=1/0,r=-1/0;const o=[];for(const a of t){const{x:t,y:h,z:l}=a.canonical,c=Math.pow(2,e-l),u=t*c,f=h*c;o.push({id:a,x:u,y:f}),u<i&&(i=u),u>n&&(n=u),f<s&&(s=f),f>r&&(r=f)}const a=new Set;for(const t of o)t.x!==i&&t.x!==n&&t.y!==s&&t.y!==r||a.add(t.id);return a},t.au=function(t,e){const i=Math.abs(2*t.wrap)-+(t.wrap<0),n=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||n-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x},t.av=class{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(const t in this.data)for(const e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){const n=t.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const s={value:e,timeout:void 0};if(void 0!==i&&(s.timeout=setTimeout((()=>{this.remove(t,s)}),i)),this.data[n].push(s),this.order.push(n),this.order.length>this.max){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const e=this.data[t].shift();return e.timeout&&clearTimeout(e.timeout),0===this.data[t].length&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),e.value}getByKey(t){const e=this.data[t];return e?e[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,e){if(!this.has(t))return this;const i=t.wrapped().key,n=void 0===e?0:this.data[i].indexOf(e),s=this.data[i][n];return this.data[i].splice(n,1),s.timeout&&clearTimeout(s.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(s.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){const e=[];for(const i in this.data)for(const n of this.data[i])t(n.value)||e.push(n);for(const t of e)this.remove(t.value.tileID,t)}},t.aw=function(t,e){let i=0,n=0;if("constant"===t.kind)n=t.layoutSize;else if("source"!==t.kind){const{interpolationType:s,minZoom:r,maxZoom:o}=t,a=s?j(pi.interpolationFactor(s,e,r,o),0,1):0;"camera"===t.kind?n=_i.number(t.minSize,t.maxSize,a):i=a}return{uSizeT:i,uSize:n}},t.ay=function(t,{uSize:e,uSizeT:i},{lowerSize:n,upperSize:s}){return"source"===t.kind?n/_f:"composite"===t.kind?_i.number(n/_f,s/_f,i):e},t.az=E,t.b=Y,t.b$=Ea,t.b0=function(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t},t.b1=function(t,e){var i=e[0],n=e[1],s=e[2],r=i*i+n*n+s*s;return r>0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t},t.b2=b,t.b3=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]},t.b4=function(t,e,i){return t[0]=e[0]*i[0],t[1]=e[1]*i[1],t[2]=e[2]*i[2],t[3]=e[3]*i[3],t},t.b5=g,t.b6=function(t,e,i){const n=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return 0===n?null:(-(t[0]*i[0]+t[1]*i[1]+t[2]*i[2])-i[3])/n},t.b7=M,t.b8=function(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t},t.b9=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]},t.bA=T,t.bB=function(t,e,i){var n=i[0],s=i[1],r=i[2],o=i[3],a=e[0],h=e[1],l=e[2],c=s*l-r*h,u=r*a-n*l,f=n*h-s*a;return t[0]=a+o*(c+=c)+s*(f+=f)-r*(u+=u),t[1]=h+o*u+r*c-n*f,t[2]=l+o*f+n*u-s*c,t},t.bC=function(t,e,i){const n=(s=[t[0],t[1],t[2],e[0],e[1],e[2],i[0],i[1],i[2]])[0]*((c=s[8])*(o=s[4])-(a=s[5])*(l=s[7]))+s[1]*(-c*(r=s[3])+a*(h=s[6]))+s[2]*(l*r-o*h);var s,r,o,a,h,l,c;if(0===n)return null;const u=b([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),f=b([],[i[0],i[1],i[2]],[t[0],t[1],t[2]]),d=b([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),p=w([],u,-t[3]);return y(p,p,w([],f,-e[3])),y(p,p,w([],d,-i[3])),w(p,p,1/n),p},t.bD=Rf,t.bE=function(){return new Float64Array(4)},t.bF=function(t,e,i,n){var s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),r[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),r[2]=s[2],t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t},t.bG=function(t,e,i,n){var s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[0],r[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),r[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t},t.bH=function(t,e,i,n){var s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),r[1]=s[1],r[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t},t.bI=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),r=e[0],o=e[1],a=e[2],h=e[3],l=e[8],c=e[9],u=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=r*s-l*n,t[1]=o*s-c*n,t[2]=a*s-u*n,t[3]=h*s-f*n,t[8]=r*n+l*s,t[9]=o*n+c*s,t[10]=a*n+u*s,t[11]=h*n+f*s,t},t.bJ=function(t,e){const i=F(t,360),n=F(e,360),s=n-i,r=n>i?s-360:s+360;return Math.abs(s)<Math.abs(r)?s:r},t.bK=function(t){return t[0]=0,t[1]=0,t[2]=0,t},t.bL=function(t,e,i,n){const s=Math.sqrt(t*t+e*e),r=Math.sqrt(i*i+n*n);t/=s,e/=s,i/=r,n/=r;const o=Math.acos(t*i+e*n);return-e*i+t*n>0?o:-o},t.bM=function(t,e){const i=F(t,2*Math.PI),n=F(e,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},t.bN=function(){const t={},e=bt.$version;for(const i in bt.$root){const n=bt.$root[i];if(n.required){let s=null;s="version"===i?e:"array"===n.type?[]:{},null!=s&&(t[i]=s)}}return t},t.bO=dt,t.bP=yr,t.bQ=function t(e,i){if(Array.isArray(e)){if(!Array.isArray(i)||e.length!==i.length)return!1;for(let n=0;n<e.length;n++)if(!t(e[n],i[n]))return!1;return!0}if("object"==typeof e&&null!==e&&null!==i){if("object"!=typeof i)return!1;if(Object.keys(e).length!==Object.keys(i).length)return!1;for(const n in e)if(!t(e[n],i[n]))return!1;return!0}return e===i},t.bR=ht,t.bS=function(t){t=t.slice();const e=Object.create(null);for(let i=0;i<t.length;i++)e[t[i].id]=t[i];for(let i=0;i<t.length;i++)"ref"in t[i]&&(t[i]=Mt(t[i],e[t[i].ref]));return t},t.bT=function(t,e){if("custom"===t.type)return new $f(t,e);switch(t.type){case"background":return new kf(t,e);case"circle":return new vh(t,e);case"color-relief":return new Bh(t,e);case"fill":return new Cl(t,e);case"fill-extrusion":return new Xl(t,e);case"heatmap":return new Ch(t,e);case"hillshade":return new Ih(t,e);case"line":return new gu(t,e);case"raster":return new io(t,e);case"symbol":return new Df(t,e)}},t.bU=t=>"raster"===t.type,t.bV=G,t.bW=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!St(t.version,e.version))return[{command:"setStyle",args:[e]}];St(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),St(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),St(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),St(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),St(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),St(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),St(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),St(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),St(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),St(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),St(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),St(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),St(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),St(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});const n={},s=[];!function(t,e,i,n){let s;for(s in e=e||{},t=t||{})Object.prototype.hasOwnProperty.call(t,s)&&(Object.prototype.hasOwnProperty.call(e,s)||Et(s,i,n));for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&(Object.prototype.hasOwnProperty.call(t,s)?St(t[s],e[s])||("geojson"===t[s].type&&"geojson"===e[s].type&&Pt(t,e,s)?zt(i,{command:"setGeoJSONSourceData",args:[s,e[s].data]}):At(s,e,i,n)):Tt(s,e,i))}(t.sources,e.sources,s,n);const r=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?i.push({command:"removeLayer",args:[t.id]}):r.push(t)})),i=i.concat(s),function(t,e,i){e=e||[];const n=(t=t||[]).map(Dt),s=e.map(Dt),r=t.reduce(Ft,{}),o=e.reduce(Ft,{}),a=n.slice(),h=Object.create(null);let l,c,u,f,d;for(let t=0,e=0;t<n.length;t++)l=n[t],Object.prototype.hasOwnProperty.call(o,l)?e++:(zt(i,{command:"removeLayer",args:[l]}),a.splice(a.indexOf(l,e),1));for(let t=0,e=0;t<s.length;t++)l=s[s.length-1-t],a[a.length-1-t]!==l&&(Object.prototype.hasOwnProperty.call(r,l)?(zt(i,{command:"removeLayer",args:[l]}),a.splice(a.lastIndexOf(l,a.length-e),1)):e++,f=a[a.length-t],zt(i,{command:"addLayer",args:[o[l],f]}),a.splice(a.length-t,0,l),h[l]=!0);for(let t=0;t<s.length;t++)if(l=s[t],c=r[l],u=o[l],!h[l]&&!St(c,u))if(St(c.source,u.source)&&St(c["source-layer"],u["source-layer"])&&St(c.type,u.type)){for(d in Ct(c.layout,u.layout,i,l,null,"setLayoutProperty"),Ct(c.paint,u.paint,i,l,null,"setPaintProperty"),St(c.filter,u.filter)||zt(i,{command:"setFilter",args:[l,u.filter]}),St(c.minzoom,u.minzoom)&&St(c.maxzoom,u.maxzoom)||zt(i,{command:"setLayerZoomRange",args:[l,u.minzoom,u.maxzoom]}),c)Object.prototype.hasOwnProperty.call(c,d)&&"layout"!==d&&"paint"!==d&&"filter"!==d&&"metadata"!==d&&"minzoom"!==d&&"maxzoom"!==d&&(0===d.indexOf("paint.")?Ct(c[d],u[d],i,l,d.slice(6),"setPaintProperty"):St(c[d],u[d])||zt(i,{command:"setLayerProperty",args:[l,d,u[d]]}));for(d in u)Object.prototype.hasOwnProperty.call(u,d)&&!Object.prototype.hasOwnProperty.call(c,d)&&"layout"!==d&&"paint"!==d&&"filter"!==d&&"metadata"!==d&&"minzoom"!==d&&"maxzoom"!==d&&(0===d.indexOf("paint.")?Ct(c[d],u[d],i,l,d.slice(6),"setPaintProperty"):St(c[d],u[d])||zt(i,{command:"setLayerProperty",args:[l,d,u[d]]}))}else zt(i,{command:"removeLayer",args:[l]}),f=a[a.lastIndexOf(l)+1],zt(i,{command:"addLayer",args:[u,f]})}(r,e.layers,i)}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i},t.bX=function(t){const e=[],i=t.id;return void 0===i&&e.push({message:`layers.${i}: missing required property "id"`}),void 0===t.render&&e.push({message:`layers.${i}: missing required method "render"`}),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),e},t.bY=N,t.bZ=U,t.b_=class extends Sa{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},t.ba=Jf,t.bb=Qf,t.bc=function(t,e,i,n,s){var r=1/Math.tan(e/2);if(t[0]=r/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0){var o=1/(n-s);t[10]=(s+n)*o,t[14]=2*s*n*o}else t[10]=-1,t[14]=-2*n;return t},t.bd=function(t){var e=new d(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},t.be=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),r=e[0],o=e[1],a=e[2],h=e[3],l=e[4],c=e[5],u=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=r*s+l*n,t[1]=o*s+c*n,t[2]=a*s+u*n,t[3]=h*s+f*n,t[4]=l*s-r*n,t[5]=c*s-o*n,t[6]=u*s-a*n,t[7]=f*s-h*n,t},t.bf=function(t,e,i){var n=Math.sin(i),s=Math.cos(i),r=e[4],o=e[5],a=e[6],h=e[7],l=e[8],c=e[9],u=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=r*s+l*n,t[5]=o*s+c*n,t[6]=a*s+u*n,t[7]=h*s+f*n,t[8]=l*s-r*n,t[9]=c*s-o*n,t[10]=u*s-a*n,t[11]=f*s-h*n,t},t.bg=function(t,e){var i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],h=e[6],l=e[7],c=e[8],u=e[9],f=e[10],d=e[11],p=e[12],m=e[13],_=e[14],g=e[15],v=i*a-n*o,y=i*h-s*o,w=i*l-r*o,b=n*h-s*a,x=n*l-r*a,M=s*l-r*h,S=c*m-u*p,z=c*_-f*p,T=c*g-d*p,E=u*_-f*m,A=u*g-d*m,P=f*g-d*_,C=v*P-y*A+w*E+b*T-x*z+M*S;return C?(t[0]=(a*P-h*A+l*E)*(C=1/C),t[1]=(s*A-n*P-r*E)*C,t[2]=(m*M-_*x+g*b)*C,t[3]=(f*x-u*M-d*b)*C,t[4]=(h*T-o*P-l*z)*C,t[5]=(i*P-s*T+r*z)*C,t[6]=(_*w-p*M-g*y)*C,t[7]=(c*M-f*w+d*y)*C,t[8]=(o*A-a*T+l*S)*C,t[9]=(n*T-i*A-r*S)*C,t[10]=(p*x-m*w+g*v)*C,t[11]=(u*w-c*x-d*v)*C,t[12]=(a*z-o*E-h*S)*C,t[13]=(i*E-n*z+s*S)*C,t[14]=(m*y-p*b-_*v)*C,t[15]=(c*b-u*y+f*v)*C,t):null},t.bh=function(){const t=new Float32Array(16);return m(t),t},t.bi=function(){const t=new Float64Array(16);return m(t),t},t.bj=function(){return new Float64Array(16)},t.bk=function(t,e,i){const n=new Float64Array(4);return T(n,t,e-90,i),n},t.bl=function(t,e,i,n){var s,r,o,a,h,l=e[0],c=e[1],u=e[2],d=e[3],p=i[0],m=i[1],_=i[2],g=i[3];return(r=l*p+c*m+u*_+d*g)<0&&(r=-r,p=-p,m=-m,_=-_,g=-g),1-r>f?(s=Math.acos(r),o=Math.sin(s),a=Math.sin((1-n)*s)/o,h=Math.sin(n*s)/o):(a=1-n,h=n),t[0]=a*l+h*p,t[1]=a*c+h*m,t[2]=a*u+h*_,t[3]=a*d+h*g,t},t.bm=function(t){const e=new Float64Array(9);var i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y;u=(s=(n=t)[0])*(h=s+s),f=(r=n[1])*h,p=(o=n[2])*h,m=o*(l=r+r),g=(a=n[3])*h,v=a*l,y=a*(c=o+o),(i=e)[0]=1-(d=r*l)-(_=o*c),i[3]=f-y,i[6]=p+v,i[1]=f+y,i[4]=1-u-_,i[7]=m-g,i[2]=p-v,i[5]=m+g,i[8]=1-u-d;const w=it(-Math.asin(j(e[2],-1,1)));let b,x;return Math.hypot(e[5],e[8])<.001?(b=0,x=-it(Math.atan2(e[3],e[4]))):(b=it(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),x=it(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:b,pitch:w+90,bearing:x}},t.bn=function(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing},t.bo=Pe,t.bp=za,t.bq=vl,t.br=yl,t.bs=_l,t.bt=I,t.bu=k,t.bv=Ne,t.bw=function(t,e,i,n,s){return I(n,s,j((t-e)/(i-e),0,1))},t.bx=function(t,e,i,n){return t[0]=e[0]+i[0]*n,t[1]=e[1]+i[1]*n,t[2]=e[2]+i[2]*n,t},t.by=F,t.bz=function(){return new Float64Array(3)},t.c=lt,t.c$=ss,t.c0=class extends Sa{constructor(t,e){super(t,e),this.current=Aa}set(t){if(t[12]!==this.current[12]||t[0]!==this.current[0])return this.current=t,void this.gl.uniformMatrix4fv(this.location,!1,t);for(let e=1;e<16;e++)if(t[e]!==this.current[e]){this.current=t,this.gl.uniformMatrix4fv(this.location,!1,t);break}}},t.c1=Ta,t.c2=class extends Sa{constructor(t,e){super(t,e),this.current=[0,0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]&&t[2]===this.current[2]||(this.current=t,this.gl.uniform3f(this.location,t[0],t[1],t[2]))}},t.c3=class extends Sa{constructor(t,e){super(t,e),this.current=[0,0]}set(t){t[0]===this.current[0]&&t[1]===this.current[1]||(this.current=t,this.gl.uniform2f(this.location,t[0],t[1]))}},t.c4=p,t.c5=function(t,e){var i=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=i,t[2]=0,t[3]=-i,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},t.c6=function(t,e,i){var n=e[0],s=e[1],r=e[2];return t[0]=n*i[0]+s*i[3]+r*i[6],t[1]=n*i[1]+s*i[4]+r*i[7],t[2]=n*i[2]+s*i[5]+r*i[8],t},t.c7=function(t,e,i,n,s,r,o){var a=1/(e-i),h=1/(n-s),l=1/(r-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*h,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+i)*a,t[13]=(s+n)*h,t[14]=(o+r)*l,t[15]=1,t},t.c8=class extends Sa{constructor(t,e){super(t,e),this.current=new Array}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(4*t.length);for(let i=0;i<t.length;i++)e[4*i]=t[i].r,e[4*i+1]=t[i].g,e[4*i+2]=t[i].b,e[4*i+3]=t[i].a;this.gl.uniform4fv(this.location,e)}}},t.c9=class extends Sa{constructor(t,e){super(t,e),this.current=new Array}set(t){if(t!=this.current){this.current=t;const e=new Float32Array(t);this.gl.uniform1fv(this.location,e)}}},t.cA=function(t,e){return nt[e]&&"touches"in t},t.cB=function(t){return nt[t]||st[t]},t.cC=function(t,e,i){var n=e[0],s=e[1];return t[0]=i[0]*n+i[4]*s+i[12],t[1]=i[1]*n+i[5]*s+i[13],t},t.cD=function(t,e){const{x:i,y:n}=Hf.fromLngLat(e);return!(t<0||t>25||n<0||n>=1||i<0||i>=1)},t.cE=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},t.cF=class extends lo{},t.cG=ft,t.cH=function(t,e){lt.REGISTERED_PROTOCOLS[t]=e},t.cI=function(t){delete lt.REGISTERED_PROTOCOLS[t]},t.cJ=function(t,e){const i={};for(let n=0;n<t.length;n++){const s=e&&e[t[n].id]||Ms(t[n]);e&&(e[t[n].id]=s);let r=i[s];r||(r=i[s]=[]),r.push(t[n])}const n=[];for(const t in i)n.push(i[t]);return n},t.cK=dr,t.cL=ed,t.cM=rm,t.cN=nf,t.cO=function(e){var i,n;e.bucket.createArrays(),e.bucket.tilePixelRatio=P/(512*e.bucket.overscaling),e.bucket.compareText={},e.bucket.iconsNeedLinear=!1;const s=e.bucket.layers[0],r=s.layout,o=s._unevaluatedLayout._values,a={layoutIconSize:o["icon-size"].possiblyEvaluate(new kr(e.bucket.zoom+1),e.canonical),layoutTextSize:o["text-size"].possiblyEvaluate(new kr(e.bucket.zoom+1),e.canonical),textMaxSize:o["text-size"].possiblyEvaluate(new kr(18))};if("composite"===e.bucket.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.textSizeData;a.compositeTextSizes=[o["text-size"].possiblyEvaluate(new kr(t),e.canonical),o["text-size"].possiblyEvaluate(new kr(i),e.canonical)]}if("composite"===e.bucket.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.bucket.iconSizeData;a.compositeIconSizes=[o["icon-size"].possiblyEvaluate(new kr(t),e.canonical),o["icon-size"].possiblyEvaluate(new kr(i),e.canonical)]}const h=r.get("text-line-height")*Tu,l="viewport"!==r.get("text-rotation-alignment")&&"point"!==r.get("symbol-placement"),c=r.get("text-keep-upright"),u=r.get("text-size");for(const o of e.bucket.features){const f=r.get("text-font").evaluate(o,{},e.canonical).join(","),d=u.evaluate(o,{},e.canonical),p=a.layoutTextSize.evaluate(o,{},e.canonical),m=a.layoutIconSize.evaluate(o,{},e.canonical),_={horizontal:{},vertical:void 0},g=o.text;let v,y=[0,0];if(g){const i=g.toString(),n=r.get("text-letter-spacing").evaluate(o,{},e.canonical)*Tu,a=Sr(i)?n:0,u=r.get("text-anchor").evaluate(o,{},e.canonical),m=$m(s,o,e.canonical);if(!m){const t=r.get("text-radial-offset").evaluate(o,{},e.canonical);y=t?km(u,[t*Tu,Im]):r.get("text-offset").evaluate(o,{},e.canonical).map((t=>t*Tu))}let v=l?"center":r.get("text-justify").evaluate(o,{},e.canonical);const w="point"===r.get("symbol-placement")?r.get("text-max-width").evaluate(o,{},e.canonical)*Tu:1/0,b=()=>{e.bucket.allowVerticalPlacement&&Mr(i)&&(_.vertical=rf(g,e.glyphMap,e.glyphPositions,e.imagePositions,f,w,h,u,"left",a,y,t.ax.vertical,!0,p,d))};if(!l&&m){const i=new Set;if("auto"===v)for(let t=0;t<m.values.length;t+=2)i.add(Om(m.values[t]));else i.add(v);let n=!1;for(const s of i)if(!_.horizontal[s])if(n)_.horizontal[s]=_.horizontal[0];else{const i=rf(g,e.glyphMap,e.glyphPositions,e.imagePositions,f,w,h,"center",s,a,y,t.ax.horizontal,!1,p,d);i&&(_.horizontal[s]=i,n=1===i.positionedLines.length)}b()}else{"auto"===v&&(v=Om(u));const n=rf(g,e.glyphMap,e.glyphPositions,e.imagePositions,f,w,h,u,v,a,y,t.ax.horizontal,!1,p,d);n&&(_.horizontal[v]=n),b(),Mr(i)&&l&&c&&(_.vertical=rf(g,e.glyphMap,e.glyphPositions,e.imagePositions,f,w,h,u,v,a,y,t.ax.vertical,!1,p,d))}}let w=!1;if(null===(i=o.icon)||void 0===i?void 0:i.name){const t=e.imageMap[o.icon.name];t&&(v=df(e.imagePositions[o.icon.name],r.get("icon-offset").evaluate(o,{},e.canonical),r.get("icon-anchor").evaluate(o,{},e.canonical)),w=!!t.sdf,void 0===e.bucket.sdfIcons?e.bucket.sdfIcons=w:e.bucket.sdfIcons!==w&&q("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.bucket.pixelRatio||0!==r.get("icon-rotate").constantOr(1))&&(e.bucket.iconsNeedLinear=!0))}const b=Lm(_.horizontal)||_.vertical;(n=e.bucket).iconsInText||(n.iconsInText=!!b&&b.iconsInText),(b||v)&&jm(e.bucket,o,_,v,e.imageMap,a,p,m,y,w,e.canonical,e.subdivisionGranularity)}e.showCollisionBoxes&&e.bucket.generateCollisionDebugBuffers()},t.cP=Tl,t.cQ=Vl,t.cR=uu,t.cS=function(t,e=""){const i=new Lu;return function(t,e,i=""){for(const n in t.layers)e.writeMessage(3,((t,e)=>Kp(t,e,i)),t.layers[n])}(t,i,e),i.finish()},t.cT=function(t,e,i,n,s,r){let o=lm(t,e,i,s,0);return o=lm(o,e,n,r,1),o},t.cU=class{constructor(t){this.maxEntries=t,this.map=new Map}get(t){const e=this.map.get(t);return void 0!==e&&(this.map.delete(t),this.map.set(t,e)),e}set(t,e){if(this.map.has(t))this.map.delete(t);else if(this.map.size>=this.maxEntries){const t=this.map.keys().next().value;this.map.delete(t)}this.map.set(t,e)}clear(){this.map.clear()}},t.cV=Bl,t.cW=Lu,t.cX=Yp,t.cY=function(t,i,n,s,r){return e(this,void 0,void 0,(function*(){if(u())try{return yield J(t,i,n,s,r)}catch(t){}return function(t,e,i,n,s){const r=t.width,o=t.height;K&&Q||(K=new OffscreenCanvas(r,o),Q=K.getContext("2d",{willReadFrequently:!0})),K.width=r,K.height=o,Q.drawImage(t,0,0,r,o);const a=Q.getImageData(e,i,n,s);return Q.clearRect(0,0,r,o),a.data}(t,i,n,s,r)}))},t.cZ=Rh,t.c_=class{constructor(t,e){this.layers={[Jp]:this},this.name=Jp,this.version=e?e.version:1,this.extent=e?e.extent:4096,this.length=t.length,this.features=t}feature(t){return new Xp(this.features[t],this.extent)}},t.ca=class extends xo{},t.cb=Mu,t.cc=class extends So{},t.cd=Ph,t.ce=function(t){return t<=1?1:Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},t.cf=Ah,t.cg=function(t,e,i){var n=e[0],s=e[1],r=e[2],o=i[3]*n+i[7]*s+i[11]*r+i[15];return t[0]=(i[0]*n+i[4]*s+i[8]*r+i[12])/(o=o||1),t[1]=(i[1]*n+i[5]*s+i[9]*r+i[13])/o,t[2]=(i[2]*n+i[6]*s+i[10]*r+i[14])/o,t},t.ch=class extends co{},t.ci=class extends Do{},t.cj=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},t.ck=function(t,e){var i=t[0],n=t[1],s=t[2],r=t[3],o=t[4],a=t[5],h=t[6],l=t[7],c=t[8],u=t[9],d=t[10],p=t[11],m=t[12],_=t[13],g=t[14],v=t[15],y=e[0],w=e[1],b=e[2],x=e[3],M=e[4],S=e[5],z=e[6],T=e[7],E=e[8],A=e[9],P=e[10],C=e[11],D=e[12],F=e[13],I=e[14],k=e[15];return Math.abs(i-y)<=f*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-w)<=f*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(s-b)<=f*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(r-x)<=f*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-M)<=f*Math.max(1,Math.abs(o),Math.abs(M))&&Math.abs(a-S)<=f*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(h-z)<=f*Math.max(1,Math.abs(h),Math.abs(z))&&Math.abs(l-T)<=f*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(c-E)<=f*Math.max(1,Math.abs(c),Math.abs(E))&&Math.abs(u-A)<=f*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(d-P)<=f*Math.max(1,Math.abs(d),Math.abs(P))&&Math.abs(p-C)<=f*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(m-D)<=f*Math.max(1,Math.abs(m),Math.abs(D))&&Math.abs(_-F)<=f*Math.max(1,Math.abs(_),Math.abs(F))&&Math.abs(g-I)<=f*Math.max(1,Math.abs(g),Math.abs(I))&&Math.abs(v-k)<=f*Math.max(1,Math.abs(v),Math.abs(k))},t.cl=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},t.cm=t=>"circle"===t.type,t.cn=t=>"heatmap"===t.type,t.co=t=>"line"===t.type,t.cp=t=>"fill"===t.type,t.cq=t=>"fill-extrusion"===t.type,t.cr=t=>"hillshade"===t.type,t.cs=t=>"color-relief"===t.type,t.ct=t=>"background"===t.type,t.cu=t=>"custom"===t.type,t.cv=$,t.cw=function(t,e,i){if(e<=0)return t;const n=1/e;return void 0===i||Math.abs(i)<1e-10?Math.round(t*n)/n:(i>0?Math.ceil(t*n-1e-9):Math.floor(t*n+1e-10))/n},t.cx=function(t,e,i){const n=A(e.x-i.x,e.y-i.y),s=A(t.x-i.x,t.y-i.y);var r,o;return it(Math.atan2(n[0]*s[1]-n[1]*s[0],(r=n)[0]*(o=s)[0]+r[1]*o[1]))},t.cy=O,t.cz=function(t,e){var i;if(!st[e])return!1;const n=null==t?void 0:t.target,s=(null===(i=null==n?void 0:n.ownerDocument)||void 0===i?void 0:i.defaultView)||window;return t instanceof s.MouseEvent||t instanceof s.WheelEvent},t.d=D,t.d0=class{constructor(t,e){const i=(e=this.options=Object.assign({},su,e)).debug;if(i&&console.time("preprocess data"),e.maxZoom<0||e.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(e.promoteId&&e.generateId)throw new Error("promoteId and generateId cannot be used together.");let n=uc(t,e);i&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",e.indexMaxZoom,e.indexMaxPoints),console.time("generate tiles")),n=Oc(n,e),e.updateable&&(this.source=n),this.initializeIndex(n,e)}initializeIndex(t,e){this.tileIndex=e.cluster?new Gc(e.clusterOptions):new iu(e),t.length&&this.tileIndex.initialize(t)}getTile(t,e,i){return e=+e,i=+i,(t=+t)<0||t>24?null:this.tileIndex.getTile(t,e,i)}updateData(t,e){const i=this.options;if(!i.updateable)throw new Error("to update tile geojson `updateable` option must be set to true");let{affected:n,source:s}=function(t,e,i){const n=function(t,e){return t?{removeAll:t.removeAll,remove:new Set(t.remove||[]),add:new Map(t.add?.map((t=>[e.promoteId?t.properties[e.promoteId]:t.id,t]))),update:new Map(t.update?.map((t=>[t.id,t])))}:{remove:new Set,add:new Map,update:new Map}}(e,i);let s=[];if(n.removeAll&&(s=t,t=[]),n.remove.size||n.add.size){const e=[];for(const i of t)(n.remove.has(i.id)||n.add.has(i.id))&&e.push(i);if(e.length){s.push(...e);const i=new Set(e.map((t=>t.id)));t=t.filter((t=>!i.has(t.id)))}if(n.add.size){let e=uc({type:"FeatureCollection",features:Array.from(n.add.values())},i);e=Oc(e,i),s.push(...e),t.push(...e)}}if(n.update.size){const e=new Map,r=[];for(const i of t)n.update.has(i.id)?e.set(i.id,[...e.get(i.id)||[],i]):r.push(i);for(const[t,o]of n.update){const n=e.get(t);if(!n||0===n.length)continue;const a=Bc(n,o,i);s.push(...n,...a),r.push(...a)}t=r}return{affected:s,source:t}}(this.source,t,i);e&&({affected:n,source:s}=this.filterUpdate(s,n,e)),n.length&&(this.source=s,this.tileIndex.updateIndex(s,n,i))}filterUpdate(t,e,i){const n=new Set;for(const s of t)null!=s.id&&(i(gc(s))||(e.push(s),n.add(s.id)));return{affected:e,source:t=t.filter((t=>!n.has(t.id)))}}getData(){if(!this.options.updateable)throw new Error("to retrieve data the `updateable` option must be set to true");return{type:"FeatureCollection",features:this.source.map((t=>gc(t)))}}updateClusterOptions(t,e){const i=this.options.cluster;this.options.cluster=t,this.options.clusterOptions=e,i!=t?this.initializeIndex(this.source,this.options):this.tileIndex.updateIndex(this.source,[],this.options)}getClusterExpansionZoom(t){return this.tileIndex.getClusterExpansionZoom(t)}getClusterChildren(t){return this.tileIndex.getChildren(t)}getClusterLeaves(t,e,i){return this.tileIndex.getLeaves(t,e,i)}},t.d1=Ir,t.e=L,t.f=mt,t.g=ct,t.h=t=>e(void 0,void 0,void 0,(function*(){if(0===t.byteLength)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(e)}catch(t){throw new Error(`Could not load image because of ${D(t).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})),t.i=W,t.j=t=>new Promise(((e,i)=>{const n=new Image;n.onload=()=>{e(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame((()=>n.src=X))},n.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const s=new Blob([new Uint8Array(t)],{type:"image/png"});n.src=t.byteLength?URL.createObjectURL(s):X})),t.k=(t,e)=>pt(L(t,{type:"json"}),e),t.l=yt,t.m=pt,t.n=vt,t.o=(t,e)=>pt(L(t,{type:"arrayBuffer"}),e),t.p=tf,t.q=function(t){return new Lu(t).readFields(Ju,[])},t.r=function(t){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(t))},t.s=tt,t.t=zh,t.u=Xr,t.v=sr,t.w=q,t.x=bt,t.y=Lr,t.z=or})),i("worker",0,(function(t){class e{constructor(t,e){this.keyCache={},t&&this.replace(t,e)}replace(t,e){this._layerConfigs={},this._layers={},this.update(t,[],e)}update(e,i,n){for(const i of e){this._layerConfigs[i.id]=i;const e=this._layers[i.id]=t.bT(i,n);e._featureFilter=t.ah(e.filter,n),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const t of i)delete this.keyCache[t],delete this._layerConfigs[t],delete this._layers[t];this.familiesBySource={};const s=t.cJ(Object.values(this._layerConfigs),this.keyCache);for(const e of s){const i=e.map((t=>this._layers[t.id])),n=i[0];if(n.isHidden())continue;const s=n.source||"";let r=this.familiesBySource[s];r||(r=this.familiesBySource[s]={});const o=n.sourceLayer||t.ag;let a=r[o];a||(a=r[o]=[]),a.push(i)}}}class i{constructor(e){const i={},n=[];for(const t in e){const s=e[t],r=i[t]={};for(const t in s){const e=s[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const i={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};n.push(i),r[t]={rect:i,metrics:e.metrics}}}const{w:s,h:r}=t.p(n),o=new t.t({width:s||1,height:r||1});for(const n in e){const s=e[n];for(const e in s){const r=s[+e];if(!r||0===r.bitmap.width||0===r.bitmap.height)continue;const a=i[n][e].rect;t.t.copy(r.bitmap,o,{x:0,y:0},{x:a.x+1,y:a.y+1},r.bitmap)}}this.image=o,this.positions=i}}t.cK("GlyphAtlas",i);class n{constructor(e){this.tileID=new t.a3(e.tileID.overscaledZ,e.tileID.wrap,e.tileID.canonical.z,e.tileID.canonical.x,e.tileID.canonical.y),this.uid=e.uid,this.zoom=e.zoom,this.pixelRatio=e.pixelRatio,this.tileSize=e.tileSize,this.source=e.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=e.showCollisionBoxes,this.collectResourceTiming=!!e.collectResourceTiming,this.returnDependencies=!!e.returnDependencies,this.promoteId=e.promoteId,this.inFlightDependencies=[]}parse(e,n,r,o,a){return t._(this,void 0,void 0,(function*(){this.status="parsing",this.data=e,this.collisionBoxArray=new t.ae;const h=new t.cL(Object.keys(e.layers).sort()),l=new t.cM(this.tileID,this.promoteId);l.bucketLayerIDs=[];const c={},u={featureIndex:l,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:r,subdivisionGranularity:a},f=n.familiesBySource[this.source];for(const i in f){const n=e.layers[i];if(!n)continue;1===n.version&&t.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const o=h.encode(i),a=[];for(let t=0;t<n.length;t++){const e=n.feature(t),s=l.getId(e,i);a.push({feature:e,id:s,index:t,sourceLayerIndex:o})}for(const e of f[i]){const i=e[0];i.source!==this.source&&t.w(`layer.source = ${i.source} does not equal this.source = ${this.source}`),i.isHidden(this.zoom,!0)||(s(e,this.zoom,r),(c[i.id]=i.createBucket({index:l.bucketLayerIDs.length,layers:e,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:o,sourceID:this.source})).populate(a,u,this.tileID.canonical),l.bucketLayerIDs.push(e.map((t=>t.id))))}}const d=t.bY(u.glyphDependencies,(t=>Object.keys(t).map(Number)));for(const t of this.inFlightDependencies)null==t||t.abort();this.inFlightDependencies=[];let p=Promise.resolve({});if(Object.keys(d).length){const t=new AbortController;this.inFlightDependencies.push(t),p=o.sendAsync({type:"GG",data:{stacks:d,source:this.source,tileID:this.tileID,type:"glyphs"}},t)}const m=Object.keys(u.iconDependencies);let _=Promise.resolve({});if(m.length){const t=new AbortController;this.inFlightDependencies.push(t),_=o.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},t)}const g=Object.keys(u.patternDependencies);let v=Promise.resolve({});if(g.length){const t=new AbortController;this.inFlightDependencies.push(t),v=o.sendAsync({type:"GI",data:{icons:g,source:this.source,tileID:this.tileID,type:"patterns"}},t)}const y=u.dashDependencies;let w=Promise.resolve({});if(Object.keys(y).length){const t=new AbortController;this.inFlightDependencies.push(t),w=o.sendAsync({type:"GDA",data:{dashes:y}},t)}const[b,x,M,S]=yield Promise.all([p,_,v,w]),z=new i(b),T=new t.cN(x,M);for(const e in c){const i=c[e];i instanceof t.af?(s(i.layers,this.zoom,r),t.cO({bucket:i,glyphMap:b,glyphPositions:z.positions,imageMap:x,imagePositions:T.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:u.subdivisionGranularity})):i.hasDependencies&&(i instanceof t.cP||i instanceof t.cQ||i instanceof t.cR)&&(s(i.layers,this.zoom,r),i.addFeatures(u,this.tileID.canonical,T.patternPositions,S))}return this.status="done",{buckets:Object.values(c).filter((t=>!t.isEmpty())),featureIndex:l,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:z.image,imageAtlas:T,dashPositions:S,glyphMap:this.returnDependencies?b:null,iconMap:this.returnDependencies?x:null,glyphPositions:this.returnDependencies?z.positions:null}}))}}function s(e,i,n){const s=new t.J(i);for(const t of e)t.recalculate(s,n)}class r{constructor(){this.loading={},this.loaded={},this.parsing={}}startLoading(t,e){this.loading[t]=e}finishLoading(t){delete this.loading[t]}abort(t){const e=this.loading[t];(null==e?void 0:e.abort)&&(e.abort.abort(),delete this.loading[t])}setParsing(t,e){this.parsing[t]=e}consumeParsing(t){const e=this.parsing[t];if(e)return delete this.parsing[t],e}clearParsing(t){delete this.parsing[t]}markLoaded(t,e){this.loaded[t]=e}getLoaded(t){const e=this.loaded[t];if(e)return e}removeLoaded(t){delete this.loaded[t]}clearLoaded(){this.loaded={}}}class o{constructor(t){this.start=`${t}#start`,this.end=`${t}#end`,this.measure=t,performance.mark(this.start)}finish(){performance.mark(this.end);let t=performance.getEntriesByName(this.measure);return 0===t.length&&(performance.measure(this.measure,this.start,this.end),t=performance.getEntriesByName(this.measure),performance.clearMarks(this.start),performance.clearMarks(this.end),performance.clearMeasures(this.measure)),t}}class a{constructor(t,e,i,n,s){this.type=t,this.properties=i||{},this.extent=s,this.pointsArray=e,this.id=n}loadGeometry(){return this.pointsArray.map((e=>e.map((e=>new t.P(e.x,e.y)))))}}class h{constructor(t,e,i){this.version=2,this._myFeatures=t,this.name=e,this.length=t.length,this.extent=i}feature(t){return this._myFeatures[t]}}class l{constructor(){this.layers={}}addLayer(t){this.layers[t.name]=t}}function c(e){let i=t.cS(e);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:e,rawData:i.buffer}}function u(e,i,n){const{extent:s}=e,r=Math.pow(2,n.z-i.z),o=(n.x-i.x*r)*s,l=(n.y-i.y*r)*s,c=[];for(let i=0;i<e.length;i++){const n=e.feature(i);let h=n.loadGeometry();for(const t of h)for(const e of t)e.x=e.x*r-o,e.y=e.y*r-l;const u=128;h=t.cT(h,n.type,-u,-u,s+u,s+u),0!==h.length&&c.push(new a(n.type,h,n.properties,n.id,s))}return new h(c,e.name,s)}class f{constructor(e,i,n){this.actor=e,this.layerIndex=i,this.availableImages=n,this.tileState=new r,this.overzoomedTileResultCache=new t.cU(1e3)}loadVectorTile(e,i){try{return{vectorTile:"mlt"!==e.encoding?new t.cV(new t.cW(i)):new t.cX(i),rawData:i}}catch(n){const s=new Uint8Array(i);let r=`Unable to parse the tile at ${e.request.url}, `;throw r+=31===s[0]&&139===s[1]?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${t.d(n).message}`,new Error(r)}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:i,overzoomParameters:s}=e;s&&(e.request=s.overzoomRequest);const r=this._startRequestTiming(e),o=new n(e);this.tileState.startLoading(i,o);const a=new AbortController;o.abort=a;try{const n=yield t.o(e.request,a);if(e.etag&&e.etag===n.etag)return this.tileState.finishLoading(i),this._getEtagUnmodifiedResult(n,r);const h=this.loadVectorTile(e,n.data);if(this.tileState.finishLoading(i),!h)return null;let{vectorTile:l,rawData:c}=h;s&&({vectorTile:l,rawData:c}=this._getOverzoomTile(e,l));const u=this._getExpiryData(n),f=this._finishRequestTiming(r);o.vectorTile=l,this.tileState.markLoaded(i,o);const d={rawData:c,cacheControl:u,resourceTiming:f};this.tileState.setParsing(i,d);try{return yield this._parseWorkerTile(o,e,d)}finally{this.tileState.clearParsing(i)}}catch(t){throw this.tileState.finishLoading(i),o.status="done",this.tileState.markLoaded(i,o),t}}))}_getEtagUnmodifiedResult(e,i){const n=this._getExpiryData(e),s=this._finishRequestTiming(i);return t.e({etagUnmodified:!0},n,s)}_parseWorkerTile(e,i,n){return t._(this,void 0,void 0,(function*(){let s=yield e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(n){const{rawData:e,cacheControl:r,resourceTiming:o}=n;s=t.e({rawTileData:e.slice(0),encoding:i.encoding},s,r,o)}return s}))}_getExpiryData({expires:t,cacheControl:e,etag:i}){const n={};return t&&(n.expires=t),e&&(n.cacheControl=e),i&&(n.etag=i),n}_startRequestTiming(t){var e;if(null===(e=t.request)||void 0===e?void 0:e.collectResourceTiming)return new o(t.request.url)}_finishRequestTiming(t){const e=null==t?void 0:t.finish();return e?{resourceTiming:JSON.parse(JSON.stringify(e))}:{}}_getOverzoomTile(t,e){var i;const{tileID:n,source:s,overzoomParameters:r}=t,{maxZoomTileID:o}=r,a=`${o.key}_${n.key}_${null===(i=t.request)||void 0===i?void 0:i.url}`,h=this.overzoomedTileResultCache.get(a);if(h)return h;const f=new l,d=this.layerIndex.familiesBySource[s];for(const t in d){const i=e.layers[t];if(!i)continue;const s=u(i,o,n.canonical);s.length>0&&f.addLayer(s)}const p=c(f);return this.overzoomedTileResultCache.set(a,p),p}reloadTile(e){return t._(this,void 0,void 0,(function*(){const t=e.uid,i=this.tileState.getLoaded(t);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=e.showCollisionBoxes,"parsing"===i.status){const n=this.tileState.consumeParsing(t);return yield this._parseWorkerTile(i,e,n)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,e)}))}abortTile(e){return t._(this,void 0,void 0,(function*(){this.tileState.abort(e.uid)}))}removeTile(e){return t._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(e.uid)}))}}class d{constructor(){this.loaded={}}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:i,encoding:n,rawImageData:s,redFactor:r,greenFactor:o,blueFactor:a,baseShift:h}=e,l=s.width+2,c=s.height+2,u=t.b(s)?new t.R({width:l,height:c},yield t.cY(s,-1,-1,l,c)):s,f=new t.cZ(i,u,n,r,o,a,h);return this.loaded||(this.loaded={}),this.loaded[i]=f,f}))}removeTile(t){const e=this.loaded,i=t.uid;(null==e?void 0:e[i])&&delete e[i]}}class p{constructor(t,e,i,n=m){this.actor=t,this.layerIndex=e,this.availableImages=i,this.tileState=new r,this._createGeoJSONIndex=n}loadVectorTile(e){if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const{z:i,x:n,y:s}=e.tileID.canonical,r=this._geoJSONIndex.getTile(i,n,s);return r?c(new t.c_(r.features,{version:2,extent:t.a6})):null}loadTile(e){return t._(this,void 0,void 0,(function*(){const{uid:t}=e,i=new n(e);i.abort=new AbortController;try{const n=this.loadVectorTile(e);if(!n)return null;const{vectorTile:s,rawData:r}=n;i.vectorTile=s,this.tileState.markLoaded(t,i);const o={rawData:r};this.tileState.setParsing(t,o);try{return yield this._parseWorkerTile(i,e,o)}finally{this.tileState.clearParsing(t)}}catch(e){throw i.status="done",this.tileState.markLoaded(t,i),e}}))}_reloadLoadedTile(e){return t._(this,void 0,void 0,(function*(){const t=e.uid,i=this.tileState.getLoaded(t);if(!i)throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");if(i.showCollisionBoxes=e.showCollisionBoxes,"parsing"===i.status){const n=this.tileState.consumeParsing(t);return yield this._parseWorkerTile(i,e,n)}if("done"===i.status&&i.vectorTile)return yield this._parseWorkerTile(i,e)}))}_parseWorkerTile(e,i,n){return t._(this,void 0,void 0,(function*(){let s=yield e.parse(e.vectorTile,this.layerIndex,this.availableImages,this.actor,i.subdivisionGranularity);if(n){const{rawData:e}=n;s=t.e({rawTileData:e.slice(0),encoding:"mvt"},s)}return s}))}abortTile(e){return t._(this,void 0,void 0,(function*(){this.tileState.abort(e.uid)}))}removeTile(e){return t._(this,void 0,void 0,(function*(){this.tileState.removeLoaded(e.uid)}))}loadData(e){return t._(this,void 0,void 0,(function*(){var i;null===(i=this._pendingRequest)||void 0===i||i.abort();const n=this._startRequestTiming(e);this._pendingRequest=new AbortController;try{yield this.loadAndProcessGeoJSON(e,this._pendingRequest),delete this._pendingRequest,this.tileState.clearLoaded();const t={};return e.request&&(t.data=e.data),this._finishRequestTiming(n,e,t),t}catch(e){if(delete this._pendingRequest,!t.$(e))throw e;return{abandoned:!0}}}))}_startRequestTiming(t){var e;if(null===(e=t.request)||void 0===e?void 0:e.collectResourceTiming)return new o(t.request.url)}_finishRequestTiming(t,e,i){const n=null==t?void 0:t.finish();n&&(i.resourceTiming={[e.source]:JSON.parse(JSON.stringify(n))})}reloadTile(t){return this.tileState.getLoaded(t.uid)?this._reloadLoadedTile(t):this.loadTile(t)}loadAndProcessGeoJSON(e,i){return t._(this,void 0,void 0,(function*(){var n;if(e.request&&(e.data=(yield t.k(e.request,i)).data),e.data)return e.data=this._filterGeoJSON(e.data,e.filter),void(this._geoJSONIndex=this._createGeoJSONIndex(e.data,e));if(e.dataDiff)return null!==(n=this._geoJSONIndex)&&void 0!==n||(this._geoJSONIndex=this._createGeoJSONIndex({type:"FeatureCollection",features:[]},e)),void this._geoJSONIndex.updateData(e.dataDiff,this._getFilterPredicate(e.filter));if(e.updateCluster&&this._geoJSONIndex.updateClusterOptions(e.geojsonVtOptions.cluster,_(e)),null==this._geoJSONIndex)throw new Error(`Input data given to '${e.source}' is not a valid GeoJSON object.`)}))}_filterGeoJSON(t,e){if("FeatureCollection"!==t.type)return t;const i=this._getFilterPredicate(e);return i?{type:"FeatureCollection",features:t.features.filter((t=>i(t)))}:t}_getFilterPredicate(e){if("boolean"!=typeof e&&!(null==e?void 0:e.length))return;const i=t.c$(e,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return t=>i.value.evaluate({zoom:0},t)}removeSource(e){return t._(this,void 0,void 0,(function*(){var t;null===(t=this._pendingRequest)||void 0===t||t.abort()}))}getClusterExpansionZoom(t){return this._geoJSONIndex.getClusterExpansionZoom(t.clusterId)}getClusterChildren(t){return this._geoJSONIndex.getClusterChildren(t.clusterId)}getClusterLeaves(t){return this._geoJSONIndex.getClusterLeaves(t.clusterId,t.limit,t.offset)}}function m(e,i){const n=t.e(i.geojsonVtOptions||{},{updateable:!0,clusterOptions:_(i)});return new t.d0(e,n)}function _({geojsonVtOptions:e,clusterProperties:i}){if(!i||!e.clusterOptions)return e.clusterOptions;const n={},s={},r={accumulated:null,zoom:0},o={properties:null},a=Object.keys(i);for(const e of a){const[r,o]=i[e],a=t.c$(o),h=t.c$("string"==typeof r?[r,["accumulated"],["get",e]]:r);n[e]=a.value,s[e]=h.value}return e.clusterOptions.map=t=>{o.properties=t;const e={};for(const t of a)e[t]=n[t].evaluate(r,o);return e},e.clusterOptions.reduce=(t,e)=>{o.properties=e;for(const e of a)r.accumulated=t[e],t[e]=s[e].evaluate(r,o)},e.clusterOptions}class g{constructor(e){this.self=e,this.actor=new t.N(e),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(t,e)=>{if(this.externalWorkerSourceTypes[t])throw new Error(`Worker source with name "${t}" already registered.`);this.externalWorkerSourceTypes[t]=e},this.self.addProtocol=t.cH,this.self.removeProtocol=t.cI,this.self.registerRTLTextPlugin=e=>{t.d1.setMethods(e)},this.self.makeRequest=t.m,this.actor.registerMessageHandler("LDT",((t,e)=>this._getDEMWorkerSource(t,e.source).loadTile(e))),this.actor.registerMessageHandler("RDT",((e,i)=>t._(this,void 0,void 0,(function*(){this._getDEMWorkerSource(e,i.source).removeTile(i)})))),this.actor.registerMessageHandler("GCEZ",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterExpansionZoom(i)})))),this.actor.registerMessageHandler("GCC",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterChildren(i)})))),this.actor.registerMessageHandler("GCL",((e,i)=>t._(this,void 0,void 0,(function*(){return this._getWorkerSource(e,i.type,i.source).getClusterLeaves(i)})))),this.actor.registerMessageHandler("LD",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadData(e))),this.actor.registerMessageHandler("LT",((t,e)=>this._getWorkerSource(t,e.type,e.source).loadTile(e))),this.actor.registerMessageHandler("RT",((t,e)=>this._getWorkerSource(t,e.type,e.source).reloadTile(e))),this.actor.registerMessageHandler("AT",((t,e)=>this._getWorkerSource(t,e.type,e.source).abortTile(e))),this.actor.registerMessageHandler("RMT",((t,e)=>this._getWorkerSource(t,e.type,e.source).removeTile(e))),this.actor.registerMessageHandler("RS",((e,i)=>t._(this,void 0,void 0,(function*(){var t,n;if(!(null===(n=null===(t=this.workerSources[e])||void 0===t?void 0:t[i.type])||void 0===n?void 0:n[i.source]))return;const s=this.workerSources[e][i.type][i.source];delete this.workerSources[e][i.type][i.source],void 0!==s.removeSource&&s.removeSource(i)})))),this.actor.registerMessageHandler("RM",(e=>t._(this,void 0,void 0,(function*(){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],this.globalStates.delete(e)})))),this.actor.registerMessageHandler("SR",((e,i)=>t._(this,void 0,void 0,(function*(){this.referrer=i})))),this.actor.registerMessageHandler("SRPS",((t,e)=>this._syncRTLPluginState(t,e))),this.actor.registerMessageHandler("IS",((e,i)=>t._(this,void 0,void 0,(function*(){this.self.importScripts(i)})))),this.actor.registerMessageHandler("SI",((t,e)=>this._setImages(t,e))),this.actor.registerMessageHandler("UL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).update(i.layers,i.removedIds,this._getGlobalState(e))})))),this.actor.registerMessageHandler("UGS",((e,i)=>t._(this,void 0,void 0,(function*(){const t=this._getGlobalState(e);for(const e in i)t[e]=i[e]})))),this.actor.registerMessageHandler("SL",((e,i)=>t._(this,void 0,void 0,(function*(){this._getLayerIndex(e).replace(i,this._getGlobalState(e))}))))}_getGlobalState(t){let e=this.globalStates.get(t);return e||(e={},this.globalStates.set(t,e)),e}_setImages(e,i){return t._(this,void 0,void 0,(function*(){this.availableImages[e]=i;for(const t in this.workerSources[e]){const n=this.workerSources[e][t];for(const t in n)n[t].availableImages=i}}))}_syncRTLPluginState(e,i){return t._(this,void 0,void 0,(function*(){return yield t.d1.syncState(i,this.self.importScripts)}))}_getAvailableImages(t){let e=this.availableImages[t];return e||(e=[]),e}_getLayerIndex(t){let i=this.layerIndexes[t];return i||(i=this.layerIndexes[t]=new e),i}_getWorkerSource(t,e,i){var n,s;if((n=this.workerSources)[t]||(n[t]={}),(s=this.workerSources[t])[e]||(s[e]={}),!this.workerSources[t][e][i]){const n={sendAsync:(e,i)=>(e.targetMapId=t,this.actor.sendAsync(e,i))};switch(e){case"vector":this.workerSources[t][e][i]=new f(n,this._getLayerIndex(t),this._getAvailableImages(t));break;case"geojson":this.workerSources[t][e][i]=new p(n,this._getLayerIndex(t),this._getAvailableImages(t));break;default:this.workerSources[t][e][i]=new this.externalWorkerSourceTypes[e](n,this._getLayerIndex(t),this._getAvailableImages(t))}}return this.workerSources[t][e][i]}_getDEMWorkerSource(t,e){var i,n;return(i=this.demWorkerSources)[t]||(i[t]={}),(n=this.demWorkerSources[t])[e]||(n[e]=new d),this.demWorkerSources[t][e]}}return t.i(self)&&(self.worker=new g(self)),g})),i("index",0,(function(t,e){var i="5.24.0";function n(){var t=new e.A(4);return e.A!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let s,r,o;const a={frame(t,i,n,s){const r=s||window,o=r.requestAnimationFrame((t=>{a(),i(t)})),{unsubscribe:a}=e.s(t.signal,"abort",(()=>{a(),r.cancelAnimationFrame(o),n(new e.a(t.signal.reason))}),!1)},frameAsync(t,e){return new Promise(((i,n)=>{this.frame(t,i,n,e)}))},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){const e=window.document.createElement("canvas"),i=e.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0,t.width,t.height),i},resolveURL:t=>(s||(s=document.createElement("a")),s.href=t,s.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==o?o:!!matchMedia&&(null!=r||(r=matchMedia("(prefers-reduced-motion: reduce)")),r.matches)},set prefersReducedMotion(t){o=t}},h=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:performance.now()}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function l(){return h.getCurrentTime()}var c,u;class f{static create(t,e,i){const n=window.document.createElement(t);return void 0!==e&&(n.className=e),i&&i.appendChild(n),n}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){f.docStyle&&f.selectProp&&(f.userSelect=f.docStyle[f.selectProp],f.docStyle[f.selectProp]="none")}static enableDrag(){f.docStyle&&f.selectProp&&(f.docStyle[f.selectProp]=f.userSelect)}static suppressClickInternal(t){t.preventDefault(),t.stopPropagation(),window.removeEventListener("click",f.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",f.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",f.suppressClickInternal,!0)}),0)}static getScale(t){const e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,i,n){const s=i.boundingClientRect;return new e.P((n.clientX-s.left)/i.x-t.clientLeft,(n.clientY-s.top)/i.y-t.clientTop)}static mousePos(t,e){const i=f.getScale(t);return f.getPoint(t,i,e)}static touchPos(t,e){const i=[],n=f.getScale(t);for(const s of e)i.push(f.getPoint(t,n,s));return i}static sanitize(t){const e=(new DOMParser).parseFromString(t,"text/html").body||document.createElement("body"),i=e.querySelectorAll("script");for(const t of i)t.remove();return f.clean(e),e.innerHTML}static isPossiblyDangerous(t,e){const i=e.replace(/\s+/g,"").toLowerCase();return!(!["src","href","xlink:href"].includes(t)||!i.includes("javascript:")&&!i.includes("data:"))||!!t.startsWith("on")||void 0}static clean(t){const e=t.children;for(const t of e)f.removeAttributes(t),f.clean(t)}static removeAttributes(t){for(const{name:e,value:i}of t.attributes)f.isPossiblyDangerous(e,i)&&t.removeAttribute(e)}}f.docStyle="undefined"!=typeof window&&(null===(c=window.document)||void 0===c?void 0:c.documentElement.style),f.selectProp=!f.docStyle||"userSelect"in f.docStyle?"userSelect":"webkitUserSelect",function(t){let i,n,s,r;t.resetRequestQueue=()=>{i=[],n=0,s=0,r={}},t.addThrottleControl=t=>{const e=s++;return r[e]=t,e},t.removeThrottleControl=t=>{delete r[t],a()},t.getImage=(t,n,s=!0)=>new Promise(((r,o)=>{t.headers||(t.headers={}),t.headers.accept="image/webp,*/*",e.e(t,{type:"image"}),i.push({abortController:n,requestParameters:t,supportImageRefresh:s,state:"queued",onError:t=>{o(t)},onSuccess:t=>{r(t)}}),a()}));const o=t=>e._(this,void 0,void 0,(function*(){t.state="running";const{requestParameters:i,supportImageRefresh:s,onError:r,onSuccess:o,abortController:l}=t,c=!1===s&&!e.i(self)&&!e.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce(((t,e)=>t&&"accept"===e),!0));n++;const u=c?h(i,l):e.m(i,l);try{const i=yield u;delete t.abortController,t.state="completed",i.data instanceof HTMLImageElement||e.b(i.data)?o(i):i.data&&o({data:yield(f=i.data,"function"==typeof createImageBitmap?e.h(f):e.j(f)),cacheControl:i.cacheControl,expires:i.expires})}catch(i){delete t.abortController,r(e.d(i))}finally{n--,a()}var f})),a=()=>{const t=(()=>{for(const t of Object.keys(r))if(r[t]())return!0;return!1})()?e.c.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:e.c.MAX_PARALLEL_IMAGE_REQUESTS;for(let e=n;e<t&&i.length>0;e++){const t=i.shift();t.abortController.signal.aborted?e--:o(t)}},h=(t,i)=>new Promise(((n,s)=>{const r=new Image,o=t.url,a=t.credentials;a&&"include"===a?r.crossOrigin="use-credentials":(a&&"same-origin"===a||!e.f(o))&&(r.crossOrigin="anonymous"),i.signal.addEventListener("abort",(()=>{r.src="",s(new e.a(i.signal.reason))})),r.fetchPriority="high",r.onload=()=>{r.onerror=r.onload=null,n({data:r})},r.onerror=()=>{r.onerror=r.onload=null,i.signal.aborted||s(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},r.src=o}))}(u||(u={})),u.resetRequestQueue();class d{constructor(t){this._transformRequestFn=null!=t?t:null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}}function p(t){const e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){const i=[];for(const{id:n,url:s}of t){const t=`${n}${s}`;i.includes(t)||(i.push(t),e.push({id:n,url:s}))}}return e}function m(t,e,i){try{const n=new URL(t);return n.pathname+=`${e}${i}`,n.toString()}catch(e){throw new Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function _(t){const{userImage:e}=t;return!(!(null==e?void 0:e.render)||!e.render()||(t.data.replace(new Uint8Array(e.data.buffer)),0))}class g extends e.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const t of Object.keys(this.images))this.removeImage(t);this.patterns={},this.atlasImage=new e.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){const i=this.images[t];if(i&&!i.data&&i.spriteData){const t=i.spriteData;i.data=new e.R({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),i.spriteData=null}return i}addImage(t,e){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e)}_validate(t,i){let n=!0;const s=i.data||i.spriteData;return this._validateStretch(i.stretchX,null==s?void 0:s.width)||(this.fire(new e.l(new Error(`Image "${t}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,null==s?void 0:s.height)||(this.fire(new e.l(new Error(`Image "${t}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.l(new Error(`Image "${t}" has invalid "content" value`))),n=!1),n}_validateStretch(t,e){if(!t)return!0;let i=0;for(const n of t){if(n[0]<i||n[1]<n[0]||e<n[1])return!1;i=n[1]}return!0}_validateContent(t,e){if(!t)return!0;if(4!==t.length)return!1;const i=e.spriteData,n=(null==i?void 0:i.width)||e.data.width,s=(null==i?void 0:i.height)||e.data.height;return!(t[0]<0||n<t[0]||t[1]<0||s<t[1]||t[2]<0||n<t[2]||t[3]<0||s<t[3]||t[2]<t[0]||!(t[3]>=t[1]))}updateImage(t,e,i=!0){const n=this.getImage(t);if(i&&(n.data.width!==e.data.width||n.data.height!==e.data.height))throw new Error(`size mismatch between old image (${n.data.width}x${n.data.height}) and new image (${e.data.width}x${e.data.height}).`);e.version=n.version+1,this.images[t]=e,this.updatedImages[t]=!0}removeImage(t){var e;const i=this.images[t];delete this.images[t],delete this.patterns[t],(null===(e=i.userImage)||void 0===e?void 0:e.onRemove)&&i.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(t){return new Promise((e=>{let i=!0;if(!this.isLoaded())for(const e of t)this.images[e]||(i=!1);this.isLoaded()||i?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}_getImagesForIds(t){var i;const n={};for(const s of t){let t=this.getImage(s);t||(this.fire(new e.n("styleimagemissing",{id:s})),t=this.getImage(s)),t?n[s]={data:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,textFitWidth:t.textFitWidth,textFitHeight:t.textFitHeight,hasRenderCallback:Boolean(null===(i=t.userImage)||void 0===i?void 0:i.render)}:e.w(`Image "${s}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:t,height:e}=this.atlasImage;return{width:t,height:e}}getPattern(t){const i=this.patterns[t],n=this.getImage(t);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},s=new e.I(i,n);this.patterns[t]={bin:i,position:s}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const i=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new e.T(t,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const e in this.patterns)t.push(this.patterns[e].bin);const{w:i,h:n}=e.p(t),s=this.atlasImage;s.resize({width:i||1,height:n||1});for(const t in this.patterns){const{bin:i}=this.patterns[t],n=i.x+1,r=i.y+1,o=this.getImage(t).data,a=o.width,h=o.height;e.R.copy(o,s,{x:0,y:0},{x:n,y:r},{width:a,height:h}),e.R.copy(o,s,{x:0,y:h-1},{x:n,y:r-1},{width:a,height:1}),e.R.copy(o,s,{x:0,y:0},{x:n,y:r+h},{width:a,height:1}),e.R.copy(o,s,{x:a-1,y:0},{x:n-1,y:r},{width:1,height:h}),e.R.copy(o,s,{x:0,y:0},{x:n+a,y:r},{width:1,height:h})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const i of t){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const t=this.getImage(i);t||e.w(`Image with ID: "${i}" was not found`),_(t)&&this.updateImage(i,t)}}cloneImages(){const t={};for(const e in this.images){const i=this.images[e];t[e]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return t}}const v=1e20,y=new Float64Array(256);for(let t=0;t<256;t++){const e=.5-Math.pow(t/255,1/2.2);y[t]=e*Math.abs(e)}function w(t,e,i,n,s,r,o,a,h){for(let l=e;l<e+n;l++)b(t,i*r+l,r,s,o,a,h);for(let l=i;l<i+s;l++)b(t,l*r+e,1,n,o,a,h)}function b(t,e,i,n,s,r,o){r[0]=0,o[0]=-v,o[1]=v,s[0]=t[e];for(let a=1,h=0,l=0;a<n;a++){s[a]=t[e+a*i];const n=a*a;do{const t=r[h];l=(s[a]-s[t]+n-t*t)/(a-t)/2}while(l<=o[h]&&--h>-1);h++,r[h]=a,o[h]=l,o[h+1]=v}for(let a=0,h=0;a<n;a++){for(;o[h+1]<a;)h++;const n=r[h],l=a-n;t[e+a*i]=s[n]+l*l}}y[255]=-v;const x=e.v.layout_symbol["text-font"].default.join(",");class M{constructor(t,e,i){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={},this.lang=i}setURL(t){this.url=t}getGlyphs(t){return e._(this,void 0,void 0,(function*(){const e=[];for(const i in t)for(const n of t[i])e.push(this._getAndCacheGlyphsPromise(i,n));const i=yield Promise.all(e),n={};for(const{stack:t,id:e,glyph:s}of i)n[t]||(n[t]={}),n[t][e]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return n}))}_getAndCacheGlyphsPromise(t,i){return e._(this,void 0,void 0,(function*(){var e,n;null!==(e=(n=this.entries)[t])&&void 0!==e||(n[t]={glyphs:{},requests:{},ranges:{}});const s=this.entries[t];let r=s.glyphs[i];return void 0!==r?{stack:t,id:i,glyph:r}:!this.url||this._charUsesLocalIdeographFontFamily(i)?(r=s.glyphs[i]=this._drawGlyph(s,t,i),{stack:t,id:i,glyph:r}):yield this._downloadAndCacheRangePromise(t,i)}))}_downloadAndCacheRangePromise(t,i){return e._(this,void 0,void 0,(function*(){var n;const s=this.entries[t],r=Math.floor(i/256);if(s.ranges[r])return{stack:t,id:i,glyph:null};(n=s.requests)[r]||(n[r]=M.loadGlyphRange(t,r,this.url,this.requestManager));try{const e=yield s.requests[r];for(const t in e)s.glyphs[+t]=e[+t];return s.ranges[r]=!0,{stack:t,id:i,glyph:e[i]||null}}catch(n){const o=s.glyphs[i]=this._drawGlyph(s,t,i);return this._warnOnMissingGlyphRange(o,r,i,e.d(n)),{stack:t,id:i,glyph:o}}}))}_warnOnMissingGlyphRange(t,i,n,s){const r=256*i,o=r+255,a=n.toString(16).padStart(4,"0").toUpperCase();e.w(`Unable to load glyph range ${i}, ${r}-${o}. Rendering codepoint U+${a} locally instead. ${s}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&e.r(t)}_drawGlyph(t,i,n){const s=i===x&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(n),r=s?"ideographTinySDF":"tinySDF";t[r]||(t[r]=this._createTinySDF(s?this.localIdeographFontFamily:i));const o=t[r].draw(String.fromCodePoint(n)),a=/^\p{gc=Cf}+$/u.test(String.fromCodePoint(n));return{id:n,bitmap:new e.t({width:o.width||60,height:o.height||60},o.data),metrics:{width:a?0:o.glyphWidth/2||24,height:o.glyphHeight/2||24,left:o.glyphLeft/2+.5||0,top:o.glyphTop/2-27.5||-8,advance:a?0:o.glyphAdvance/2||24,isDoubleResolution:!0}}}_createTinySDF(t){const e=t?t.split(","):[];e.push("sans-serif");const i=e.map((t=>/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`)).join(",");return new M.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(e[0]),fontStyle:this._fontStyle(e[0]),lang:this.lang})}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){const e={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[n,s]of Object.entries(e))new RegExp(`\\b${n}\\b`,"i").test(t)&&(i=`${s}`);return i}destroy(){for(const t in this.entries){const e=this.entries[t];e.tinySDF=null,e.ideographTinySDF=null,e.glyphs={},e.requests={},e.ranges={}}this.entries={}}}M.loadGlyphRange=function(t,i,n,s){return e._(this,void 0,void 0,(function*(){const r=256*i,o=r+255,a=yield s.transformRequest(n.replace("{fontstack}",t).replace("{range}",`${r}-${o}`),"Glyphs"),h=yield e.o(a,new AbortController);if(!(null==h?void 0:h.data))throw new Error(`Could not load glyph range. range: ${i}, ${r}-${o}`);const l={};for(const t of e.q(h.data))l[t.id]=t;return l}))},M.TinySDF=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:n=.25,fontFamily:s="sans-serif",fontWeight:r="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=e,this.radius=i,this.cutoff=n,this.lang=a;const h=this.size=t+4*e,l=this._createCanvas(h),c=this.ctx=l.getContext("2d",{willReadFrequently:!0});c.font=`${o} ${r} ${t}px ${s}`,c.textBaseline="alphabetic",c.textAlign="left",c.fillStyle="black",this.gridOuter=new Float64Array(h*h),this.gridInner=new Float64Array(h*h),this.f=new Float64Array(h),this.z=new Float64Array(h+1),this.v=new Uint16Array(h)}_createCanvas(t){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,t);const e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){const{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:n,actualBoundingBoxLeft:s,actualBoundingBoxRight:r}=this.ctx.measureText(t),o=Math.ceil(i),a=Math.floor(s),h=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(r)-a)),l=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(n))),c=h+2*this.buffer,u=l+2*this.buffer,f=Math.max(c*u,0),d=new Uint8ClampedArray(f),p={data:d,width:c,height:u,glyphWidth:h,glyphHeight:l,glyphTop:o,glyphLeft:a,glyphAdvance:e};if(0===h||0===l)return p;const{ctx:m,buffer:_,gridInner:g,gridOuter:b}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,h,l),m.fillText(t,_-a,_+o);const x=m.getImageData(_,_,h,l);b.fill(v,0,f),g.fill(0,0,f);let M=3;for(let t=0;t<l;t++){let e=(t+_)*c+_;for(let t=0;t<h;t++,M+=4,e++){const t=x.data[M];if(0===t)continue;const i=y[t];b[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}w(b,0,0,c,u,c,this.f,this.v,this.z),w(g,_,_,h,l,c,this.f,this.v,this.z);const S=255/this.radius,z=255*(1-this.cutoff);for(let t=0;t<f;t++){const e=Math.sqrt(b[t])-Math.sqrt(g[t]);d[t]=Math.round(z-S*e)}return p}};class S{constructor(){this.specification=e.x.light.position}possiblyEvaluate(t,i){return e.G(t.expression.evaluate(i))}interpolate(t,i,n){return{x:e.H.number(t.x,i.x,n),y:e.H.number(t.y,i.y,n),z:e.H.number(t.z,i.z,n)}}}let z;class T extends e.E{constructor(t){super(),z||(z=new e.u({anchor:new e.D(e.x.light.anchor),position:new S,color:new e.D(e.x.light.color),intensity:new e.D(e.x.light.intensity)})),this._transitionable=new e.y(z,void 0),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(t,i={}){if(!this._validate(e.z,t,i))for(const i in t){const n=t[i];i.endsWith(e.B)?this._transitionable.setTransition(i.slice(0,-e.B.length),n):this._transitionable.setValue(i,n)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,n){return!1!==(null==n?void 0:n.validate)&&e.C(this,t.call(e.F,{value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.x}))}}const E=new e.u({"sky-color":new e.D(e.x.sky["sky-color"]),"horizon-color":new e.D(e.x.sky["horizon-color"]),"fog-color":new e.D(e.x.sky["fog-color"]),"fog-ground-blend":new e.D(e.x.sky["fog-ground-blend"]),"horizon-fog-blend":new e.D(e.x.sky["horizon-fog-blend"]),"sky-horizon-blend":new e.D(e.x.sky["sky-horizon-blend"]),"atmosphere-blend":new e.D(e.x.sky["atmosphere-blend"])});class A extends e.E{constructor(t){super(),this._transitionable=new e.y(E,void 0),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.J(0))}setSky(t,i={}){if(!this._validate(e.K,t,i)){t||(t={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0});for(const i in t){const n=t[i];i.endsWith(e.B)?this._transitionable.setTransition(i.slice(0,-e.B.length),n):this._transitionable.setValue(i,n)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,i,n={}){return!1!==(null==n?void 0:n.validate)&&e.C(this,t.call(e.F,e.e({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.x})))}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}}class P{constructor(t,e){this.width=t,this.height=e,this.nextRow=0,this.data=new Uint8Array(this.width*this.height),this.dashEntry={}}getDash(t,e){var i;const n=t.join(",")+String(e);return(i=this.dashEntry)[n]||(i[n]=this.addDash(t,e)),this.dashEntry[n]}getDashRanges(t,e,i){const n=[];let s=t.length%2==1?-t[t.length-1]*i:0,r=t[0]*i,o=!0;n.push({left:s,right:r,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;const h=t[e];s=a*i,a+=h,r=a*i,n.push({left:s,right:r,isDash:o,zeroLength:0===h})}return n}addRoundDash(t,e,i){const n=e/2;for(let e=-i;e<=i;e++){const s=this.width*(this.nextRow+i+e);let r=0,o=t[r];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++r]);const h=Math.abs(a-o.left),l=Math.abs(a-o.right),c=Math.min(h,l);let u;const f=e/i*(n+1);if(o.isDash){const t=n-Math.abs(f);u=Math.sqrt(c*c+t*t)}else u=n-Math.sqrt(c*c+f*f);this.data[s+a]=Math.max(0,Math.min(255,u+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){const i=t[e],n=t[e+1];i.zeroLength?t.splice(e,1):n&&n.isDash===i.isDash&&(n.left=i.left,t.splice(e,1))}const e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);const n=this.width*this.nextRow;let s=0,r=t[s];for(let e=0;e<this.width;e++){e/r.right>1&&(r=t[++s]);const i=Math.abs(e-r.left),o=Math.abs(e-r.right),a=Math.min(i,o);this.data[n+e]=Math.max(0,Math.min(255,(r.isDash?a:-a)+128))}}addDash(t,i){const n=i?7:0,s=2*n+1;if(this.nextRow+s>this.height)return e.w("LineAtlas out of space"),null;let r=0;for(const e of t)r+=e;if(0!==r){const e=this.width/r,s=this.getDashRanges(t,this.width,e);i?this.addRoundDash(s,e,n):this.addRegularDash(s)}const o={y:this.nextRow+n,height:2*n,width:r};return this.nextRow+=s,this.dirty=!0,o}bind(t){const e=t.gl;this.texture?(e.bindTexture(e.TEXTURE_2D,this.texture),this.dirty&&(this.dirty=!1,e.texSubImage2D(e.TEXTURE_2D,0,0,0,this.width,this.height,e.ALPHA,e.UNSIGNED_BYTE,this.data))):(this.texture=e.createTexture(),e.bindTexture(e.TEXTURE_2D,this.texture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texImage2D(e.TEXTURE_2D,0,e.ALPHA,this.width,this.height,0,e.ALPHA,e.UNSIGNED_BYTE,this.data))}}const C="maplibre_preloaded_worker_pool";class D{constructor(){this.active={}}acquire(t){if(!this.workers)for(this.workers=[];this.workers.length<D.workerCount;)this.workers.push(new Worker(e.c.WORKER_URL));return this.active[t]=!0,this.workers.slice()}release(t){if(delete this.active[t],0===this.numActive()){for(const t of this.workers)t.terminate();this.workers=null}}isPreloaded(){return!!this.active[C]}numActive(){return Object.keys(this.active).length}}const F=Math.floor(a.hardwareConcurrency/2);let I,k;function $(){return I||(I=new D),I}D.workerCount=e.L(globalThis)?Math.max(Math.min(F,3),1):1;class O{constructor(t,i){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let t=0;t<n.length;t++){const s=new e.N(n[t],i);s.name=`Worker ${t}`,this.actors.push(s)}if(!this.actors.length)throw new Error("No actors found")}broadcast(t,e){const i=[];for(const n of this.actors)i.push(n.sendAsync({type:t,data:e}));return Promise.all(i)}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){for(const t of this.actors)t.remove();this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,e){for(const i of this.actors)i.registerMessageHandler(t,e)}unregisterMessageHandler(t){for(const e of this.actors)e.unregisterMessageHandler(t)}}function j(){return k||(k=new O($(),e.M),k.registerMessageHandler("GR",((t,i,n)=>e.m(i,n)))),k}function R(t,i){const n=e.O();return e.Q(n,n,[1,1,0]),e.S(n,n,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?e.U(n,n,t.calculatePosMatrix(i.toUnwrapped())):n}function L(t,e,i,n,s,r,o){var a;const h=function(t,e,i){if(t)for(const n of t){const t=e[n];if((null==t?void 0:t.source)===i&&"fill-extrusion"===t.type)return!0}else for(const t in e){const n=e[t];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==s?void 0:s.layers)&&void 0!==a?a:null,e,t.id),l=r.maxPitchScaleFactor(),c=t.tilesIn(n,l,h);c.sort(B);const u=[];for(const n of c)u.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(e,i,t.getState(),n.queryGeometry,n.cameraQueryGeometry,n.scale,s,r,l,R(r,n.tileID),o?(t,e)=>o(n.tileID,t,e):void 0)});return function(t,e){for(const i in t)for(const n of t[i])N(n,e);return t}(function(t){const e={},i={};for(const{queryResults:n,wrappedTileID:s}of t){i[s]||(i[s]={});const t=i[s];for(const i in n){const s=n[i];t[i]||(t[i]={});const r=t[i];e[i]||(e[i]=[]);for(const t of s)r[t.featureIndex]||(r[t.featureIndex]=!0,e[i].push(t))}}return e}(u),t)}function B(t,e){const i=t.tileID,n=e.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function N(t,e){const i=t.feature,n=e.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function U(t,i,n,s){return e._(this,void 0,void 0,(function*(){let r=t;if(t.url?r=(yield e.k(yield i.transformRequest(t.url,"Source"),n)).data:yield a.frameAsync(n,s),!r)return null;const o=e.V(e.e(r,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map((t=>t.id))),o}))}class G{constructor(t,e){t&&(e?this.setSouthWest(t).setNorthEast(e):Array.isArray(t)&&(4===t.length?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof e.W?new e.W(t.lng,t.lat):e.W.convert(t),this}setSouthWest(t){return this._sw=t instanceof e.W?new e.W(t.lng,t.lat):e.W.convert(t),this}extend(t){const i=this._sw,n=this._ne;let s,r;if(t instanceof e.W)s=t,r=t;else{if(!(t instanceof G))return Array.isArray(t)?4===t.length||t.every(Array.isArray)?this.extend(G.convert(t)):this.extend(e.W.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(e.W.convert(t)):this;if(s=t._sw,r=t._ne,!s||!r)return this}return i||n?(i.lng=Math.min(s.lng,i.lng),i.lat=Math.min(s.lat,i.lat),n.lng=Math.max(r.lng,n.lng),n.lat=Math.max(r.lat,n.lat)):(this._sw=new e.W(s.lng,s.lat),this._ne=new e.W(r.lng,r.lat)),this}getCenter(){return new e.W((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new e.W(this.getWest(),this.getNorth())}getSouthEast(){return new e.W(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:i,lat:n}=e.W.convert(t);let s=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(s=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&s}intersects(t){if(!((t=G.convert(t)).getNorth()>=this.getSouth()&&t.getSouth()<=this.getNorth()))return!1;const i=Math.abs(this.getEast()-this.getWest()),n=Math.abs(t.getEast()-t.getWest());if(i>=360||n>=360)return!0;const s=e.X(this.getWest(),-180,180),r=e.X(this.getEast(),-180,180),o=e.X(t.getWest(),-180,180),a=e.X(t.getEast(),-180,180),h=s>r,l=o>a;return!(!h||!l)||(h?a>=s||o<=r:l?r>=o||s<=a:o<=r&&a>=s)}static convert(t){return t instanceof G?t:t?new G(t):t}static fromLngLat(t,i=0){const n=360*i/40075017,s=n/Math.cos(Math.PI/180*t.lat);return new G(new e.W(t.lng-s,t.lat-n),new e.W(t.lng+s,t.lat+n))}adjustAntiMeridian(){const t=new e.W(this._sw.lng,this._sw.lat),i=new e.W(this._ne.lng,this._ne.lat);return new G(t,t.lng>i.lng?new e.W(i.lng+360,i.lat):i)}}class V{constructor(t,e,i){this.bounds=G.convert(this.validateBounds(t)),this.minzoom=e||0,this.maxzoom=i||24}validateBounds(t){return Array.isArray(t)&&4===t.length?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const i=Math.pow(2,t.z),n=Math.floor(e.Z(this.bounds.getWest())*i),s=Math.floor(e.Y(this.bounds.getNorth())*i),r=Math.ceil(e.Z(this.bounds.getEast())*i),o=Math.ceil(e.Y(this.bounds.getSouth())*i);return t.x>=n&&t.x<r&&t.y>=s&&t.y<o}}class q extends e.E{constructor(t,i,n,s){if(super(),this.id=t,this.dispatcher=n,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.e(this,e.V(i,["url","scheme","tileSize","promoteId","encoding"])),this._options=e.e({type:"vector"},i),this._collectResourceTiming=i.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(s)}load(){return e._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new e.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(e.e(this,i),i.bounds&&(this.tileBounds=new V(i.bounds,this.minzoom,this.maxzoom)),this.fire(new e.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,e.$(t)||this.fire(new e.l(e.d(t)))}}))}loaded(){return this._loaded}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}onAdd(t){this.map=t,this.load()}setSourceProperty(t){this._tileJSONRequest&&this._tileJSONRequest.abort(),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return e.e({},this._options)}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:yield this.map._requestManager.transformRequest(e,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:yield this._getOverzoomParameters(t),etag:t.etag};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(t.actor&&"expired"!==t.state){if("loading"===t.state)return new Promise(((e,i)=>{t.reloadPromise={resolve:e,reject:i}}))}else t.actor=this.dispatcher.getActor(),n="LT";t.abortController=new AbortController;try{const e=yield t.actor.sendAsync({type:n,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e);const s={};return(null==e?void 0:e.etagUnmodified)&&(s.unmodified=!0),s}catch(e){if(delete t.abortController,t.aborted)return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}))}_getOverzoomParameters(t){return e._(this,void 0,void 0,(function*(){if(t.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const e=t.tileID.scaledTo(this.maxzoom).canonical,i=e.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:e,overzoomRequest:yield this.map._requestManager.transformRequest(i,"Tile")}}))}_afterTileLoadWorkerResponse(t,e){if((null==e?void 0:e.resourceTiming)&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.etag=null==e?void 0:e.etag,t.loadVectorData(e,this.map.painter),t.reloadPromise){const e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))}))}hasTransition(){return!1}}class Z extends e.E{constructor(t,i,n,s){super(),this.id=t,this.dispatcher=n,this.setEventedParent(s),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=e.e({type:"raster"},i),e.e(this,e.V(i,["url","scheme","tileSize"]))}load(){return e._(this,arguments,void 0,(function*(t=!1){this._loaded=!1,this.fire(new e.n("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield U(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,i&&(e.e(this,i),i.bounds&&(this.tileBounds=new V(i.bounds,this.minzoom,this.maxzoom)),this.fire(new e.n("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.n("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,e.$(t)||this.fire(new e.l(e.d(t)))}}))}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return e.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const n=yield u.getImage(yield this.map._requestManager.transformRequest(i,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(null==n?void 0:n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,s=i.gl,r=n.data;t.texture=this.map.painter.getTileTexture(r.width),t.texture?t.texture.update(r,{useMipmap:!0}):(t.texture=new e.T(i,r,s.RGBA,{useMipmap:!0}),t.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST)),t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)}))}hasTransition(){return!1}}class W extends Z{constructor(t,i,n,s){super(t,i,n,s),this.type="raster-dem",this.maxzoom=22,this._options=e.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(t){return e._(this,void 0,void 0,(function*(){const i=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=yield this.map._requestManager.transformRequest(i,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const i=yield u.getImage(n,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(null==i?void 0:i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const s=e.b(n)&&e.a0()?n:yield this.readImageNow(n),r={type:this.type,uid:t.uid,source:this.id,rawImageData:s,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(t.actor&&"expired"!==t.state&&"reloading"!==t.state)return;t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor()),t.dem=yield t.actor.sendAsync({type:"LDT",data:r}),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}))}readImageNow(t){return e._(this,void 0,void 0,(function*(){if("undefined"!=typeof VideoFrame&&e.a1()){const i=t.width+2,n=t.height+2;try{return new e.R({width:i,height:n},yield e.a2(t,-1,-1,i,n))}catch(t){}}return a.getImageData(t,1)}))}_getNeighboringTiles(t){const i=t.canonical,n=Math.pow(2,i.z),s=(i.x-1+n)%n,r=0===i.x?t.wrap-1:t.wrap,o=(i.x+1+n)%n,a=i.x+1===n?t.wrap+1:t.wrap,h={};return h[new e.a3(t.overscaledZ,r,i.z,s,i.y).key]={backfilled:!1},h[new e.a3(t.overscaledZ,a,i.z,o,i.y).key]={backfilled:!1},i.y>0&&(h[new e.a3(t.overscaledZ,r,i.z,s,i.y-1).key]={backfilled:!1},h[new e.a3(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},h[new e.a3(t.overscaledZ,a,i.z,o,i.y-1).key]={backfilled:!1}),i.y+1<n&&(h[new e.a3(t.overscaledZ,r,i.z,s,i.y+1).key]={backfilled:!1},h[new e.a3(t.overscaledZ,t.wrap,i.z,i.x,i.y+1).key]={backfilled:!1},h[new e.a3(t.overscaledZ,a,i.z,o,i.y+1).key]={backfilled:!1}),h}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.demTexture&&this.map.painter.saveTileTexture(t.demTexture),t.fbo&&(t.fbo.destroy(),delete t.fbo),t.dem&&delete t.dem,delete t.neighboringTiles,t.state="unloaded",t.actor&&(yield t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}}))}))}}function H(t,e){return e?t.properties[e]:t.id}function Y(t,e){const i={id:t.id};if(e.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete e.removeProperties),e.removeProperties)for(const i of e.removeProperties){const e=t.addOrUpdateProperties.findIndex((t=>t.key===i));e>-1&&t.addOrUpdateProperties.splice(e,1)}return(t.removeAllProperties||e.removeAllProperties)&&(i.removeAllProperties=!0),(t.removeProperties||e.removeProperties)&&(i.removeProperties=[...t.removeProperties||[],...e.removeProperties||[]]),(t.addOrUpdateProperties||e.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...t.addOrUpdateProperties||[],...e.addOrUpdateProperties||[]]),(t.newGeometry||e.newGeometry)&&(i.newGeometry=e.newGeometry||t.newGeometry),i}function X(t){var e,i;if(!t)return{};const n={};return n.removeAll=t.removeAll,n.remove=new Set(t.remove||[]),n.add=new Map(null===(e=t.add)||void 0===e?void 0:e.map((t=>[t.id,t]))),n.update=new Map(null===(i=t.update)||void 0===i?void 0:i.map((t=>[t.id,t]))),n}function J(t){return t&&0!==t.length?"number"==typeof t[0]?[t]:t.flatMap((t=>J(t))):[]}function K(t){return"GeometryCollection"===t.type?t.geometries.flatMap((t=>K(t))):J(t.coordinates)}function Q(t){const e=new G;let i;switch(t.type){case"FeatureCollection":i=t.features.flatMap((t=>K(t.geometry)));break;case"Feature":i=K(t.geometry);break;default:i=K(t)}if(0===i.length)return e;for(const t of i){const[i,n]=t;e.extend([i,n])}return e}class tt extends e.E{constructor(t,i,n,s){super(),this.id=t,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._removed=!1,this._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:i.data},this.actor=n.getActor(),this.setEventedParent(s),this._data="string"==typeof i.data?{url:i.data}:{geojson:i.data},this._options=e.e({},i),this._collectResourceTiming=i.collectResourceTiming,void 0!==i.maxzoom&&(this.maxzoom=i.maxzoom),i.type&&(this.type=i.type),i.attribution&&(this.attribution=i.attribution),this.promoteId=i.promoteId,void 0!==i.clusterMaxZoom&&this.maxzoom<=i.clusterMaxZoom&&e.w(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${i.clusterMaxZoom}".`),this.workerOptions=e.e({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0!==i.buffer?i.buffer:128),tolerance:this._pixelsToTileUnits(void 0!==i.tolerance?i.tolerance:.375),extent:e.a6,maxZoom:this.maxzoom,lineMetrics:i.lineMetrics||!1,generateId:i.generateId||!1,promoteId:"string"==typeof i.promoteId?i.promoteId:void 0,cluster:i.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(i.clusterMaxZoom),minPoints:Math.max(2,i.clusterMinPoints||2),extent:e.a6,radius:this._pixelsToTileUnits(i.clusterRadius||50),log:!1,generateId:i.generateId||!1}},clusterProperties:i.clusterProperties,filter:i.filter},i.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(e.a6/this.tileSize)}_getClusterMaxZoom(t){const i=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||e.w(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${i}"`),i}load(){return e._(this,void 0,void 0,(function*(){yield this._updateWorkerData()}))}onAdd(t){this.map=t,this.load()}setData(t,e){this._data="string"==typeof t?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t};const i=this._updateWorkerData();return e?i:this}updateData(t,e){this._pendingWorkerUpdate.diff=function(t,e){if(!t)return e||{};if(!e)return t||{};const i=X(t),n=X(e);!function(t,e){e.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),e.remove.clear());for(const i of e.remove)t.add.delete(i),t.update.delete(i);for(const[i,n]of e.update){const s=t.update.get(i);s&&(e.update.set(i,Y(s,n)),t.update.delete(i))}}(i,n);const s={};if((i.removeAll||n.removeAll)&&(s.removeAll=!0),s.remove=new Set([...i.remove,...n.remove]),s.add=new Map([...i.add,...n.add]),s.update=new Map([...i.update,...n.update]),s.remove.size&&s.add.size)for(const t of s.add.keys())s.remove.delete(t);return function(t){const e={};return t.removeAll&&(e.removeAll=t.removeAll),t.remove&&(e.remove=Array.from(t.remove)),t.add&&(e.add=Array.from(t.add.values())),t.update&&(e.update=Array.from(t.update.values())),e}(s)}(this._pendingWorkerUpdate.diff,t);const i=this._updateWorkerData();return e?i:this}getData(){return e._(this,void 0,void 0,(function*(){return this._data.url&&(yield this.once("data")),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}))}getBounds(){return e._(this,void 0,void 0,(function*(){return Q(yield this.getData())}))}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,void 0!==t.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData(),this}getClusterExpansionZoom(t){return this.actor.sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}getClusterChildren(t){return this.actor.sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}getClusterLeaves(t,e,i){return this.actor.sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}_updateWorkerData(){return e._(this,void 0,void 0,(function*(){if(this._isUpdatingWorker)return;if(!this._hasPendingWorkerUpdate())return void e.w(`No pending worker updates for GeoJSONSource ${this.id}.`);const{data:t,diff:i,updateCluster:n}=this._pendingWorkerUpdate,s=this._getLoadGeoJSONParameters(t,i,n);void 0!==t?this._pendingWorkerUpdate.data=void 0:i?this._pendingWorkerUpdate.diff=void 0:n&&(this._pendingWorkerUpdate.updateCluster=void 0),yield this._dispatchWorkerUpdate(s)}))}_getLoadGeoJSONParameters(t,i,n){return e._(this,void 0,void 0,(function*(){const s=e.e({type:this.type},this.workerOptions);return"string"==typeof t?(s.request=yield this.map._requestManager.transformRequest(a.resolveURL(t),"Source"),s.request.collectResourceTiming=this._collectResourceTiming,s):void 0!==t?(s.data=t,s):i?(s.dataDiff=i,s):n?(s.updateCluster=!0,s):void 0}))}_dispatchWorkerUpdate(t){return e._(this,void 0,void 0,(function*(){this._isUpdatingWorker=!0,this.fire(new e.n("dataloading",{dataType:"source"}));try{const i=yield t,n=yield this.actor.sendAsync({type:"LD",data:i});if(this._isUpdatingWorker=!1,this._removed||n.abandoned)return void this.fire(new e.n("dataabort",{dataType:"source"}));n.data&&(this._data={geojson:n.data});const s=this._applyDiffToSource(i.dataDiff),r=this._getShouldReloadTileOptions(s),o={dataType:"source"};this._applyResourceTiming(o,n),this.fire(new e.n("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new e.n("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:r})))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new e.n("dataabort",{dataType:"source"}));this.fire(new e.l(e.d(t)))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}}))}_applyResourceTiming(t,i){var n;if(!this._collectResourceTiming)return;const s=null===(n=i.resourceTiming)||void 0===n?void 0:n[this.id];if(!s)return;const r=s.slice(0);(null==r?void 0:r.length)&&e.e(t,{resourceTiming:r})}_applyDiffToSource(t){if(!t)return;const e="string"==typeof this.promoteId?this.promoteId:void 0;if(!this._data.url&&!this._data.updateable){const t=function(t,e){const i=new Map;if(null==t)return i;if(null==t.type)return i;if("Feature"===t.type){const n=H(t,e);if(null==n)return;return i.set(n,t),i}if("FeatureCollection"===t.type){const n=new Set;for(const s of t.features){const t=H(s,e);if(null==t)return;if(n.has(t))return;n.add(t),i.set(t,s)}return i}}(this._data.geojson,e);if(!t)throw new Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;const i=function(t,e,i){var n,s;const r=[];if(e.removeAll)t.clear();else if(e.remove)for(const i of e.remove){const e=t.get(i);e&&(r.push(e.geometry),t.delete(i))}if(e.add)for(const n of e.add){const e=H(n,i);if(null==e)continue;const s=t.get(e);s&&r.push(s.geometry),r.push(n.geometry),t.set(e,n)}if(e.update)for(const i of e.update){const e=t.get(i.id);if(!e)continue;const o=!!i.newGeometry,a=i.removeAllProperties||(null===(n=i.removeProperties)||void 0===n?void 0:n.length)>0||(null===(s=i.addOrUpdateProperties)||void 0===s?void 0:s.length)>0;if(!o&&!a)continue;r.push(e.geometry);const h=Object.assign({},e);if(t.set(i.id,h),o&&(r.push(i.newGeometry),h.geometry=i.newGeometry),a){if(h.properties=i.removeAllProperties?{}:Object.assign({},h.properties||{}),i.removeProperties)for(const t of i.removeProperties)delete h.properties[t];if(i.addOrUpdateProperties)for(const{key:t,value:e}of i.addOrUpdateProperties)h.properties[t]=e}}return r}(this._data.updateable,t,e);return t.removeAll||this._options.cluster?void 0:i}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((t=>Q(t)))}}shouldReloadTile(t,{affectedBounds:i}){if("loading"===t.state)return!0;if("unloaded"===t.state)return!1;const{buffer:n,extent:s}=this.workerOptions.geojsonVtOptions,r=function({x:t,y:i,z:n},s=0){const r=e.a4((t-s)/Math.pow(2,n)),o=e.a5((i+1+s)/Math.pow(2,n)),a=e.a4((t+1+s)/Math.pow(2,n)),h=e.a5((i-s)/Math.pow(2,n));return new G([r,o],[a,h])}(t.tileID.canonical,n/s);for(const t of i)if(r.intersects(t))return!0;return!1}loaded(){return!this._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}loadTile(t){return e._(this,void 0,void 0,(function*(){const e=t.actor?"RT":"LT";t.actor=this.actor;const i={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity};t.abortController=new AbortController;const n=yield this.actor.sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(n,this.map.painter,"RT"===e)}))}abortTile(t){return e._(this,void 0,void 0,(function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}))}unloadTile(t){return e._(this,void 0,void 0,(function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}))}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return e.e({},this._options,{type:this.type,data:this._data.updateable?{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}:this._data.url||this._data.geojson})}hasTransition(){return!1}}class et extends e.E{constructor(t,e,i,n){super(),this.flippedWindingOrder=!1,this.id=t,this.dispatcher=i,this.coordinates=e.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(n),this.options=e}load(t){return e._(this,void 0,void 0,(function*(){this._loaded=!1,this.fire(new e.n("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const e=yield u.getImage(yield this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,(null==e?void 0:e.data)&&(this.image=e.data,t&&(this.coordinates=t),this._finishLoading())}catch(t){this._request=null,this._loaded=!0,e.$(t)||this.fire(new e.l(e.d(t)))}}))}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally((()=>this.texture=null)),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.n("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const i=t.map(e.a7.fromLngLat);var n;return this.tileID=function(t){const i=e.a8.fromPoints(t),n=i.width(),s=i.height(),r=Math.max(n,s),o=Math.max(0,Math.floor(-Math.log(r)/Math.LN2)),a=Math.pow(2,o);return new e.aa(o,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map((t=>this.tileID.getTilePoint(t)._round())),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new e.n("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,i=t.gl;this.texture||(this.texture=new e.T(t,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return e._(this,void 0,void 0,(function*(){var e;(null===(e=this.tileID)||void 0===e?void 0:e.equals(t.tileID.canonical))?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(t){const{minX:i,minY:n,maxX:s,maxY:r}=e.a8.fromPoints(t),o={};for(let t=0;t<=e.a9;t++){const e=Math.pow(2,t),a=Math.floor(i*e),h=Math.floor(n*e),l=Math.floor(s*e),c=Math.floor(r*e),u=(a%e+e)%e,f=l%e,d=Math.floor(a/e),p=Math.floor(l/e);o[t]={minWrap:d,maxWrap:p,minTileXWrapped:u,maxTileXWrapped:f,minTileY:h,maxTileY:c}}return o}}class it extends et{constructor(t,e,i,n){super(t,e,i,n),this._onPlayingHandler=()=>{var t;null===(t=this.map)||void 0===t||t.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=e}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const e of t.urls)this.urls.push((yield this.map._requestManager.transformRequest(e,"Source")).url);try{const t=yield e.ab(this.urls);if(this._loaded=!0,!t)return;this.video=t,this.video.loop=!0,this.video.addEventListener("playing",this._onPlayingHandler),this.map&&this.video.play(),this._finishLoading()}catch(t){this.fire(new e.l(e.d(t)))}}))}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;t<i.start(0)||t>i.end(0)?this.fire(new e.l(new e.ac(`sources.${this.id}`,null,`Playback for this video can be set only between the ${i.start(0)} and ${i.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}onRemove(){super.onRemove(),this.video&&(this.video.removeEventListener("playing",this._onPlayingHandler),this.video.pause())}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,i=t.gl;this.texture?this.video.paused||(this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE),i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,this.video)):(this.texture=new e.T(t,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,n=!0)}n&&this.fire(new e.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class nt extends et{constructor(t,i,n,s){super(t,i,n,s),i.coordinates?Array.isArray(i.coordinates)&&4===i.coordinates.length&&!i.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t))))||this.fire(new e.l(new e.ac(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.l(new e.ac(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.l(new e.ac(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new e.l(new e.ac(`sources.${t}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.l(new e.ac(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return e._(this,void 0,void 0,(function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.l(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}))}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,n=i.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new e.T(i,this.canvas,n.RGBA,{premultiply:!0}),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let s=!1;for(const t in this.tiles){const e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,s=!0)}s&&this.fire(new e.n("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const st={},rt=t=>{switch(t){case"geojson":return tt;case"image":return et;case"raster":return Z;case"raster-dem":return W;case"vector":return q;case"video":return it;case"canvas":return nt}return st[t]},ot="RTLPluginLoaded";class at extends e.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=j()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch((t=>{throw this.status="error",t}))}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return e._(this,arguments,void 0,(function*(t,e=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(t),!this.url)throw new Error(`requested url ${t} is invalid`);if("unavailable"===this.status){if(!e)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()}))}_requestImport(){return e._(this,void 0,void 0,(function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new e.n(ot))}))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let ht=null;function lt(){return ht||(ht=new at),ht}var ct,ut;!function(t){t[t.Base=0]="Base",t[t.Parent=1]="Parent"}(ct||(ct={})),function(t){t[t.Departing=0]="Departing",t[t.Incoming=1]="Incoming"}(ut||(ut={}));class ft{constructor(t,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=e.ad(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading"}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:e,fadingParentID:i,fadeEndTime:n}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=e,this.fadingParentID=i,this.fadeEndTime=n}setSelfFadeLogic(t){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=t}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=l(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(t){this.demTexture&&t.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(t,i,n){if(!0!==(null==t?void 0:t.etagUnmodified))if(this.hasData()&&this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestEncoding=t.encoding,this.latestFeatureIndex.rawTileData=t.rawTileData,this.latestFeatureIndex.encoding=t.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(t,e){const i={};if(!e)return i;for(const n of t){const t=n.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){n.layers=t,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(const e of t)i[e.id]=n}}return i}(t.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.af){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const t in this.buckets){const i=this.buckets[t];if(i instanceof e.af&&i.hasRTLText){this.hasRTLText=!0,lt().lazyLoad();break}}this.queryPadding=0;for(const t in this.buckets){const e=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(t).queryRadius(e))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new e.ae;else this.state="loaded"}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.imageAtlas=null,this.dashPositions=null,this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const e in this.buckets){const i=this.buckets[e];i.uploadPending()&&i.upload(t)}const i=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new e.T(t,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new e.T(t,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,n,s,r,o,a,h,l,c){var u;return(null===(u=this.latestFeatureIndex)||void 0===u?void 0:u.rawTileData)?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:s,scale:r,tileSize:this.tileSize,pixelPosMatrix:l,transform:a,params:o,queryPadding:this.queryPadding*h,getElevation:c},t,e,i):{}}querySourceFeatures(t,i){const n=this.latestFeatureIndex;if(!(null==n?void 0:n.rawTileData))return;const s=n.loadVTLayers(),r=(null==i?void 0:i.sourceLayer)?i.sourceLayer:"",o=s[e.ag]||s[r];if(!o)return;const a=e.ah(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:h,x:l,y:c}=this.tileID.canonical,u={z:h,x:l,y:c};for(let i=0;i<o.length;i++){const s=o.feature(i);if(a.needGeometry){const t=e.ai(s,!0);if(!a.filter(new e.J(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!a.filter(new e.J(this.tileID.overscaledZ),s))continue;const f=n.getId(s,r),d=new e.aj(s,h,l,c,f);d.tile=u,t.push(d)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const i=this.expirationTime;if(t.cacheControl){const i=e.ak(t.cacheControl);i["max-age"]&&(this.expirationTime=Date.now()+1e3*i["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const t=Date.now();let e=!1;if(this.expirationTime>t)e=!1;else if(i)if(this.expirationTime<i)e=!0;else{const n=this.expirationTime-i;n?this.expirationTime=t+Math.max(n,3e4):e=!0}else e=!0;e?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-(new Date).getTime(),Math.pow(2,31)-1)}setFeatureState(t,i){var n,s,r;if(!(null===(n=this.latestFeatureIndex)||void 0===n?void 0:n.rawTileData)||0===Object.keys(t).length)return;const o=this.latestFeatureIndex.loadVTLayers();for(const n in this.buckets){if(!i.style.hasLayer(n))continue;const a=this.buckets[n],h=a.layers[0].sourceLayer||e.ag,l=o[h],c=t[h];if(!l||!c||0===Object.keys(c).length)continue;a.update(c,l,(null===(s=this.imageAtlas)||void 0===s?void 0:s.patternPositions)||{},this.dashPositions||{});const u=null===(r=null==i?void 0:i.style)||void 0===r?void 0:r.getLayer(n);u&&(this.queryPadding=Math.max(this.queryPadding,u.queryRadius(a)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<l()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=l()+t}setDependencies(t,e){const i={};for(const t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(const i of t){const t=this.dependencies[i];if(t)for(const i of e)if(t[i])return!0}return!1}}class dt{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(t,i,n){var s,r,o,a,h;const l=String(i);if((a=this.stateChanges)[t]||(a[t]={}),(h=this.stateChanges[t])[l]||(h[l]={}),e.e(this.stateChanges[t][l],n),null===this.deletedStates[t]){this.deletedStates[t]={};for(const e in this.state[t])e!==l&&(this.deletedStates[t][e]=null)}else if(null===(null===(s=this.deletedStates[t])||void 0===s?void 0:s[l])){this.deletedStates[t][l]={};for(const e in this.state[t][l])n[e]||(this.deletedStates[t][l][e]=null)}else for(const e in n)null===(null===(o=null===(r=this.deletedStates[t])||void 0===r?void 0:r[l])||void 0===o?void 0:o[e])&&delete this.deletedStates[t][l][e]}removeFeatureState(t,e,i){var n,s,r;if(null===this.deletedStates[t])return;const o=String(e);if((s=this.deletedStates)[t]||(s[t]={}),i&&void 0!==e)null!==this.deletedStates[t][o]&&((r=this.deletedStates[t])[o]||(r[o]={}),this.deletedStates[t][o][i]=null);else if(void 0!==e)if(null===(n=this.stateChanges[t])||void 0===n?void 0:n[o])for(i in this.deletedStates[t][o]={},this.stateChanges[t][o])this.deletedStates[t][o][i]=null;else this.deletedStates[t][o]=null;else this.deletedStates[t]=null}getState(t,i){const n=String(i),s=e.e({},(this.state[t]||{})[n],(this.stateChanges[t]||{})[n]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){const e=this.deletedStates[t][i];if(null===e)return{};for(const t in e)delete s[t]}return s}initializeTileState(t,e){t.setFeatureState(this.state,e)}coalesceChanges(t,i){var n,s,r;const o={};for(const t in this.stateChanges){(n=this.state)[t]||(n[t]={});const i={};for(const n in this.stateChanges[t])(s=this.state[t])[n]||(s[n]={}),e.e(this.state[t][n],this.stateChanges[t][n]),i[n]=this.state[t][n];o[t]=i}for(const t in this.deletedStates){(r=this.state)[t]||(r[t]={});const i={};if(null===this.deletedStates[t])for(const e in this.state[t])i[e]={},this.state[t][e]={};else for(const e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(const i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[e]=this.state[t][e]}o[t]||(o[t]={}),e.e(o[t],i)}this.stateChanges={},this.deletedStates={},0!==Object.keys(o).length&&(this.revision++,t.setFeatureState(o,i))}}const pt=89.25;function mt(t,i){const n=e.al(i.lat,-e.am,e.am);return new e.P(e.Z(i.lng)*t,e.Y(n)*t)}function _t(t,i){return new e.a7(i.x/t,i.y/t).toLngLat()}function gt(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(e.an(90-t.pitch)),Math.tan(e.an(pt-t.pitch)))}function vt(t,i){const n=t.canonical,s=i/e.ao(n.z),r=n.x+Math.pow(2,n.z)*t.wrap,o=e.ap(new Float64Array(16));return e.Q(o,o,[r*s,n.y*s,0]),e.S(o,o,[s/e.a6,s/e.a6,1]),o}function yt(t,i,n,s,r){const o=e.a7.fromLngLat(t,i),a=r*e.aq(1,t.lat),{x:h,y:l,z:c}=wt(n,s);return new e.a7(o.x+a*-h,o.y+a*-l,o.z+a*-c)}function wt(t,i){const n=e.an(t),s=e.an(i),r=Math.cos(-n),o=Math.sin(n);return{x:o*Math.sin(s),y:-o*Math.cos(s),z:r}}function bt(t,e,i){const n=e.intersectsFrustum(t);if(!i||0===n)return n;const s=e.intersectsPlane(i);return 0===s?0:2===n&&2===s?2:1}function xt(t,e,i){let n=0;const s=(i-e)/10;for(let r=0;r<10;r++)n+=s*Math.pow(Math.cos(e+(r+.5)/10*(i-e)),t);return n}function Mt(t,i){return function(n,s,r,o,a){const h=2*((t-1)/e.ar(Math.cos(e.an(pt-a))/Math.cos(e.an(pt)))-1),l=Math.acos(r/o),c=2*xt(h-1,0,e.an(a/2)),u=Math.min(e.an(pt),l+e.an(a/2)),f=xt(h-1,Math.min(u,l-e.an(a/2)),u),d=Math.atan(s/r),p=Math.hypot(s,r);let m=n;return m+=e.ar(o/p/Math.max(.5,Math.cos(e.an(a/2)))),m+=h*e.ar(Math.cos(d))/2,m-=e.ar(Math.max(1,f/c/i))/2,m}}const St=Mt(9.314,3);function zt(t,i){const n=(i.roundZoom?Math.round:Math.floor)(t.zoom+e.ar(t.tileSize/i.tileSize));return Math.max(0,n)}function Tt(t,i){const n=t.getCameraFrustum(),s=t.getClippingPlane(),r=t.screenPointToMercatorCoordinate(t.getCameraPoint()),o=e.a7.fromLngLat(t.center,t.elevation);r.z=o.z+Math.cos(t.pitchInRadians)*t.cameraToCenterDistance/t.worldSize;const a=t.getCoveringTilesDetailsProvider(),h=a.allowVariableZoom(t,i),l=zt(t,i),c=i.minzoom||0,u=void 0!==i.maxzoom?i.maxzoom:t.maxZoom,f=Math.min(Math.max(0,l),u),d=Math.pow(2,f),p=[d*r.x,d*r.y,0],m=[d*o.x,d*o.y,0],_=Math.hypot(o.x-r.x,o.y-r.y),g=Math.abs(o.z-r.z),v=Math.hypot(_,g),y=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),w=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)w.push(y(-t)),w.push(y(t));for(w.push(y(0));w.length>0;){const d=w.pop(),_=d.x,y=d.y;let x=d.fullyVisible;const M={x:_,y,z:d.zoom},S=a.getTileBoundingVolume(M,d.wrap,t.elevation,i);if(!x){const t=bt(n,S,s);if(0===t)continue;x=2===t}const z=a.distanceToTile2d(r.x,r.y,M,S);let T=l;h&&(T=(i.calculateTileZoom||St)(t.zoom+e.ar(t.tileSize/i.tileSize),z,g,v,t.fov)),T=(i.roundZoom?Math.round:Math.floor)(T),T=Math.max(0,T);const E=Math.min(T,u);if(d.wrap=a.getWrap(o,M,d.wrap),d.zoom>=E){if(d.zoom<c)continue;const t=f-d.zoom,n=p[0]-.5-(_<<t),s=p[1]-.5-(y<<t),r=i.reparseOverscaled?Math.max(d.zoom,T):d.zoom;b.push({tileID:new e.a3(d.zoom===u?r:d.zoom,d.wrap,d.zoom,_,y),distanceSq:e.as([m[0]-.5-_,m[1]-.5-y]),tileDistanceToCamera:Math.sqrt(n*n+s*s)})}else for(let t=0;t<4;t++)w.push({zoom:d.zoom+1,x:(_<<1)+t%2,y:(y<<1)+(t>>1),wrap:d.wrap,fullyVisible:x})}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}const Et=e.a8.fromPoints([new e.P(0,0),new e.P(e.a6,e.a6)]);function At(t){return"raster"===t||"image"===t||"video"===t}function Pt(t,e,i,n,s,r,o){if(!e.hasData())return!1;const{tileID:a,fadingRole:h,fadingDirection:l,fadingParentID:c}=e;if(h===ct.Base&&l===ut.Incoming&&c)return i[c.key]=c,!0;const u=Math.max(a.overscaledZ-s,r);for(let s=a.overscaledZ-1;s>=u;s--){const r=a.scaledTo(s),h=t.getLoadedTile(r);if(h)return e.setCrossFadeLogic({fadingRole:ct.Base,fadingDirection:ut.Incoming,fadingParentID:h.tileID,fadeEndTime:n+o}),h.setCrossFadeLogic({fadingRole:ct.Parent,fadingDirection:ut.Departing,fadeEndTime:n+o}),i[r.key]=r,!0}return!1}function Ct(t,e,i,n,s,r){if(!e.hasData())return!1;const o=e.tileID.children(s);let a=Dt(t,e,o,i,n,s,r);if(a)return!0;for(const h of o)Dt(t,e,h.children(s),i,n,s,r)&&(a=!0);return a}function Dt(t,e,i,n,s,r,o){if(i[0].overscaledZ>=r)return!1;let a=!1;for(const r of i){const i=t.getLoadedTile(r);if(!i)continue;const{fadingRole:h,fadingDirection:l,fadingParentID:c}=i;h===ct.Base&&l===ut.Departing&&c||(i.setCrossFadeLogic({fadingRole:ct.Base,fadingDirection:ut.Departing,fadingParentID:e.tileID,fadeEndTime:s+o}),e.setCrossFadeLogic({fadingRole:ct.Parent,fadingDirection:ut.Incoming,fadeEndTime:s+o})),n[r.key]=r,a=!0}return a}function Ft(t,e,i,n){const s=t.tileID;return!!t.selfFading||!t.hasData()&&!!e.has(s)&&(t.setSelfFadeLogic(i+n),!0)}function It(t,e){var i;t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0;let n=e.tileID.canonical.x-t.tileID.canonical.x;const s=e.tileID.canonical.y-t.tileID.canonical.y,r=Math.pow(2,t.tileID.canonical.z),o=e.tileID.key;0===n&&0===s||Math.abs(s)>1||(Math.abs(n)>1&&(1===Math.abs(n+r)?n+=r:1===Math.abs(n-r)&&(n-=r)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,n,s),(null===(i=t.neighboringTiles)||void 0===i?void 0:i[o])&&(t.neighboringTiles[o].backfilled=!0)))}class kt{constructor(){this._tiles={}}handleWrapJump(t){const e={};for(const i in this._tiles){const n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e}setFeatureState(t,e){for(const i in this._tiles)this._tiles[i].setFeatureState(t,e)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((t=>t.tileID)).sort(e.au).map((t=>t.key)):Object.keys(this._tiles)}getTileById(t){return this._tiles[t]}setTile(t,e){this._tiles[t]=e}deleteTileById(t){delete this._tiles[t]}getLoadedTile(t){const e=this.getTileById(t.key);return(null==e?void 0:e.hasData())?e:null}isIdRenderable(t,e=!1){var i;return null===(i=this.getTileById(t))||void 0===i?void 0:i.isRenderable(e)}getRenderableIds(t=0,i){const n=[];for(const t of this.getAllIds())this.isIdRenderable(t,i)&&n.push(this.getTileById(t));return i?n.sort(((i,n)=>{const s=i.tileID,r=n.tileID,o=new e.P(s.canonical.x,s.canonical.y)._rotate(-t),a=new e.P(r.canonical.x,r.canonical.y)._rotate(-t);return s.overscaledZ-r.overscaledZ||a.y-o.y||a.x-o.x})).map((t=>t.tileID.key)):n.map((t=>t.tileID)).sort(e.au).map((t=>t.key))}}class $t extends e.E{constructor(t,i,n){super(),this.id=t,this.dispatcher=n,this.on("data",(t=>{this._dataHandler(t)})),this.on("dataloading",(()=>{this._sourceErrored=!1})),this.on("error",(()=>{this._sourceErrored=this._source.loaded()})),this._source=((t,e,i,n)=>{const s=new(rt(e.type))(t,e,i,n);if(s.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${s.id}`);return s})(t,i,n,this),this._inViewTiles=new kt,this._outOfViewCache=new e.av(0,(t=>this._unloadTile(t))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new dt,this._didEmitContent=!1,this._updated=!1}onAdd(t){var e;this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,(null===(e=this._source)||void 0===e?void 0:e.onAdd)&&this._source.onAdd(t)}onRemove(t){var e;for(const t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),(null===(e=this._source)||void 0===e?void 0:e.onRemove)&&this._source.onRemove(t),this._inViewTiles=new kt}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,i,n){return e._(this,void 0,void 0,(function*(){try{const e=yield this._source.loadTile(t);this._tileLoaded(t,i,n,e)}catch(i){t.state="errored",404!==i.status?this._source.fire(new e.l(e.d(i),{tile:t})):this.update(this.transform,this.terrain)}}))}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new e.n("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.map?this.map.painter:null);for(const e of this._inViewTiles.getAllTiles())e.upload(t),e.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){var e;return this._inViewTiles.getRenderableIds(null===(e=this.transform)||void 0===e?void 0:e.bearingInRadians,t)}hasRenderableParent(t){const e=t.overscaledZ-1;if(e>=this._source.minzoom){const i=this.getLoadedTile(t.scaledTo(e));if(i)return this._inViewTiles.isIdRenderable(i.tileID.key)}return!1}reload(t,e){if(this._paused)this._shouldReloadOnResume=!0;else{this._outOfViewCache.reset();for(const i of this._inViewTiles.getAllIds()){const n=this._inViewTiles.getTileById(i);e&&!this._source.shouldReloadTile(n,e)||(t?this._reloadTile(i,"expired"):"errored"!==n.state&&this._reloadTile(i,"reloading"))}}}_reloadTile(t,i){return e._(this,void 0,void 0,(function*(){const e=this._inViewTiles.getTileById(t);e&&("loading"!==e.state&&(e.state=i),yield this._loadTile(e,t,i))}))}_tileLoaded(t,i,n,s){t.timeAdded=l(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration),"expired"===n&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(i,t),(null==s?void 0:s.unmodified)||("raster-dem"===this.getSource().type&&t.dem&&function(t,e){var i,n,s;const r=e.getRenderableIds();for(const o of r){if(!(null===(i=t.neighboringTiles)||void 0===i?void 0:i[o]))continue;const r=e.getTileById(o);t.neighboringTiles[o].backfilled||It(t,r),(null===(s=null===(n=r.neighboringTiles)||void 0===n?void 0:n[t.tileID.key])||void 0===s?void 0:s.backfilled)||It(r,t)}}(t,this._inViewTiles),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new e.n("data",{dataType:"source",tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(t,e){const i=this._getLoadedDescendents(e),n=new Set;for(const s of e){const e=i[s.key];if(!(null==e?void 0:e.length)){n.add(s);continue}const r=s.overscaledZ+$t.maxOverzooming,o=e.filter((t=>t.tileID.overscaledZ<=r));if(!o.length){n.add(s);continue}const a=Math.min(...o.map((t=>t.tileID.overscaledZ))),h=o.filter((t=>t.tileID.overscaledZ===a)).map((t=>t.tileID));for(const e of h)t[e.key]=e;this._areDescendentsComplete(h,a,s.overscaledZ)||n.add(s)}return n}_getLoadedDescendents(t){var e;const i={};for(const n of this._inViewTiles.getAllTiles().filter((t=>t.hasData())))for(const s of t)n.tileID.isChildOf(s)&&(i[e=s.key]||(i[e]=[]),i[s.key].push(n));return i}_areDescendentsComplete(t,e,i){return 1===t.length&&t[0].isOverscaled()?t[0].overscaledZ===e:Math.pow(4,e-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){const i=Math.ceil(t.width/this._source.tileSize)+1,n=Math.ceil(t.height/this._source.tileSize)+1,s=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?e.c.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,s):s;this._outOfViewCache.setMaxSize(r)}handleWrapJump(t){const e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);this._prevLng=t,e&&(this._inViewTiles.handleWrapJump(e),this._resetTileReloadTimers())}update(t,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=t,this.terrain=i,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?n=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new e.a3(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(n=Tt(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?t.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter((t=>this._source.hasTile(t))))):n=[],this.usedForTerrain&&(n=this._addTerrainIdealTiles(n));const s=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,s&&this.fire(new e.n("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const r=zt(t,this._source),o=this._updateRetainedTiles(n,r),a=At(this._source.type);a&&this._rasterFadeDuration>0&&!i&&function(t,i,n,s,r,o,a){const h=l(),c=e.at(i);for(const e of i){const i=t.getTileById(e.key);i.fadingDirection!==ut.Departing&&0!==i.fadeOpacity||i.resetFadeLogic(),Pt(t,i,n,h,s,r,a)||Ct(t,i,n,h,o,a)||Ft(i,c,h,a)||i.resetFadeLogic()}}(this._inViewTiles,n,o,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),a?this._cleanUpRasterTiles(o):this._cleanUpVectorTiles(o)}_cleanUpRasterTiles(t){for(const e of this._inViewTiles.getAllIds())t[e]||this._removeTile(e)}_cleanUpVectorTiles(t){for(const e of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(e);t[e]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(e):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(e)}}_addTerrainIdealTiles(t){const e=[];for(const i of t)if(i.canonical.z>this._source.minzoom){const t=i.scaledTo(i.canonical.z-1);e.push(t);const n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));e.push(n)}return t.concat(e)}releaseSymbolFadeTiles(){for(const t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(t,e){var i;const n=new Set;for(const e of t)this._addTile(e).hasData()||n.add(e);const s=t.reduce(((t,e)=>(t[e.key]=e,t)),{}),r=this._retainLoadedChildren(s,n),o={},a=Math.max(e-$t.maxUnderzooming,this._source.minzoom);for(const t of r){let e=this._inViewTiles.getTileById(t.key),n=null==e?void 0:e.wasRequested();for(let r=t.overscaledZ-1;r>=a;--r){const a=t.scaledTo(r);if(o[a.key])break;if(o[a.key]=!0,e=this.getTile(a),!e&&n&&(e=this._addTile(a)),e){const t=e.hasData();if((t||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(s[a.key]=a),n=e.wasRequested(),t)break}}}return s}_addTile(t){let i=this._inViewTiles.getTileById(t.key);if(i)return i;i=this._outOfViewCache.getAndRemove(t),i&&(i.resetFadeLogic(),this._setTileReloadTimer(t.key,i),i.tileID=t,this._state.initializeTileState(i,this.map?this.map.painter:null));const n=i;return i||(i=new ft(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(i,t.key,i.state)),i.uses++,this._inViewTiles.setTile(t.key,i),n||this._source.fire(new e.n("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(t,e){this._clearTileReloadTimer(t);const i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_clearTileReloadTimer(t){const e=this._timers[t];e&&(clearTimeout(e),delete this._timers[t])}_resetTileReloadTimers(){for(const t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(const t of this._inViewTiles.getAllIds()){const e=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,e)}}refreshTiles(t){for(const e of this._inViewTiles.getAllIds()){const i=this._inViewTiles.getTileById(e);(this._inViewTiles.isIdRenderable(e)||"errored"==i.state)&&t.some((t=>t.equals(i.tileID.canonical)))&&this._reloadTile(e,"expired")}}_removeTile(t){const e=this._inViewTiles.getTileById(t);e&&(e.uses--,this._inViewTiles.deleteTileById(t),this._clearTileReloadTimer(t),e.uses>0||(e.hasData()&&"reloading"!==e.state?this._outOfViewCache.add(e.tileID,e,e.getExpiryTimeout()):(e.aborted=!0,this._abortTile(e),this._unloadTile(e))))}_dataHandler(t){"source"===t.dataType&&("metadata"!==t.sourceDataType?"content"===t.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,i,n){const s=[],r=this.transform;if(!r)return s;const o=r.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?r.getCameraQueryGeometry(t):t,h=t=>r.screenPointToMercatorCoordinate(t,this.terrain),l=this.transformBbox(t,h,!o),c=this.transformBbox(a,h,!o),u=this.getIds(),f=e.a8.fromPoints(c);for(const t of u){const n=this._inViewTiles.getTileById(t);if(n.holdingForSymbolFade())continue;const a=o?[n.tileID]:[n.tileID.unwrapTo(-1),n.tileID.unwrapTo(0)],h=Math.pow(2,r.zoom-n.tileID.overscaledZ),u=i*n.queryPadding*e.a6/n.tileSize/h;for(const t of a){const i=f.map((i=>t.getTilePoint(new e.a7(i.x,i.y))));if(i.expandBy(u),i.intersects(Et)){const e=l.map((e=>t.getTilePoint(e))),i=c.map((e=>t.getTilePoint(e)));s.push({tile:n,tileID:o?t:t.unwrapTo(0),queryGeometry:e,cameraQueryGeometry:i,scale:h})}}}return s}transformBbox(t,i,n){let s=t.map(i);if(n){const n=e.a8.fromPoints(t);n.shrinkBy(.001*Math.min(n.width(),n.height()));const r=n.map(i);e.a8.fromPoints(s).covers(r)||(s=s.map((t=>t.x>.5?new e.a7(t.x-1,t.y,t.z):t)))}return s}getVisibleCoordinates(t){const e=this.getRenderableIds(t).map((t=>this._inViewTiles.getTileById(t).tileID));return this.transform&&this.transform.populateCache(e),e}hasTransition(){return!!this._source.hasTransition()||At(this._source.type)&&function(t,e){if(e<=0)return!1;const i=l();for(const e of t.getAllTiles())if(e.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,i,n){t||(t=e.ag),this._state.updateState(t,i,n)}removeFeatureState(t,i,n){t||(t=e.ag),this._state.removeFeatureState(t,i,n)}getFeatureState(t,i){return t||(t=e.ag),this._state.getState(t,i)}setDependencies(t,e,i){const n=this._inViewTiles.getTileById(t);n&&n.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(const i of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(i).hasDependency(t,e)&&this._reloadTile(i,"reloading");this._outOfViewCache.filter((i=>!i.hasDependency(t,e)))}areTilesLoaded(){for(const t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}}$t.maxUnderzooming=10,$t.maxOverzooming=3;class Ot{constructor(t,e){this.reset(t,e)}reset(t,e){this.points=t||[],this._distances=[0];for(let t=1;t<this.points.length;t++)this._distances[t]=this._distances[t-1]+this.points[t].dist(this.points[t-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(e||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(t){if(1===this.points.length)return this.points[0];t=e.al(t,0,1);let i=1,n=this._distances[i];const s=t*this.paddedLength+this.padding;for(;n<s&&i<this._distances.length;)n=this._distances[++i];const r=i-1,o=this._distances[r],a=n-o,h=a>0?(s-o)/a:0;return this.points[r].mult(1-h).add(this.points[i].mult(h))}}function jt(t,e){let i=!0;return"always"===t||"never"!==t&&"never"!==e||(i=!1),i}class Rt{constructor(t,e,i){const n=this.boxCells=[],s=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)n.push([]),s.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=t,this.height=e,this.xScale=this.xCellCount/t,this.yScale=this.yCellCount/e,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(t,e,i,n,s){this._forEachCell(e,i,n,s,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(n),this.bboxes.push(s)}insertCircle(t,e,i,n){this._forEachCell(e-n,i-n,e+n,i+n,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(n)}_insertBoxCell(t,e,i,n,s,r){this.boxCells[s].push(r)}_insertCircleCell(t,e,i,n,s,r){this.circleCells[s].push(r)}_query(t,e,i,n,s,r,o){if(i<0||t>this.width||n<0||e>this.height)return[];const a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=n){if(s)return[{key:null,x1:t,y1:e,x2:i,y2:n}];for(let t=0;t<this.boxKeys.length;t++)a.push({key:this.boxKeys[t],x1:this.bboxes[4*t],y1:this.bboxes[4*t+1],x2:this.bboxes[4*t+2],y2:this.bboxes[4*t+3]});for(let t=0;t<this.circleKeys.length;t++){const e=this.circles[3*t],i=this.circles[3*t+1],n=this.circles[3*t+2];a.push({key:this.circleKeys[t],x1:e-n,y1:i-n,x2:e+n,y2:i+n})}}else this._forEachCell(t,e,i,n,this._queryCell,a,{hitTest:s,overlapMode:r,seenUids:{box:{},circle:{}}},o);return a}query(t,e,i,n){return this._query(t,e,i,n,!1,null)}hitTest(t,e,i,n,s,r){return this._query(t,e,i,n,!0,s,r).length>0}hitTestCircle(t,e,i,n,s){const r=t-i,o=t+i,a=e-i,h=e+i;if(o<0||r>this.width||h<0||a>this.height)return!1;const l=[];return this._forEachCell(r,a,o,h,this._queryCellCircle,l,{hitTest:!0,overlapMode:n,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},s),l.length>0}_queryCell(t,e,i,n,s,r,o,a){const{seenUids:h,hitTest:l,overlapMode:c}=o,u=this.boxCells[s],f=1e-6;if(null!==u){const s=this.bboxes;for(const o of u)if(!h.box[o]){h.box[o]=!0;const u=4*o,d=this.boxKeys[o];if(t<=s[u+2]+f&&e<=s[u+3]+f&&i>=s[u+0]-f&&n>=s[u+1]-f&&(!a||a(d))&&(!l||!jt(c,d.overlapMode))&&(r.push({key:d,x1:s[u],y1:s[u+1],x2:s[u+2],y2:s[u+3]}),l))return!0}}const d=this.circleCells[s];if(null!==d){const s=this.circles;for(const o of d)if(!h.circle[o]){h.circle[o]=!0;const u=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(s[u],s[u+1],s[u+2],t,e,i,n)&&(!a||a(f))&&(!l||!jt(c,f.overlapMode))){const t=s[u],e=s[u+1],i=s[u+2];if(r.push({key:f,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),l)return!0}}}return!1}_queryCellCircle(t,e,i,n,s,r,o,a){const{circle:h,seenUids:l,overlapMode:c}=o,u=this.boxCells[s];if(null!==u){const t=this.bboxes;for(const e of u)if(!l.box[e]){l.box[e]=!0;const i=4*e,n=this.boxKeys[e];if(this._circleAndRectCollide(h.x,h.y,h.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(n))&&!jt(c,n.overlapMode))return r.push(!0),!0}}const f=this.circleCells[s];if(null!==f){const t=this.circles;for(const e of f)if(!l.circle[e]){l.circle[e]=!0;const i=3*e,n=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],h.x,h.y,h.radius)&&(!a||a(n))&&!jt(c,n.overlapMode))return r.push(!0),!0}}}_forEachCell(t,e,i,n,s,r,o,a){const h=this._convertToXCellCoord(t),l=this._convertToYCellCoord(e),c=this._convertToXCellCoord(i),u=this._convertToYCellCoord(n);for(let f=h;f<=c;f++)for(let h=l;h<=u;h++)if(s.call(this,t,e,i,n,this.xCellCount*h+f,r,o,a))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,e,i,n,s,r){const o=n-t,a=s-e,h=i+r;return h*h>o*o+a*a}_circleAndRectCollide(t,e,i,n,s,r,o){const a=(r-n)/2,h=Math.abs(t-(n+a));if(h>a+i)return!1;const l=(o-s)/2,c=Math.abs(e-(s+l));if(c>l+i)return!1;if(h<=a||c<=l)return!0;const u=h-a,f=c-l;return u*u+f*f<=i*i}}function Lt(t,e){const i=1/(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),n=1/(e[8]*e[8]+e[9]*e[9]+e[10]*e[10]),s=e[0]*i,r=e[4]*i,o=e[8]*n,a=e[1]*i,h=e[5]*i,l=e[9]*n,c=e[2]*i,u=e[6]*i,f=e[10]*n;t[0]=s,t[1]=r,t[2]=o,t[4]=a,t[5]=h,t[6]=l,t[8]=c,t[9]=u,t[10]=f;const d=e[12],p=e[13],m=e[14];return t[12]=-s*d-a*p-c*m,t[13]=-r*d-h*p-u*m,t[14]=-o*d-l*p-f*m,t[3]=0,t[7]=0,t[11]=0,t[15]=1,t}const Bt=e.O();function Nt(t,i,s){const r=e.O();if(!t){const{vecSouth:t,vecEast:e}=Gt(i),s=n();s[0]=e[0],s[1]=e[1],s[2]=t[0],s[3]=t[1],o=s,(f=(h=(a=s)[0])*(u=a[3])-(c=a[2])*(l=a[1]))&&(o[0]=u*(f=1/f),o[1]=-l*f,o[2]=-c*f,o[3]=h*f),r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3]}var o,a,h,l,c,u,f;return e.S(r,r,[1/s,1/s,1]),r}function Ut(t,i,n,s){if(t){const t=e.O();if(!i){const{vecSouth:e,vecEast:i}=Gt(n);t[0]=i[0],t[1]=i[1],t[4]=e[0],t[5]=e[1]}return e.S(t,t,[s,s,1]),t}return n.pixelsToClipSpaceMatrix}function Gt(t){const i=Math.cos(t.rollInRadians),n=Math.sin(t.rollInRadians),s=Math.cos(t.pitchInRadians),r=Math.cos(t.bearingInRadians),o=Math.sin(t.bearingInRadians),a=e.az();a[0]=-r*s*n-o*i,a[1]=-o*s*n+r*i;const h=e.aA(a);h<1e-9?e.aB(a):e.aC(a,a,1/h);const l=e.az();l[0]=r*s*i-o*n,l[1]=o*s*i+r*n;const c=e.aA(l);return c<1e-9?e.aB(l):e.aC(l,l,1/c),{vecEast:l,vecSouth:a}}function Vt(t,i,n,s){let r;s?(r=[t,i,s(t,i),1],e.aE(r,r,n)):(r=[t,i,0,1],ae(r,r,n));const o=r[3];return{point:new e.P(r[0]/o,r[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}function qt(t,e){return.5+t/e*.5}function Zt(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function Wt(t,i,n,s,r,o,a,h,l,c,u,f,d){const p=n?t.textSizeData:t.iconSizeData,m=e.aw(p,i.transform.zoom),_=[256/i.width*2+1,256/i.height*2+1],g=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();const v=t.lineVertexArray,y=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=i.transform.width/i.transform.height;let b=!1;for(let n=0;n<y.length;n++){const x=y.get(n);if(x.hidden||x.writingMode===e.ax.vertical&&!b){oe(x.numGlyphs,g);continue}b=!1;const M=new e.P(x.anchorX,x.anchorY),S={getElevation:d,pitchedLabelPlaneMatrix:s,lineVertexArray:v,pitchWithMap:o,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:i.transform,tileAnchorPoint:M,unwrappedTileID:l,width:c,height:u,translation:f},z=ee(x.anchorX,x.anchorY,S);if(!Zt(z.point,_)){oe(x.numGlyphs,g);continue}const T=qt(i.transform.cameraToCenterDistance,z.signedDistanceFromCamera),E=e.ay(p,m,x),A=o?E*i.transform.getPitchedTextCorrection(x.anchorX,x.anchorY,l)/T:E*T,P=Xt({projectionContext:S,pitchedLabelPlaneMatrixInverse:r,symbol:x,fontSize:A,flip:!1,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:h});b=P.useVertical,(P.notEnoughRoom||b||P.needsFlipping&&Xt({projectionContext:S,pitchedLabelPlaneMatrixInverse:r,symbol:x,fontSize:A,flip:!0,keepUpright:a,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:h}).notEnoughRoom)&&oe(x.numGlyphs,g)}n?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function Ht(t,e,i,n,s,r,o,a){const h=r.glyphStartIndex+r.numGlyphs,l=r.lineStartIndex,c=r.lineStartIndex+r.lineLength,u=e.getoffsetX(r.glyphStartIndex),f=e.getoffsetX(h-1),d=se(t*u,i,n,s,r.segment,l,c,a,o);if(!d)return null;const p=se(t*f,i,n,s,r.segment,l,c,a,o);return p?a.projectionCache.anyProjectionOccluded?null:{first:d,last:p}:null}function Yt(t,i,n,s){return t===e.ax.horizontal&&Math.abs(n.y-i.y)>Math.abs(n.x-i.x)*s?{useVertical:!0}:(t===e.ax.vertical?i.y<n.y:i.x>n.x)?{needsFlipping:!0}:null}function Xt(t){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:s,fontSize:r,flip:o,keepUpright:a,glyphOffsetArray:h,dynamicLayoutVertexArray:l,aspectRatio:c,rotateToLine:u}=t,f=r/24,d=s.lineOffsetX*f,p=s.lineOffsetY*f;let m;if(s.numGlyphs>1){const t=s.glyphStartIndex+s.numGlyphs,e=s.lineStartIndex,r=s.lineStartIndex+s.lineLength,l=Ht(f,h,d,p,o,s,u,i);if(!l)return{notEnoughRoom:!0};const _=te(l.first.point.x,l.first.point.y,i,n),g=te(l.last.point.x,l.last.point.y,i,n);if(a&&!o){const t=Yt(s.writingMode,_,g,c);if(t)return t}m=[l.first];for(let n=s.glyphStartIndex+1;n<t-1;n++){const t=se(f*h.getoffsetX(n),d,p,o,s.segment,e,r,i,u);if(!t)return{notEnoughRoom:!0};m.push(t)}m.push(l.last)}else{if(a&&!o){const t=Qt(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,r=s.lineStartIndex+s.segment+1,o=new e.P(i.lineVertexArray.getx(r),i.lineVertexArray.gety(r)),a=Qt(o.x,o.y,i),h=a.signedDistanceFromCamera>0?a.point:Jt(i.tileAnchorPoint,o,t,1,i),l=te(t.x,t.y,i,n),u=te(h.x,h.y,i,n),f=Yt(s.writingMode,l,u,c);if(f)return f}const t=se(f*h.getoffsetX(s.glyphStartIndex),d,p,o,s.segment,s.lineStartIndex,s.lineStartIndex+s.lineLength,i,u);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[t]}for(const t of m)e.aD(l,t.point,t.angle);return{}}function Jt(t,e,i,n,s){const r=t.add(t.sub(e)._unit()),o=Qt(r.x,r.y,s).point,a=i.sub(o);return i.add(a._mult(n/a.mag()))}function Kt(t,i,n){const s=i.projectionCache;if(s.projections[t])return s.projections[t];const r=new e.P(i.lineVertexArray.getx(t),i.lineVertexArray.gety(t)),o=Qt(r.x,r.y,i);if(o.signedDistanceFromCamera>0)return s.projections[t]=o.point,s.anyProjectionOccluded||(s.anyProjectionOccluded=o.isOccluded),o.point;const a=t-n.direction;return Jt(0===n.distanceFromAnchor?i.tileAnchorPoint:new e.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),r,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function Qt(t,e,i){const n=t+i.translation[0],s=e+i.translation[1];let r;return i.pitchWithMap?(r=Vt(n,s,i.pitchedLabelPlaneMatrix,i.getElevation),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(n,s,i.unwrappedTileID,i.getElevation),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function te(t,i,n,s){if(n.pitchWithMap){const r=[t,i,0,1];return e.aE(r,r,s),n.transform.projectTileCoordinates(r[0]/r[3],r[1]/r[3],n.unwrappedTileID,n.getElevation).point}return{x:t/n.width*2-1,y:1-i/n.height*2}}function ee(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,i.getElevation)}function ie(t,e,i){return t._unit()._perp()._mult(e*i)}function ne(t,i,n,s,r,o,a,h,l){if(h.projectionCache.offsets[t])return h.projectionCache.offsets[t];const c=n.add(i);if(t+l.direction<s||t+l.direction>=r)return h.projectionCache.offsets[t]=c,c;const u=Kt(t+l.direction,h,l),f=ie(u.sub(n),a,l.direction),d=n.add(f),p=u.add(f);return h.projectionCache.offsets[t]=e.aF(o,c,d,p)||c,h.projectionCache.offsets[t]}function se(t,e,i,n,s,r,o,a,h){const l=n?t-e:t+e;let c=l>0?1:-1,u=0;n&&(c*=-1,u=Math.PI),c<0&&(u+=Math.PI);let f,d=c>0?r+s:r+s+1;a.projectionCache.cachedAnchorPoint?f=a.projectionCache.cachedAnchorPoint:(f=Qt(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=f);let p,m,_=f,g=f,v=0,y=0;const w=Math.abs(l),b=[];let x;for(;v+y<=w;){if(d+=c,d<r||d>=o)return null;v+=y,g=_,m=p;const t={absOffsetX:w,direction:c,distanceFromAnchor:v,previousVertex:g};if(_=Kt(d,a,t),0===i)b.push(g),x=_.sub(g);else{let e;const n=_.sub(g);e=0===n.mag()?ie(Kt(d+c,a,t).sub(_),i,c):ie(n,i,c),m||(m=g.add(e)),p=ne(d,e,_,r,o,m,i,a,t),b.push(m),x=p.sub(m)}y=x.mag()}const M=x._mult((w-v)/y)._add(m||g),S=u+Math.atan2(_.y-g.y,_.x-g.x);return b.push(M),{point:M,angle:h?S:0,path:b}}const re=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function oe(t,e){for(let i=0;i<t;i++){const t=e.length;e.resize(t+4),e.float32.set(re,3*t)}}function ae(t,e,i){const n=e[0],s=e[1];return t[0]=i[0]*n+i[4]*s+i[12],t[1]=i[1]*n+i[5]*s+i[13],t[3]=i[3]*n+i[7]*s+i[15],t}const he=100;class le{constructor(t,e=new Rt(t.width+200,t.height+200,25),i=new Rt(t.width+200,t.height+200,25)){this.transform=t,this.grid=e,this.ignoredGrid=i,this.pitchFactor=Math.cos(t.pitch*Math.PI/180)*t.cameraToCenterDistance,this.screenRightBoundary=t.width+he,this.screenBottomBoundary=t.height+he,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,n,s,r,o,a,h,l,c,u){const f=this.projectAndGetPerspectiveRatio(t.anchorPointX+a[0],t.anchorPointY+a[1],s,l,u),d=i*f.perspectiveRatio;let p;if(r||o)p=this._projectCollisionBox(t,d,n,s,r,o,a,f,l,c,u);else{const e=f.x+(c?c.x*d:0),i=f.y+(c?c.y*d:0);p={allPointsOccluded:!1,box:[e+t.x1*d,i+t.y1*d,e+t.x2*d,i+t.y2*d]}}const[m,_,g,v]=p.box,y=r?p.allPointsOccluded:f.isOccluded;let w=y;return w||(w=f.perspectiveRatio<this.perspectiveRatioCutoff),w||(w=!this.isInsideGrid(m,_,g,v)),w||"always"!==e&&this.grid.hitTest(m,_,g,v,e,h)?{box:[m,_,g,v],placeable:!1,offscreen:!1,occluded:y}:{box:[m,_,g,v],placeable:!0,offscreen:this.isOffscreen(m,_,g,v),occluded:y}}placeCollisionCircles(t,i,n,s,r,o,a,h,l,c,u,f,d,p){const m=[],_=new e.P(i.anchorX,i.anchorY),g=this.getPerspectiveRatio(_.x,_.y,o,p),v=(l?r*this.transform.getPitchedTextCorrection(i.anchorX,i.anchorY,o)/g:r*g)/e.aJ,y={getElevation:p,pitchedLabelPlaneMatrix:a,lineVertexArray:n,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:o,width:this.transform.width,height:this.transform.height,translation:d},w=Ht(v,s,i.lineOffsetX*v,i.lineOffsetY*v,!1,i,!1,y);let b=!1,x=!1,M=!0;if(w){const i=.5*u*g+f,n=new e.P(-100,-100),s=new e.P(this.screenRightBoundary,this.screenBottomBoundary),r=new Ot,o=w.first,a=w.last;let d=[];for(let t=o.path.length-1;t>=1;t--)d.push(o.path[t]);for(let t=1;t<a.path.length;t++)d.push(a.path[t]);const p=2.5*i;if(l){const t=this.projectPathToScreenSpace(d,y);d=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(d.length>0){const t=d[0].clone(),i=d[0].clone();for(let e=1;e<d.length;e++)t.x=Math.min(t.x,d[e].x),t.y=Math.min(t.y,d[e].y),i.x=Math.max(i.x,d[e].x),i.y=Math.max(i.y,d[e].y);_=t.x>=n.x&&i.x<=s.x&&t.y>=n.y&&i.y<=s.y?[d]:i.x<n.x||t.x>s.x||i.y<n.y||t.y>s.y?[]:e.aG([d],n.x,n.y,s.x,s.y)}for(const e of _){r.reset(e,.25*i);let n=0;n=r.length<=.5*i?1:Math.ceil(r.paddedLength/p)+1;for(let e=0;e<n;e++){const s=e/Math.max(n-1,1),o=r.lerp(s),a=o.x+he,l=o.y+he;m.push(a,l,i,0);const u=a-i,f=l-i,d=a+i,p=l+i;if(M&&(M=this.isOffscreen(u,f,d,p)),x||(x=this.isInsideGrid(u,f,d,p)),"always"!==t&&this.grid.hitTestCircle(a,l,i,t,c)&&(b=!0,!h))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!h&&b||!x||g<this.perspectiveRatioCutoff?[]:m,offscreen:M,collisionDetected:b}}projectPathToScreenSpace(t,e){const i=function(t,e){const i=Bt;return function(t,e){const i=1/(e[0]*e[5]-e[1]*e[4]);t[0]=e[5]*i,t[1]=-e[1]*i,t[2]=0,t[3]=0,t[4]=-e[4]*i,t[5]=e[0]*i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1/e[10],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1/e[15]}(i,e.pitchedLabelPlaneMatrix),t.map((t=>{const n=Vt(t.x,t.y,i,e.getElevation),s=e.transform.projectTileCoordinates(n.point.x,n.point.y,e.unwrappedTileID,e.getElevation);return s.point.x=(.5*s.point.x+.5)*e.width,s.point.y=(.5*-s.point.y+.5)*e.height,s}))}(t,e);return function(t){let e=0,i=0,n=0,s=0;for(let r=0;r<t.length;r++)t[r].isOccluded?(n=r+1,s=0):(s++,s>i&&(i=s,e=n));return t.slice(e,e+i)}(i)}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new e.a8;for(const s of t){const t=new e.P(s.x+he,s.y+he);n.extend(t),i.push(t)}const{minX:s,minY:r,maxX:o,maxY:a}=n,h=this.grid.query(s,r,o,a).concat(this.ignoredGrid.query(s,r,o,a)),l={},c={};for(const t of h){const n=t.key;if(void 0===l[n.bucketInstanceId]&&(l[n.bucketInstanceId]={}),l[n.bucketInstanceId][n.featureIndex])continue;const s=[new e.P(t.x1,t.y1),new e.P(t.x2,t.y1),new e.P(t.x2,t.y2),new e.P(t.x1,t.y2)];e.aH(i,s)&&(l[n.bucketInstanceId][n.featureIndex]=!0,void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]=[]),c[n.bucketInstanceId].push(n.featureIndex))}return c}insertCollisionBox(t,e,i,n,s,r){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:s,collisionGroupID:r,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,n,s,r){const o=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:s,collisionGroupID:r,overlapMode:e};for(let e=0;e<t.length;e+=4)o.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,i,n,s,r){if(r){let n;s?(n=[t,i,s(t,i),1],e.aE(n,n,r)):(n=[t,i,0,1],ae(n,n,r));const o=n[3];return{x:(n[0]/o+1)/2*this.transform.width+he,y:(-n[1]/o+1)/2*this.transform.height+he,perspectiveRatio:.5+this.transform.cameraToCenterDistance/o*.5,isOccluded:!1,signedDistanceFromCamera:o}}{const e=this.transform.projectTileCoordinates(t,i,n,s);return{x:(e.point.x+1)/2*this.transform.width+he,y:(1-e.point.y)/2*this.transform.height+he,perspectiveRatio:.5+this.transform.cameraToCenterDistance/e.signedDistanceFromCamera*.5,isOccluded:e.isOccluded,signedDistanceFromCamera:e.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,n){const s=this.transform.projectTileCoordinates(t,e,i,n);return.5+this.transform.cameraToCenterDistance/s.signedDistanceFromCamera*.5}isOffscreen(t,e,i,n){return i<he||t>=this.screenRightBoundary||n<he||e>this.screenBottomBoundary}isInsideGrid(t,e,i,n){return i>=0&&t<this.gridRightBoundary&&n>=0&&e<this.gridBottomBoundary}getViewportMatrix(){const t=e.ap([]);return e.Q(t,t,[-100,-100,0]),t}_projectCollisionBox(t,i,n,s,r,o,a,h,l,c,u){let f=1,d=0,p=0,m=1;const _=t.anchorPointX+a[0],g=t.anchorPointY+a[1];if(o&&!r){const t=this.projectAndGetPerspectiveRatio(_+1,g,s,l,u),e=t.x-h.x,i=Math.atan((t.y-h.y)/e)+(e<0?Math.PI:0),n=Math.sin(i),r=Math.cos(i);f=r,d=n,p=-n,m=r}else if(!o&&r){const t=Gt(this.transform);f=t.vecEast[0],d=t.vecEast[1],p=t.vecSouth[0],m=t.vecSouth[1]}let v=h.x,y=h.y,w=i;r&&(v=_,y=g,w=Math.pow(2,-(this.transform.zoom-n.overscaledZ)),w*=this.transform.getPitchedTextCorrection(_,g,s),c||(w*=e.al(.5+h.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4))),c&&(v+=f*c.x*w+p*c.y*w,y+=d*c.x*w+m*c.y*w);const b=t.x1*w,x=t.x2*w,M=(b+x)/2,S=t.y1*w,z=t.y2*w,T=(S+z)/2,E=[{offsetX:b,offsetY:S},{offsetX:M,offsetY:S},{offsetX:x,offsetY:S},{offsetX:x,offsetY:T},{offsetX:x,offsetY:z},{offsetX:M,offsetY:z},{offsetX:b,offsetY:z},{offsetX:b,offsetY:T}];let A=[];for(const{offsetX:t,offsetY:i}of E)A.push(new e.P(v+f*t+p*i,y+d*t+m*i));let P=!1;if(r){const t=A.map((t=>this.projectAndGetPerspectiveRatio(t.x,t.y,s,l,u)));P=t.some((t=>!t.isOccluded)),A=t.map((t=>new e.P(t.x,t.y)))}else P=!0;return{box:e.aI(A),allPointsOccluded:!P}}}class ce{constructor(t,e,i,n){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class ue{constructor(t,e,i,n,s){this.text=new ce(t?t.text:null,e,i,s),this.icon=new ce(t?t.icon:null,e,n,s)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class fe{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}}class de{constructor(t,e,i,n,s){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=s}}class pe{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){const e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}}function me(t,i,n,s,r){const{horizontalAlign:o,verticalAlign:a}=e.aP(t);return new e.P(-(o-.5)*i+s[0]*r,-(a-.5)*n+s[1]*r)}class _e{constructor(t,e,i,n,s){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new le(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new pe(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=s,s&&(s.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){const e=this.terrain;return e?(i,n)=>e.getElevation(t,i,n):null}getBucketParts(t,i,n,s){const r=n.getBucket(i),o=n.latestFeatureIndex;if(!r||!o||i.id!==r.layerIds[0])return;const a=n.collisionBoxArray,h=r.layers[0].layout,l=r.layers[0].paint,c=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),u=n.tileSize/e.a6,f=n.tileID.toUnwrapped(),d="map"===h.get("text-rotation-alignment"),p=e.aK(n,1,this.transform.zoom),m=e.aL(this.collisionIndex.transform,n,l.get("text-translate"),l.get("text-translate-anchor")),_=e.aL(this.collisionIndex.transform,n,l.get("icon-translate"),l.get("icon-translate-anchor")),g=Nt(d,this.transform,p);this.retainedQueryData[r.bucketInstanceId]=new de(r.bucketInstanceId,o,r.sourceLayerIndex,r.index,n.tileID);const v={bucket:r,layout:h,translationText:m,translationIcon:_,unwrappedTileID:f,pitchedLabelPlaneMatrix:g,scale:c,textPixelRatio:u,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:e.aw(r.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(r.sourceID)};if(s)for(const e of r.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:s}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:s,parameters:v})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:r.symbolInstances.length,parameters:v})}attemptAnchorPlacement(t,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v,y,w){var b,x,M;const S=e.aM[t.textAnchor],z=[t.textOffset0,t.textOffset1],T=me(S,n,s,z,r),E=this.collisionIndex.placeCollisionBox(i,f,h,l,c,a,o,_,u.predicate,y,T,w);if((!v||this.collisionIndex.placeCollisionBox(v,f,h,l,c,a,o,g,u.predicate,y,T,w).placeable)&&E.placeable){let t;if((null===(b=this.prevPlacement)||void 0===b?void 0:b.variableOffsets[d.crossTileID])&&(null===(M=null===(x=this.prevPlacement)||void 0===x?void 0:x.placements[d.crossTileID])||void 0===M?void 0:M.text)&&(t=this.prevPlacement.variableOffsets[d.crossTileID].anchor),0===d.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[d.crossTileID]={textOffset:z,width:n,height:s,anchor:S,textBoxScale:r,prevAnchor:t},this.markUsedJustification(p,S,d,m),p.allowVerticalPlacement&&(this.markUsedOrientation(p,m,d),this.placedOrientations[d.crossTileID]=m),{shift:T,placedGlyphBoxes:E}}}placeLayerBucketPart(t,i,n){const{bucket:s,layout:r,translationText:o,translationIcon:a,unwrappedTileID:h,pitchedLabelPlaneMatrix:l,textPixelRatio:c,holdingForFade:u,collisionBoxArray:f,partiallyEvaluatedTextSize:d,collisionGroup:p}=t.parameters,m=r.get("text-optional"),_=r.get("icon-optional"),g=e.aN(r,"text-overlap","text-allow-overlap"),v="always"===g,y=e.aN(r,"icon-overlap","icon-allow-overlap"),w="always"===y,b="map"===r.get("text-rotation-alignment"),x="map"===r.get("text-pitch-alignment"),M="none"!==r.get("icon-text-fit"),S="viewport-y"===r.get("symbol-z-order"),z=v&&(w||!s.hasIconData()||_),T=w&&(v||!s.hasTextData()||m);!s.collisionArrays&&f&&s.deserializeCollisionBoxes(f);const E=this.retainedQueryData[s.bucketInstanceId].tileID,A=this._getTerrainElevationFunc(E),P=this.transform.getFastPathSimpleProjectionMatrix(E),C=(t,f,w)=>{var S,C;if(i[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new fe(!1,!1,!1));let D=!1,F=!1,I=!0,k=null,$={box:null,placeable:!1,offscreen:null,occluded:!1},O={placeable:!1},j=null,R=null,L=null,B=0,N=0,U=0;f.textFeatureIndex?B=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(B=t.featureIndex),f.verticalTextFeatureIndex&&(N=f.verticalTextFeatureIndex);const G=f.textBox;if(G){const i=i=>{let n=e.ax.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,n=e,this.markUsedOrientation(s,n,t))}return n},r=(i,n)=>{if(s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const t of s.writingModes)if(t===e.ax.vertical?($=n(),O=$):$=i(),null==$?void 0:$.placeable)break}else $=i()},l=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===l){const n=(e,i)=>{const n=this.collisionIndex.placeCollisionBox(e,g,c,E,h,x,b,o,p.predicate,A,void 0,P);return(null==n?void 0:n.placeable)&&(this.markUsedOrientation(s,i,t),this.placedOrientations[t.crossTileID]=i),n};r((()=>n(G,e.ax.horizontal)),(()=>{const i=f.verticalTextBox;return s.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&i?n(i,e.ax.vertical):{box:null,offscreen:null}})),i(null==$?void 0:$.placeable)}else{let d=e.aM[null===(C=null===(S=this.prevPlacement)||void 0===S?void 0:S.variableOffsets[t.crossTileID])||void 0===C?void 0:C.anchor];const m=(e,i,r)=>{const f=e.x2-e.x1,m=e.y2-e.y1,_=t.textBoxScale,v=M&&"never"===y?i:null;let w=null,S="never"===g?1:2,z="never";d&&S++;for(let i=0;i<S;i++){for(let i=l;i<u;i++){const n=s.textAnchorOffsets.get(i);if(d&&n.textAnchor!==d)continue;const l=this.attemptAnchorPlacement(n,e,f,m,_,b,x,c,E,h,p,z,t,s,r,o,a,v,A);if(l&&(w=l.placedGlyphBoxes,null==w?void 0:w.placeable))return D=!0,k=l.shift,w}d?d=null:z=g}return n&&!w&&(w={box:this.collisionIndex.placeCollisionBox(G,"always",c,E,h,x,b,o,p.predicate,A,void 0,P).box,offscreen:!1,placeable:!1,occluded:!1}),w};r((()=>m(G,f.iconBox,e.ax.horizontal)),(()=>{const i=f.verticalTextBox;return s.allowVerticalPlacement&&!(null==$?void 0:$.placeable)&&t.numVerticalGlyphVertices>0&&i?m(i,f.verticalIconBox,e.ax.vertical):{box:null,occluded:!0,offscreen:null}})),$&&(D=$.placeable,I=$.offscreen);const _=i(null==$?void 0:$.placeable);if(!D&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(s,e.anchor,t,_))}}}if(j=$,D=null==j?void 0:j.placeable,I=null==j?void 0:j.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){const i=s.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),a=e.ay(s.textSizeData,d,i),c=r.get("text-padding");R=this.collisionIndex.placeCollisionCircles(g,i,s.lineVertexArray,s.glyphOffsetArray,a,h,l,n,x,p.predicate,t.collisionCircleDiameter,c,o,A),R.circles.length&&R.collisionDetected&&!n&&e.w("Collisions detected, but collision boxes are not shown"),D=v||R.circles.length>0&&!R.collisionDetected,I&&(I=R.offscreen)}if(f.iconFeatureIndex&&(U=f.iconFeatureIndex),f.iconBox){const t=t=>this.collisionIndex.placeCollisionBox(t,y,c,E,h,x,b,a,p.predicate,A,M&&k?k:void 0,P);O&&O.placeable&&f.verticalIconBox?(L=t(f.verticalIconBox),F=L.placeable):(L=t(f.iconBox),F=L.placeable),I&&(I=L.offscreen)}const V=m||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,q=_||0===t.numIconVertices;V||q?q?V||F&&(F=D):D=F&&D:F=D=F&&D;const Z=F&&L.placeable;if(D&&j.placeable&&this.collisionIndex.insertCollisionBox(j.box,g,r.get("text-ignore-placement"),s.bucketInstanceId,O&&O.placeable&&N?N:B,p.ID),Z&&this.collisionIndex.insertCollisionBox(L.box,y,r.get("icon-ignore-placement"),s.bucketInstanceId,U,p.ID),R&&D&&this.collisionIndex.insertCollisionCircles(R.circles,g,r.get("text-ignore-placement"),s.bucketInstanceId,B,p.ID),n&&this.storeCollisionData(s.bucketInstanceId,w,f,j,L,R),0===t.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===s.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new fe((D||z)&&!(null==j?void 0:j.occluded),(F||T)&&!(null==L?void 0:L.occluded),I||s.justReloaded),i[t.crossTileID]=!0};if(S){if(0!==t.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const e=s.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){const i=e[t];C(s.symbolInstances.get(i),s.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)C(s.symbolInstances.get(e),s.collisionArrays[e],e);s.justReloaded=!1}storeCollisionData(t,e,i,n,s,r){if(i.textBox||i.iconBox){let r,o;this.collisionBoxArrays.has(t)?r=this.collisionBoxArrays.get(t):(r=new Map,this.collisionBoxArrays.set(t,r)),r.has(e)?o=r.get(e):(o={text:null,icon:null},r.set(e,o)),i.textBox&&(o.text=n.box),i.iconBox&&(o.icon=s.box)}if(r){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<r.circles.length;t+=4)e.push(r.circles[t+0]-he),e.push(r.circles[t+1]-he),e.push(r.circles[t+2]),e.push(r.collisionDetected?1:0)}}markUsedJustification(t,i,n,s){let r;r=s===e.ax.vertical?n.verticalPlacedTextSymbolIndex:{left:n.leftJustifiedTextSymbolIndex,center:n.centerJustifiedTextSymbolIndex,right:n.rightJustifiedTextSymbolIndex}[e.aO(i)];const o=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex,n.verticalPlacedTextSymbolIndex];for(const e of o)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=r>=0&&e!==r?0:n.crossTileID)}markUsedOrientation(t,i,n){const s=i===e.ax.horizontal||i===e.ax.horizontalOnly?i:0,r=i===e.ax.vertical?i:0,o=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const e of o)t.text.placedSymbolArray.get(e).placedOrientation=s;n.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=r)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const e=this.prevPlacement;let i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;const n=e?e.symbolFadeChange(t):1,s=e?e.opacities:{},r=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(const t in this.placements){const e=this.placements[t],r=s[t];r?(this.opacities[t]=new ue(r,n,e.text,e.icon),i||(i=e.text!==r.text.placed),i||(i=e.icon!==r.icon.placed)):(this.opacities[t]=new ue(null,n,e.text,e.icon,e.skipFade),i||(i=e.text||e.icon))}for(const t in s){const e=s[t];if(!this.opacities[t]){const s=new ue(e,n,!1,!1);s.isHidden()||(this.opacities[t]=s,i||(i=e.text.placed),i||(i=e.icon.placed))}}for(const t in r)this.variableOffsets[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.variableOffsets[t]=r[t]);for(const t in o)this.placedOrientations[t]||!this.opacities[t]||this.opacities[t].isHidden()||(this.placedOrientations[t]=o[t]);if(e&&void 0===e.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=t:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=e?e.lastPlacementChangeTime:t)}updateLayerOpacities(t,e){const i={};for(const n of e){const e=n.getBucket(t);e&&n.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(t,i,n,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const r=t.layers[0],o=r.layout,a=new ue(null,0,!1,!1,!0),h=o.get("text-allow-overlap"),l=o.get("icon-allow-overlap"),c=r._unevaluatedLayout.hasValue("text-variable-anchor")||r._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===o.get("text-rotation-alignment"),f="map"===o.get("text-pitch-alignment"),d="none"!==o.get("icon-text-fit"),p=new ue(null,0,h&&(l||!t.hasIconData()||o.get("icon-optional")),l&&(h||!t.hasTextData()||o.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const m=(t,e,i)=>{for(let n=0;n<e/4;n++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices||(t.hasVisibleVertices=i!==Te)},_=this.collisionBoxArrays.get(t.bucketInstanceId);for(let i=0;i<t.symbolInstances.length;i++){const s=t.symbolInstances.get(i),{numHorizontalGlyphVertices:r,numVerticalGlyphVertices:o,crossTileID:h}=s;let l=this.opacities[h];n[h]?l=a:l||(l=p,this.opacities[h]=l),n[h]=!0;const g=s.numIconVertices>0,v=this.placedOrientations[s.crossTileID],y=v===e.ax.vertical,w=v===e.ax.horizontal||v===e.ax.horizontalOnly;if(r>0||o>0){const e=ze(l.text);m(t.text,r,y?Te:e),m(t.text,o,w?Te:e);const i=l.text.isHidden(),n=[s.rightJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.leftJustifiedTextSymbolIndex];for(const e of n)e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||y?1:0);s.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);const a=this.variableOffsets[s.crossTileID];a&&this.markUsedJustification(t,a.anchor,s,v);const h=this.placedOrientations[s.crossTileID];h&&(this.markUsedJustification(t,"left",s,h),this.markUsedOrientation(t,h,s))}if(g){const e=ze(l.icon),i=!(d&&s.verticalPlacedIconSymbolIndex&&y);s.placedIconSymbolIndex>=0&&(m(t.icon,s.numIconVertices,i?e:Te),t.icon.placedSymbolArray.get(s.placedIconSymbolIndex).hidden=l.icon.isHidden()),s.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,s.numVerticalIconVertices,i?Te:e),t.icon.placedSymbolArray.get(s.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}const b=(null==_?void 0:_.has(i))?_.get(i):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[i];if(n){let i=new e.P(0,0);if(n.textBox||n.verticalTextBox){let e=!0;if(c){const t=this.variableOffsets[h];t?(i=me(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&i._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):e=!1}if(n.textBox||n.verticalTextBox){let s;n.textBox&&(s=y),n.verticalTextBox&&(s=w),ge(t.textCollisionBox.collisionVertexArray,l.text.placed,!e||s,b.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const e=Boolean(!w&&n.verticalIconBox);let s;n.iconBox&&(s=e),n.verticalIconBox&&(s=!e),ge(t.iconCollisionBox.collisionVertexArray,l.icon.placed,s,b.icon,d?i.x:0,d?i.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);t.bucketInstanceId in this.collisionCircleArrays&&(t.collisionCircleArray=this.collisionCircleArrays[t.bucketInstanceId],delete this.collisionCircleArrays[t.bucketInstanceId])}symbolFadeChange(t){return 0===this.fadeDuration?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(t,e){const i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}}function ge(t,e,i,n,s,r){n&&0!==n.length||(n=[0,0,0,0]);const o=n[0]-he,a=n[1]-he,h=n[2]-he,l=n[3]-he;t.emplaceBack(e?1:0,i?1:0,s||0,r||0,o,a),t.emplaceBack(e?1:0,i?1:0,s||0,r||0,h,a),t.emplaceBack(e?1:0,i?1:0,s||0,r||0,h,l),t.emplaceBack(e?1:0,i?1:0,s||0,r||0,o,l)}const ve=Math.pow(2,25),ye=Math.pow(2,24),we=Math.pow(2,17),be=Math.pow(2,16),xe=Math.pow(2,9),Me=Math.pow(2,8),Se=Math.pow(2,1);function ze(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;const e=t.placed?1:0,i=Math.floor(127*t.opacity);return i*ve+e*ye+i*we+e*be+i*xe+e*Me+i*Se+e}const Te=0;class Ee{constructor(t){this._sortAcrossTiles="viewport-y"!==t.layout.get("symbol-z-order")&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,e,i,n,s){const r=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(r,n,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,s())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,r.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<r.length;)if(e.placeLayerBucketPart(r[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,s())return!0;return!1}}class Ae{constructor(t,e,i,n,s,r,o,a){this.placement=new _e(t,e,r,o,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=n,this._showCollisionBoxes=s,this._done=!1}isDone(){return this._done}continuePlacement(t,i,n){const s=l(),r=()=>!this._forceFullPlacement&&l()-s>2;for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if(e.aQ(s)&&s.layout&&(!s.minzoom||s.minzoom<=o)&&(!s.maxzoom||s.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new Ee(s)),this._inProgressLayer.continuePlacement(n[s.source],this.placement,this._showCollisionBoxes,s,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const Pe=512/e.a6/2;class Ce{constructor(t,i,n){this.tileID=t,this.bucketInstanceId=n,this._symbolsByKey={};const s=new Map;for(let t=0;t<i.length;t++){const e=i.get(t),n=e.key,r=s.get(n);r?r.push(e):s.set(n,[e])}for(const[t,i]of s){const n={positions:i.map((t=>({x:Math.floor(t.anchorX*Pe),y:Math.floor(t.anchorY*Pe)}))),crossTileIDs:i.map((t=>t.crossTileID))};if(n.positions.length>128){const t=new e.aR(n.positions.length,16,Uint16Array);for(const{x:e,y:i}of n.positions)t.add(e,i);t.finish(),delete n.positions,n.index=t}this._symbolsByKey[t]=n}}getScaledCoordinates(t,i){const{x:n,y:s,z:r}=this.tileID.canonical,{x:o,y:a,z:h}=i.canonical,l=Pe/Math.pow(2,h-r),c=(a*e.a6+t.anchorY)*l,u=s*e.a6*Pe;return{x:Math.floor((o*e.a6+t.anchorX)*l-n*e.a6*Pe),y:Math.floor(c-u)}}findMatches(t,e,i){const n=this.tileID.canonical.z<e.canonical.z?1:Math.pow(2,this.tileID.canonical.z-e.canonical.z);for(let s=0;s<t.length;s++){const r=t.get(s);if(r.crossTileID)continue;const o=this._symbolsByKey[r.key];if(!o)continue;const a=this.getScaledCoordinates(r,e);if(o.index){const t=o.index.range(a.x-n,a.y-n,a.x+n,a.y+n).sort();for(const e of t){const t=o.crossTileIDs[e];if(!i[t]){i[t]=!0,r.crossTileID=t;break}}}else if(o.positions)for(let t=0;t<o.positions.length;t++){const e=o.positions[t],s=o.crossTileIDs[t];if(Math.abs(e.x-a.x)<=n&&Math.abs(e.y-a.y)<=n&&!i[s]){i[s]=!0,r.crossTileID=s;break}}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}}class De{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Fe{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const e=Math.round((t-this.lng)/360);if(0!==e)for(const t in this.indexes){const i=this.indexes[t],n={};for(const t in i){const s=i[t];s.tileID=s.tileID.unwrapTo(s.tileID.wrap+e),n[s.tileID.key]=s}this.indexes[t]=n}this.lng=t}addBucket(t,e,i){var n,s,r;if(null===(n=this.indexes[t.overscaledZ])||void 0===n?void 0:n[t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===e.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let t=0;t<e.symbolInstances.length;t++)e.symbolInstances.get(t).crossTileID=0;(s=this.usedCrossTileIDs)[r=t.overscaledZ]||(s[r]={});const o=this.usedCrossTileIDs[t.overscaledZ];for(const i in this.indexes){const n=this.indexes[i];if(Number(i)>t.overscaledZ)for(const i in n){const s=n[i];s.tileID.isChildOf(t)&&s.findMatches(e.symbolInstances,t,o)}else{const s=n[t.scaledTo(Number(i)).key];s&&s.findMatches(e.symbolInstances,t,o)}}for(let t=0;t<e.symbolInstances.length;t++){const n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),o[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new Ce(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(const i of e.getCrossTileIDsLists())for(const e of i)delete this.usedCrossTileIDs[t][e]}removeStaleBuckets(t){let e=!1;for(const i in this.indexes){const n=this.indexes[i];for(const s in n)t[n[s].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,n[s]),delete n[s],e=!0)}return e}}class Ie{constructor(){this.layerIndexes={},this.crossTileIDs=new De,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let n=this.layerIndexes[t.id];void 0===n&&(n=this.layerIndexes[t.id]=new Fe);let s=!1;const r={};n.handleWrapJump(i);for(const i of e){const e=i.getBucket(t);t.id===(null==e?void 0:e.layerIds[0])&&(e.bucketInstanceId||(this.maxBucketInstanceId+=1,e.bucketInstanceId=this.maxBucketInstanceId),n.addBucket(i.tileID,e,this.crossTileIDs)&&(s=!0),r[e.bucketInstanceId]=!0)}return n.removeStaleBuckets(r)&&(s=!0),s}pruneUnusedLayers(t){const e={};for(const i of t)e[i]=!0;for(const t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}}var ke="void main() {fragColor=vec4(1.0);}";const $e={prelude:Oe("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Oe("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Oe("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Oe("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Oe("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Oe("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Oe(ke,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Oe("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Oe("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Oe("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Oe("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Oe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Oe("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Oe(ke,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Oe("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Oe("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Oe("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Oe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Oe("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Oe("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Oe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Oe("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Oe("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Oe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Oe("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Oe("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Oe("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Oe("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Oe("uniform sampler2D u_texture;in vec2 v_tex;in float v_total_opacity;void main() {fragColor=texture(u_texture,v_tex)*v_total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_total_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_total_opacity=opacity*max(0.0,min(visibility,fade_opacity[0]+fade_change));if (v_total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;}"),symbolSDF:Oe("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform bool u_is_plain;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float total_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out_text,color_alpha_out_halo;if (u_is_plain){highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);color_alpha_out_text=total_opacity*alpha*fill_color;}if (u_is_halo) {float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);float inner_edge_halo=inner_edge+gamma_halo*gamma_scale;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(inner_edge_halo-gamma_scaled_halo,inner_edge_halo+gamma_scaled_halo,dist);highp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha_halo= min(smoothstep(halo_edge-gamma_scaled_halo,halo_edge+gamma_scaled_halo,dist),1.0-alpha_halo);color_alpha_out_halo=total_opacity*alpha_halo*halo_color;}if (u_is_plain && u_is_halo) {fragColor=color_alpha_out_text+(1.-color_alpha_out_text.a)*color_alpha_out_halo;} else if (u_is_halo){fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out_text;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,total_opacity);}"),symbolTextAndIcon:Oe("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform bool u_is_text;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;fragColor=texture(u_texture_icon,tex_icon)*total_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;lowp float dist=texture(u_texture,tex).a;lowp vec4 color_alpha_out,color_alpha_out_halo;if (u_is_text) {highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);color_alpha_out=fill_color*(alpha*total_opacity);}if (u_is_halo) {highp float gamma_halo=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);lowp float buff_halo=(6.0-halo_width/fontScale)/SDF_PX;highp float gamma_scaled_halo=gamma_halo*gamma_scale;highp float alpha_halo=smoothstep(buff_halo-gamma_scaled_halo,buff_halo+gamma_scaled_halo,dist);color_alpha_out_halo=halo_color*(alpha_halo*total_opacity);}if (u_is_text && u_is_halo) {fragColor=color_alpha_out+(1.-color_alpha_out.a)*color_alpha_out_halo;} else if (u_is_halo) {fragColor=color_alpha_out_halo;} else {fragColor=color_alpha_out;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));float total_opacity=opacity*interpolated_fade_opacity;if (total_opacity < 0.1){gl_Position=vec4(-2.,-2.,-2.,1.);return;}highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,total_opacity,is_sdf);}"),terrain:Oe("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Oe("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Oe("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Oe("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Oe("#ifdef GL_ES\nprecision highp float;\n#endif\nin vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Oe("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Oe(t,e){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=e.match(/in ([\w]+) ([\w]+)/g),s=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=r?r.concat(s):s,a={};return{fragmentSource:t=t.replace(i,((t,e,i,n,s)=>(a[s]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nin ${i} ${n} ${s};\n#else\nuniform ${i} ${n} u_${s};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${s}\n ${i} ${n} ${s} = u_${s};\n#endif\n`))),vertexSource:e=e.replace(i,((t,e,i,n,s)=>{const r="float"===n?"vec2":"vec4",o=s.match(/color/)?"color":r;return a[s]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nin ${i} ${r} a_${s};\nout ${i} ${n} ${s};\n#else\nuniform ${i} ${n} u_${s};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = a_${s};\n#else\n ${i} ${n} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${s} = unpack_mix_${o}(a_${s}, u_${s}_t);\n#else\n ${i} ${n} ${s} = u_${s};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${s}\nuniform lowp float u_${s}_t;\nin ${i} ${r} a_${s};\n#else\nuniform ${i} ${n} u_${s};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${n} ${s} = a_${s};\n#else\n ${i} ${n} ${s} = u_${s};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${s}\n ${i} ${n} ${s} = unpack_mix_${o}(a_${s}, u_${s}_t);\n#else\n ${i} ${n} ${s} = u_${s};\n#endif\n`})),staticAttributes:n,staticUniforms:o}}class je{constructor(t,e,i){this.vertexBuffer=t,this.indexBuffer=e,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Re=e.aS([{name:"a_pos",type:"Int16",components:2}]);const Le="#define PROJECTION_MERCATOR",Be="mercator";class Ne{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Be}get shaderDefine(){return Le}get shaderPreludeCode(){return $e.projectionMercator}get vertexShaderPreludeCode(){return $e.projectionMercator.vertexSource}get subdivisionGranularity(){return e.aT.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(t){}getMeshFromTileID(t,i,n,s,r){if(this._cachedMesh)return this._cachedMesh;const o=new e.aU;o.emplaceBack(0,0),o.emplaceBack(e.a6,0),o.emplaceBack(0,e.a6),o.emplaceBack(e.a6,e.a6);const a=t.createVertexBuffer(o,Re.members),h=e.aV.simpleSegment(0,0,4,2),l=new e.aW;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);const c=t.createIndexBuffer(l);return this._cachedMesh=new je(a,c,h),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(t){}}class Ue{constructor(t=0,e=0,i=0,n=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(n)||n<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=e,this.left=i,this.right=n}interpolate(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.H.number(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.H.number(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.H.number(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.H.number(t.right,i.right,n)),this}getCenter(t,i){const n=e.al((this.left+t-this.right)/2,0,t),s=e.al((this.top+i-this.bottom)/2,0,i);return new e.P(n,s)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Ue(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ge(t,e){if(!t.renderWorldCopies||t.lngRange)return;const i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function Ve(t){return Math.max(0,Math.floor(t))}class qe{constructor(t,i){var n;this.applyConstrain=(t,e)=>null!==this._constrainOverride?this._constrainOverride(t,e):this._callbacks.defaultConstrain(t,e),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(n=null==i?void 0:i.constrainOverride)&&void 0!==n?n:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new e.W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ve(this._zoom),this._scale=e.ao(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ue,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,i,n){this._constrainOverride=t.constrainOverride,this._latRange=t.latRange,this._lngRange=t.lngRange,this._width=t.width,this._height=t.height,this._center=t.center,this._elevation=t.elevation,this._minElevationForCurrentTile=t.minElevationForCurrentTile,this._zoom=t.zoom,this._tileZoom=Ve(this._zoom),this._scale=e.ao(this._zoom),this._bearingInRadians=t.bearingInRadians,this._fovInRadians=t.fovInRadians,this._pitchInRadians=t.pitchInRadians,this._rollInRadians=t.rollInRadians,this._unmodified=t.unmodified,this._edgeInsets=new Ue(t.padding.top,t.padding.bottom,t.padding.left,t.padding.right),this._minZoom=t.minZoom,this._maxZoom=t.maxZoom,this._minPitch=t.minPitch,this._maxPitch=t.maxPitch,this._renderWorldCopies=t.renderWorldCopies,this._cameraToCenterDistance=t.cameraToCenterDistance,this._nearZ=t.nearZ,this._farZ=t.farZ,this._autoCalculateNearFarZ=!n&&t.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){this._minZoom!==t&&(this._minZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(t){this._minPitch!==t&&(this._minPitch=t,this.setPitch(Math.max(this.pitch,t)))}get maxPitch(){return this._maxPitch}setMaxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.setPitch(Math.min(this.pitch,t)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(t){void 0===t?t=!0:null===t&&(t=!1),this._renderWorldCopies=t}get constrainOverride(){return this._constrainOverride}setConstrainOverride(t){void 0===t&&(t=null),this._constrainOverride!==t&&(this._constrainOverride=t,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){const i=e.X(t,-180,180)*Math.PI/180;var s,r,o,a,h,l,c,u,f;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),s=this._rotationMatrix,o=-this._bearingInRadians,a=(r=this._rotationMatrix)[0],h=r[1],l=r[2],c=r[3],u=Math.sin(o),f=Math.cos(o),s[0]=a*f+l*u,s[1]=h*f+c*u,s[2]=a*-u+l*f,s[3]=h*-u+c*f)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){const i=e.al(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){const e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return e.aX(this._fovInRadians)}setFov(t){t=e.al(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=e.an(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){const i=this.applyConstrain(this._center,t).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=e.ao(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(t){t!==this._elevation&&(this._elevation=t,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(t,e){this._autoCalculateNearFarZ=!1,this._nearZ=t,this._farZ=e,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,e,i){this._unmodified=!1,this._edgeInsets.interpolate(t,e,i),this.constrainInternal(),this._calcMatrices()}resize(t,e,i=!0){this._width=t,this._height=e,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){var t,e;return 2!==(null===(t=this._latRange)||void 0===t?void 0:t.length)||2!==(null===(e=this._lngRange)||void 0===e?void 0:e.length)?null:new G([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]])}setMaxBounds(t){t?(this._lngRange=[t.getWest(),t.getEast()],this._latRange=[t.getSouth(),t.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-e.am,e.am])}getCameraQueryGeometry(t,i){if(1===i.length)return[i[0],t];{const{minX:n,minY:s,maxX:r,maxY:o}=e.a8.fromPoints(i).extend(t);return[new e.P(n,s),new e.P(r,s),new e.P(r,o),new e.P(n,o),new e.P(n,s)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:e,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(e),this.setZoom(i),this._unmodified=t,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=e.ap(new Float64Array(16));e.S(t,t,[this._width/2,-this._height/2,1]),e.Q(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=e.ap(new Float64Array(16)),e.S(t,t,[1,-1,1]),e.Q(t,t,[-1,-1,0]),e.S(t,t,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=t,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(t,i,n,s){const r=void 0!==n?n:this.bearing,o=s=void 0!==s?s:this.pitch,{distanceToCenter:a,clampedElevation:h}=this._distanceToCenterFromAltElevationPitch(i,this.elevation,o),{x:l,y:c}=wt(o,r),u=e.a7.fromLngLat(t,i);let f,d,p=e.aY(1,u.y),m=0;do{if(m+=1,m>10)break;d=a/p,f=new e.a7(u.x+l*d,u.y+c*d),p=1/f.meterInMercatorCoordinateUnits()}while(Math.abs(a-d*p)>1e-12);return{center:f.toLngLat(),elevation:h,zoom:e.ar(this.height/2/Math.tan(this.fovInRadians/2)/d/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;const i=1/this.worldSize,n=e.aq(1,this.center.lat)*this.worldSize,s=e.a7.fromLngLat(this.center,this.elevation),r=s.x/i,o=s.y/i,a=s.z/i,h=this.pitch,l=this.bearing,{x:c,y:u,z:f}=wt(h,l),d=this.cameraToCenterDistance,p=r+d*-c,m=o+d*-u,_=a+d*f,{distanceToCenter:g,clampedElevation:v}=this._distanceToCenterFromAltElevationPitch(_/n,t,h),y=g*n,w=new e.a7((p+c*y)*i,(m+u*y)*i,0).toLngLat(),b=e.aq(1,w.lat),x=e.ar(this.height/2/Math.tan(this.fovInRadians/2)/g/b/this.tileSize);this._elevation=v,this._center=w,this.setZoom(x)}_distanceToCenterFromAltElevationPitch(t,i,n){const s=-Math.cos(e.an(n)),r=t-i;let o,a=i;return s*r>=0||Math.abs(s)<.1?(o=1e4,a=t+o*s):o=-r/s,{distanceToCenter:o,clampedElevation:a}}getCameraPoint(){const t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const t=e.aq(1,this.center.lat)*this.worldSize;return yt(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/t).toLngLat()}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];const i=t.canonical.z>=0?1<<t.canonical.z:Math.pow(2,t.canonical.z);return[t.canonical.x/i,t.canonical.y/i,1/i/e.a6,1/i/e.a6]}}class Ze{constructor(t,i){this.min=t,this.max=i,this.center=e.aZ([],e.a_([],this.min,this.max),.5)}quadrant(t){const i=[t%2==0,t<2],n=e.a$(this.min),s=e.a$(this.max);for(let t=0;t<i.length;t++)n[t]=i[t]?this.min[t]:this.center[t],s[t]=i[t]?this.center[t]:this.max[t];return s[2]=this.max[2],new Ze(n,s)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersectsFrustum(t){let e=!0;for(const i of t.planes){const t=this.intersectsPlane(i);if(0===t)return 0;1===t&&(e=!1)}return e?2:t.aabb.min[0]>this.max[0]||t.aabb.min[1]>this.max[1]||t.aabb.min[2]>this.max[2]||t.aabb.max[0]<this.min[0]||t.aabb.max[1]<this.min[1]||t.aabb.max[2]<this.min[2]?0:1}intersectsPlane(t){let e=t[3],i=t[3];for(let n=0;n<3;n++)t[n]>0?(e+=t[n]*this.min[n],i+=t[n]*this.max[n]):(i+=t[n]*this.min[n],e+=t[n]*this.max[n]);return e>=0?2:i<0?0:1}}class We{distanceToTile2d(t,e,i,n){const s=n,r=s.distanceX([t,e]),o=s.distanceY([t,e]);return Math.hypot(r,o)}getWrap(t,e,i){return i}getTileBoundingVolume(t,i,n,s){var r,o;let a=0,h=0;if(null==s?void 0:s.terrain){const l=new e.a3(t.z,i,t.z,t.x,t.y),c=s.terrain.getMinMaxElevation(l);a=null!==(r=c.minElevation)&&void 0!==r?r:Math.min(0,n),h=null!==(o=c.maxElevation)&&void 0!==o?o:Math.max(0,n)}const l=1<<t.z;return new Ze([i+t.x/l,t.y/l,a],[i+(t.x+1)/l,(t.y+1)/l,h])}allowVariableZoom(t,i){const n=t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height,s=e.al(78.5-n/2,0,60);return!!i.terrain||t.pitch>s}allowWorldCopies(){return!0}prepareNextFrame(){}}class He{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(t,i=1,n=0,s,r){const o=r?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),h=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map((n=>function(t,i,n,s){const r=e.aE([],t,i),o=1/r[3]/n*s;return e.b4(r,r,[o,o,1/r[3],o])}(n,t,i,a)));s&&function(t,i,n,s){const r=s?4:0,o=s?0:4;let a=0;const h=[],l=[];for(let i=0;i<4;i++){const n=e.b0([],t[i+o],t[i+r]),s=e.b5(n);e.aZ(n,n,1/s),h.push(s),l.push(n)}for(let i=0;i<4;i++){const s=e.b6(t[i+r],l[i],n);a=null!==s&&s>=0?Math.max(a,s):Math.max(a,h[i])}const c=function(t,i){const n=e.b0([],t[i[0]],t[i[1]]),s=e.b0([],t[i[2]],t[i[1]]),r=[0,0,0,0];return e.b1(r,e.b2([],n,s)),r[3]=-e.b3(r,t[i[0]]),r}(t,i),u=function(t,i){const n=e.b7(t),s=e.b8([],t,1/n),r=e.b0([],i,e.aZ([],s,e.b3(i,s))),o=e.b7(r);if(o>0){const t=Math.sqrt(1-s[3]*s[3]),n=e.aZ([],s,-s[3]),a=e.a_([],n,e.aZ([],r,t/o));return e.b9(i,a)}return null}(n,c);if(null!==u){const t=u/e.b3(l[0],c);a=Math.min(a,t)}for(let e=0;e<4;e++){const i=Math.min(a,h[e]);t[e+o]=[t[e+r][0]+l[e][0]*i,t[e+r][1]+l[e][1]*i,t[e+r][2]+l[e][2]*i,1]}}(h,o[0],s,r);const l=o.map((t=>{const i=e.b0([],h[t[0]],h[t[1]]),n=e.b0([],h[t[2]],h[t[1]]),s=e.b1([],e.b2([],i,n)),r=-e.b3(s,h[t[1]]);return s.concat(r)})),c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],u=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const t of h)for(let e=0;e<3;e++)c[e]=Math.min(c[e],t[e]),u[e]=Math.max(u[e],t[e]);return new He(h,l,new Ze(c,u))}}class Ye{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t,e){}constructor(t){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,i)=>{i=e.al(+i,this.minZoom,this.maxZoom);const n={center:new e.W(t.lng,t.lat),zoom:i};let s=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===s){const t=180-1e-10;s=[-t,t]}const r=this.tileSize*e.ao(n.zoom);let o=0,a=r,h=0,l=r,c=0,u=0;const{x:f,y:d}=this.size;if(this._helper._latRange){const t=this._helper._latRange;o=e.Y(t[1])*r,a=e.Y(t[0])*r,a-o<d&&(c=d/(a-o))}s&&(h=e.X(e.Z(s[0])*r,0,r),l=e.X(e.Z(s[1])*r,0,r),l<h&&(l+=r),l-h<f&&(u=f/(l-h)));const{x:p,y:m}=mt(r,t);let _,g;const v=Math.max(u||0,c||0);if(v){const t=new e.P(u?(l+h)/2:p,c?(a+o)/2:m);return n.center=_t(r,t).wrap(),n.zoom+=e.ar(v),n}if(this._helper._latRange){const t=d/2;m-t<o&&(g=o+t),m+t>a&&(g=a-t)}if(s){const t=(h+l)/2;let i=p;this._helper._renderWorldCopies&&(i=e.X(p,t-r/2,t+r/2));const n=f/2;i-n<h&&(_=h+n),i+n>l&&(_=l-n)}if(void 0!==_||void 0!==g){const t=new e.P(null!=_?_:p,null!=g?g:m);n.center=_t(r,t).wrap()}return n},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new qe({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new We}clone(){const t=new Ye;return t.apply(this,!1),t}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){const i=[new e.ba(0,t)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new e.P(0,0)),s=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,0)),r=this.screenPointToMercatorCoordinate(new e.P(this._helper._width,this._helper._height)),o=this.screenPointToMercatorCoordinate(new e.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,s.x,r.x,o.x)),h=Math.floor(Math.max(n.x,s.x,r.x,o.x)),l=1;for(let n=a-l;n<=h+l;n++)0!==n&&i.push(new e.ba(n,t))}return i}getCameraFrustum(){return He.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){const e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLatZoom(e,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,i){const n=e.aq(this.elevation,this.center.lat),s=this.screenPointToMercatorCoordinateAtZ(i,n),r=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),o=e.a7.fromLngLat(t),a=new e.a7(o.x-(s.x-r.x),o.y-(s.y-r.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,i){return i?this.coordinatePoint(e.a7.fromLngLat(t),i.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(e.a7.fromLngLat(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){const i=e.pointCoordinate(t);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}screenPointToMercatorCoordinateAtZ(t,i){const n=i||0,s=[t.x,t.y,0,1],r=[t.x,t.y,1,1];e.aE(s,s,this._pixelMatrixInverse),e.aE(r,r,this._pixelMatrixInverse);const o=s[3],a=r[3],h=s[1]/o,l=r[1]/a,c=s[2]/o,u=r[2]/a,f=c===u?0:(n-c)/(u-c);return new e.a7(e.H.number(s[0]/o,r[0]/a,f)/this.worldSize,e.H.number(h,l,f)/this.worldSize,n)}coordinatePoint(t,i=0,n=this._pixelMatrix){const s=[t.x*this.worldSize,t.y*this.worldSize,i,1];return e.aE(s,s,n),new e.P(s[0]/s[3],s[1]/s[3])}getBounds(){const t=Math.max(0,this._helper._height/2-gt(this));return(new G).extend(this.screenPointToLocation(new e.P(0,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,t))).extend(this.screenPointToLocation(new e.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new e.P(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=e.pointCoordinate(t):t.y>this.height/2-gt(this)}calculatePosMatrix(t,i=!1,n){var s;const r=null!==(s=t.key)&&void 0!==s?s:e.bb(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),o=i?this._alignedPosMatrixCache:this._posMatrixCache;if(o.has(r)){const t=o.get(r);return n?t.f32:t.f64}const a=vt(t,this.worldSize);e.U(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const h={f64:a,f32:new Float32Array(a)};return o.set(r,h),n?h.f32:h.f64}calculateFogMatrix(t){const i=t.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const s=vt(t,this.worldSize);return e.U(s,this._fogMatrix,s),n.set(i,new Float32Array(s)),n.get(i)}calculateCenterFromCameraLngLatAlt(t,e,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,n)}_calculateNearFarZIfNeeded(t,i,n){if(!this._helper.autoCalculateNearFarZ)return;const s=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),r=t-s*this._helper._pixelPerMeter/Math.cos(i),o=s<0?r:t,a=Math.PI/2+this.pitchInRadians,h=e.an(this.fov)*(Math.abs(Math.cos(e.an(this.roll)))*this.height+Math.abs(Math.sin(e.an(this.roll)))*this.width)/this.height*(.5+n.y/this.height),l=Math.sin(h)*o/Math.sin(e.al(Math.PI-a-h,.01,Math.PI-.01)),c=gt(this),u=Math.atan(c/this._helper.cameraToCenterDistance),f=e.an(.75),d=u>f?2*u*(.5+n.y/(2*c)):f,p=Math.sin(d)*o/Math.sin(e.al(Math.PI-a-d,.01,Math.PI-.01)),m=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+o),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const t=this.centerOffset,i=mt(this.worldSize,this.center),n=i.x,s=i.y;this._helper._pixelPerMeter=e.aq(1,this.center.lat)*this.worldSize;const r=e.an(Math.min(this.pitch,pt)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(r));let a;var h,l;this._calculateNearFarZIfNeeded(o,r,t),a=new Float64Array(16),e.bc(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),(h=this._invProjMatrix)[0]=1/(l=a)[0],h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=1/l[5],h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=0,h[11]=1/l[14],h[12]=0,h[13]=0,h[14]=-1,h[15]=l[10]/l[14],a[8]=2*-t.x/this._helper._width,a[9]=2*t.y/this._helper._height,this._projectionMatrix=e.bd(a),e.S(a,a,[1,-1,1]),e.Q(a,a,[0,0,-this._helper.cameraToCenterDistance]),e.be(a,a,-this.rollInRadians),e.bf(a,a,this.pitchInRadians),e.be(a,a,-this.bearingInRadians),e.Q(a,a,[-n,-s,0]),this._mercatorMatrix=e.S([],a,[this.worldSize,this.worldSize,this.worldSize]),e.S(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=e.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),e.Q(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=e.bg([],a);const c=[0,0,-1,1];e.aE(c,c,this._invViewProjMatrix),this._cameraPosition=[c[0]/c[3],c[1]/c[3],c[2]/c[3]],this._fogMatrix=new Float64Array(16),e.bc(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-t.x/this.width,this._fogMatrix[9]=2*t.y/this.height,e.S(this._fogMatrix,this._fogMatrix,[1,-1,1]),e.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),e.be(this._fogMatrix,this._fogMatrix,-this.rollInRadians),e.bf(this._fogMatrix,this._fogMatrix,this.pitchInRadians),e.be(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),e.Q(this._fogMatrix,this._fogMatrix,[-n,-s,0]),e.S(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),e.Q(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=e.U(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const u=this._helper._width%2/2,f=this._helper._height%2/2,d=Math.cos(this.bearingInRadians),p=Math.sin(-this.bearingInRadians),m=n-Math.round(n)+d*u+p*f,_=s-Math.round(s)+d*f+p*u,g=new Float64Array(a);if(e.Q(g,g,[m>.5?m-1:m,_>.5?_-1:_,0]),this._alignedProjMatrix=g,a=e.bg(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const t=this.screenPointToMercatorCoordinate(new e.P(0,0)),i=[t.x*this.worldSize,t.y*this.worldSize,0,1];return e.aE(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const t=e.aq(1,this.center.lat)*this.worldSize;return yt(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,i){const n=e.a7.fromLngLat(t),s=[n.x*this.worldSize,n.y*this.worldSize,i,1];return e.aE(s,s,this._viewProjMatrix),s[2]/s[3]}getProjectionData(t){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:s}=t,r=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=(null==i?void 0:i.terrainRttPosMatrix32f)&&s?i.terrainRttPosMatrix32f:o||e.bh(),{mainMatrix:a,tileMercatorCoords:r,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return e.a$(t)}getRayDirectionFromPixel(t){throw new Error("Not implemented.")}projectTileCoordinates(t,i,n,s){const r=this.calculatePosMatrix(n);let o;s?(o=[t,i,s(t,i),1],e.aE(o,o,r)):(o=[t,i,0,1],ae(o,o,r));const a=o[3];return{point:new e.P(o[0]/a,o[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(t){for(const e of t)this.calculatePosMatrix(e)}getMatrixForModel(t,i){const n=e.a7.fromLngLat(t,i),s=n.meterInMercatorCoordinateUnits(),r=e.bi();return e.Q(r,r,[n.x,n.y,n.z]),e.be(r,r,Math.PI),e.bf(r,r,Math.PI/2),e.S(r,r,[-s,s,s]),r}getProjectionDataForCustomLayer(t=!0){const i=new e.a3(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:t}),s=vt(i,this.worldSize);e.U(s,this._viewProjMatrix,s),n.tileMercatorCoords=[0,0,1,1];const r=[e.a6,e.a6,this.worldSize/this._helper.pixelsPerMeter],o=e.bj();return e.S(o,s,r),n.fallbackMatrix=o,n.mainMatrix=o,n}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}}function Xe(){e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Je(t){if(t.useSlerp)if(t.k<1){const i=e.bk(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),n=e.bk(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),s=new Float64Array(4);e.bl(s,i,n,t.k);const r=e.bm(s);t.tr.setRoll(r.roll),t.tr.setPitch(r.pitch),t.tr.setBearing(r.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(e.H.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(e.H.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(e.H.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Ke(t,i,n,s,r){const o=r.padding,a=mt(r.worldSize,n.getNorthWest()),h=mt(r.worldSize,n.getNorthEast()),l=mt(r.worldSize,n.getSouthEast()),c=mt(r.worldSize,n.getSouthWest()),u=e.an(-s),f=a.rotate(u),d=h.rotate(u),p=l.rotate(u),m=c.rotate(u),_=new e.P(Math.max(f.x,d.x,m.x,p.x),Math.max(f.y,d.y,m.y,p.y)),g=new e.P(Math.min(f.x,d.x,m.x,p.x),Math.min(f.y,d.y,m.y,p.y)),v=_.sub(g),y=(r.width-(o.left+o.right+i.left+i.right))/v.x,w=(r.height-(o.top+o.bottom+i.top+i.bottom))/v.y;if(w<0||y<0)return void Xe();const b=Math.min(e.ar(r.scale*Math.min(y,w)),t.maxZoom),x=e.P.convert(t.offset),M=new e.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(e.an(s)),S=x.add(M).mult(r.scale/e.ao(b));return{center:_t(r.worldSize,a.add(l).div(2).sub(S)),zoom:b,bearing:s}}class Qe{get useGlobeControls(){return!1}handlePanInertia(t,e){const i=t.mag(),n=Math.abs(gt(e));return{easingOffset:t.mult(Math.min(.75*n/i,1)),easingCenter:e.center}}handleMapControlsRollPitchBearingZoom(t,e){t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta),t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta)}handleMapControlsPan(t,e,i){t.around.distSqr(e.centerPoint)<.01||e.setLocationAtPoint(i,t.around)}cameraForBoxAndBearing(t,e,i,n,s){return Ke(t,e,i,n,s)}handleJumpToCenterZoom(t,i){t.zoom!==(void 0!==i.zoom?+i.zoom:t.zoom)&&t.setZoom(+i.zoom),void 0!==i.center&&t.setCenter(e.W.convert(i.center))}handleEaseTo(t,i){const n=t.zoom,s=t.padding,r={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},a=void 0!==i.zoom,h=!t.isPaddingEqual(i.padding);let l=!1;const c=a?+i.zoom:t.zoom;let u=t.centerPoint.add(i.offsetAsPoint);const f=t.screenPointToLocation(u),{center:d,zoom:p}=t.applyConstrain(e.W.convert(i.center||f),null!=c?c:n);Ge(t,d);const m=mt(t.worldSize,f),_=mt(t.worldSize,d).sub(m),g=e.ao(p-n);return l=p!==n,{easeFunc:a=>{if(l&&t.setZoom(e.H.number(n,p,a)),e.bn(r,o)||Je({startEulerAngles:r,endEulerAngles:o,tr:t,k:a,useSlerp:r.roll!=o.roll}),h&&(t.interpolatePadding(s,i.padding,a),u=t.centerPoint.add(i.offsetAsPoint)),i.around)t.setLocationAtPoint(i.around,i.aroundPoint);else{const i=e.ao(t.zoom-n),s=p>n?Math.min(2,g):Math.max(.5,g),r=Math.pow(s,1-a),o=_t(t.worldSize,m.add(_.mult(a*r)).mult(i));t.setLocationAtPoint(t.renderWorldCopies?o.wrap():o,u)}},isZooming:l,elevationCenter:d}}handleFlyTo(t,i){const n=void 0!==i.zoom,s=t.zoom,r=t.applyConstrain(e.W.convert(i.center||i.locationAtOffset),n?+i.zoom:s),o=r.center,a=r.zoom;Ge(t,o);const h=mt(t.worldSize,i.locationAtOffset),l=mt(t.worldSize,o).sub(h),c=l.mag(),u=e.ao(a-s);let f;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,s,a),r=t.applyConstrain(o,n).zoom;f=e.ao(r-s)}return{easeFunc:(i,n,r,c)=>{t.setZoom(1===i?a:s+e.ar(n));const u=1===i?o:_t(t.worldSize,h.add(l.mult(r)).mult(n));t.setLocationAtPoint(t.renderWorldCopies?u.wrap():u,c)},scaleOfZoom:u,targetCenter:o,scaleOfMinZoom:f,pixelPathLength:c}}}class ti{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}}ti.Replace=[1,0],ti.disabled=new ti(ti.Replace,e.bo.transparent,[!1,!1,!1,!1]),ti.unblended=new ti(ti.Replace,e.bo.transparent,[!0,!0,!0,!0]),ti.alphaBlended=new ti([1,771],e.bo.transparent,[!0,!0,!0,!0]);const ei=2305;class ii{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}}ii.disabled=new ii(!1,1029,ei),ii.backCCW=new ii(!0,1029,ei),ii.frontCCW=new ii(!0,1028,ei);class ni{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}}ni.ReadOnly=!1,ni.ReadWrite=!0,ni.disabled=new ni(519,ni.ReadOnly,[0,1]);const si=7680;class ri{constructor(t,e,i,n,s,r){this.test=t,this.ref=e,this.mask=i,this.fail=n,this.depthFail=s,this.pass=r}}function oi(t){return"undefined"!=typeof WebGL2RenderingContext&&t instanceof WebGL2RenderingContext}ri.disabled=new ri({func:519,mask:0},0,0,si,si,si);class ai{get awaitingQuery(){return!!this._readbackQueue}constructor(t){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=t;const i=t.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const s=new e.aU;s.emplaceBack(-1,-1),s.emplaceBack(2,-1),s.emplaceBack(-1,2);const r=new e.aW;r.emplaceBack(0,1,2),this._fullscreenTriangle=new je(i.createVertexBuffer(s,Re.members),i.createIndexBuffer(r),e.aV.simpleSegment(0,0,s.length,r.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const o=n.createTexture();n.bindTexture(n.TEXTURE_2D,o),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(o),oi(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const t=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),t.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(t,e){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(t,e),this._updateCount++,this._measuredError}_bindFramebuffer(){const t=this._cachedRenderContext.context,e=t.gl;t.activeTexture.set(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,this._fbo.colorAttachment.get()),t.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(t,i){const n=this._cachedRenderContext.context,s=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:e.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,s.TRIANGLES,ni.disabled,ri.disabled,ti.unblended,ii.disabled,((t,e)=>({u_input:t,u_output_expected:e}))(t,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&oi(s)){s.bindBuffer(s.PIXEL_PACK_BUFFER,this._pbo),s.readBuffer(s.COLOR_ATTACHMENT0),s.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null);const t=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);s.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:t}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const t=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&oi(t)){const i=t.clientWaitSync(this._readbackQueue.sync,0,0);if(i===t.WAIT_FAILED)return e.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===t.TIMEOUT_EXPIRED)return;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pbo),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),t.bindBuffer(t.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),t.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ai._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(t){let e=0;return e+=t[0]/256,e+=t[1]/65536,e+=t[2]/16777216,t[3]<127&&(e=-e),e/128}}const hi=e.a6/128;function li(t,i){const n=void 0!==t.granularity?Math.max(t.granularity,1):1,s=n+(t.generateBorders?2:0),r=n+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),o=s+1,a=r+1,h=t.generateBorders?-1:0,l=t.generateBorders||t.extendToNorthPole?-1:0,c=n+(t.generateBorders?1:0),u=n+(t.generateBorders||t.extendToSouthPole?1:0),f=o*a,d=s*r*6,p=o*a>65536;if(p&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=p||"32bit"===i,_=new Int16Array(2*f);let g=0;for(let i=l;i<=u;i++)for(let s=h;s<=c;s++){let r=s/n*e.a6;-1===s&&(r=-hi),s===n+1&&(r=e.a6+hi);let o=i/n*e.a6;-1===i&&(o=t.extendToNorthPole?e.bq:-hi),i===n+1&&(o=t.extendToSouthPole?e.br:e.a6+hi),_[g++]=r,_[g++]=o}const v=m?new Uint32Array(d):new Uint16Array(d);let y=0;for(let t=0;t<r;t++)for(let e=0;e<s;e++){const i=e+1+t*o,n=e+(t+1)*o,s=e+1+(t+1)*o;v[y++]=e+t*o,v[y++]=n,v[y++]=i,v[y++]=i,v[y++]=n,v[y++]=s}return{vertices:_.buffer.slice(0),indices:v.buffer.slice(0),uses32bitIndices:m}}const ci=new e.aT({fill:new e.bs(128,2),line:new e.bs(512,0),tile:new e.bs(128,32),stencil:new e.bs(128,1),circle:3});class ui{constructor(){this._tileMeshCache={},this._errorCorrectionUsable=0,this._errorMeasurementLastValue=0,this._errorCorrectionPreviousValue=0,this._errorMeasurementLastChangeTime=-1e3}get name(){return"vertical-perspective"}get transitionState(){return 1}get useSubdivision(){return!0}get shaderVariantName(){return"globe"}get shaderDefine(){return"#define GLOBE"}get shaderPreludeCode(){return $e.projectionGlobe}get vertexShaderPreludeCode(){return $e.projectionMercator.vertexSource}get subdivisionGranularity(){return ci}get useGlobeControls(){return!0}get latitudeErrorCorrectionRadians(){return this._errorCorrectionUsable}destroy(){this._errorMeasurement&&this._errorMeasurement.destroy()}updateGPUdependent(t){this._errorMeasurement||(this._errorMeasurement=new ai(t));const i=e.Y(this._errorQueryLatitudeDegrees),n=2*Math.atan(Math.exp(Math.PI-i*Math.PI*2))-.5*Math.PI,s=this._errorMeasurement.updateErrorLoop(i,n),r=l();s!==this._errorMeasurementLastValue&&(this._errorCorrectionPreviousValue=this._errorCorrectionUsable,this._errorMeasurementLastValue=s,this._errorMeasurementLastChangeTime=r);const o=Math.min(Math.max((r-this._errorMeasurementLastChangeTime)/1e3/.5,0),1);this._errorCorrectionUsable=e.bt(this._errorCorrectionPreviousValue,-this._errorMeasurementLastValue,e.bu(o))}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,n,s){const r=("stencil"===s?ci.stencil:ci.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:r,generateBorders:i,extendToNorthPole:0===e.y&&n,extendToSouthPole:e.y===(1<<e.z)-1&&n})}_getMesh(t,i){const n=this._getMeshKey(i);if(n in this._tileMeshCache)return this._tileMeshCache[n];const s=function(t,i){const n=li(i,"16bit"),s=e.aU.deserialize({arrayBuffer:n.vertices,length:n.vertices.byteLength/2/2}),r=e.aW.deserialize({arrayBuffer:n.indices,length:n.indices.byteLength/2/3});return new je(t.createVertexBuffer(s,Re.members),t.createIndexBuffer(r),e.aV.simpleSegment(0,0,s.length,r.length))}(t,i);return this._tileMeshCache[n]=s,s}recalculate(t){}hasTransition(){var t;const e=l();let i=!1;return i||(i=(e-this._errorMeasurementLastChangeTime)/1e3<.7),i||(i=null===(t=this._errorMeasurement)||void 0===t?void 0:t.awaitingQuery),i}setErrorQueryLatitudeDegrees(t){this._errorQueryLatitudeDegrees=t}}const fi=new e.u({type:new e.D(e.x.projection.type)});class di extends e.E{constructor(t){super(),this._transitionable=new e.y(fi,void 0),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new e.J(0)),this._mercatorProjection=new Ne,this._verticalPerspectiveProjection=new ui}get transitionState(){const t=this.properties.get("type");if("string"==typeof t&&"mercator"===t)return 0;if("string"==typeof t&&"vertical-perspective"===t)return 1;if(t instanceof e.bv){if("vertical-perspective"===t.from&&"mercator"===t.to)return 1-t.transition;if("mercator"===t.from&&"vertical-perspective"===t.to)return t.transition}return 1}get useGlobeRendering(){return this.transitionState>0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(t){this._mercatorProjection.updateGPUdependent(t),this._verticalPerspectiveProjection.updateGPUdependent(t)}getMeshFromTileID(t,e,i,n,s){return this.currentProjection.getMeshFromTileID(t,e,i,n,s)}setProjection(t){this._transitionable.setValue("type",(null==t?void 0:t.type)||"mercator")}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}setErrorQueryLatitudeDegrees(t){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(t),this._mercatorProjection.setErrorQueryLatitudeDegrees(t)}}function pi(t){const e=gi(t.worldSize,t.center.lat);return 2*Math.PI*e}function mi(t,i,n,s,r){const o=1/(1<<r),a=i/e.a6*o+s*o,h=e.by((t/e.a6*o+n*o)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-a*Math.PI*2))-.5*Math.PI,c=Math.cos(l),u=new Float64Array(3);return u[0]=Math.sin(h)*c,u[1]=Math.sin(l),u[2]=Math.cos(h)*c,u}function _i(t){return function(t,e){const i=Math.cos(e),n=new Float64Array(3);return n[0]=Math.sin(t)*i,n[1]=Math.sin(e),n[2]=Math.cos(t)*i,n}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function gi(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function vi(t){const i=Math.asin(t[1])/Math.PI*180,n=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(n>1e-6){const s=t[0]/n,r=Math.acos(t[2]/n),o=(s>0?r:-r)/Math.PI*180;return new e.W(e.X(o,-180,180),i)}return new e.W(0,i)}function yi(t){return Math.cos(t*Math.PI/180)}function wi(t,i){const n=yi(t),s=yi(i);return e.ar(s/n)}function bi(t,i){const n=t.rotate(i.bearingInRadians),s=i.zoom+wi(i.center.lat,0),r=e.bt(1/yi(i.center.lat),1/yi(Math.min(Math.abs(i.center.lat),60)),e.bw(s,7,3,0,1)),o=360/pi({worldSize:i.worldSize,center:{lat:i.center.lat}});return new e.W(i.center.lng-n.x*o*r,e.al(i.center.lat+n.y*o,-e.am,e.am))}function xi(t){const e=.5*t,i=Math.sin(e),n=Math.cos(e);return Math.log(i+n)-Math.log(n-i)}function Mi(t,i,n,s){const r=t.lat+n*s;if(Math.abs(n)>1){const o=(Math.sign(t.lat+n)!==Math.sign(t.lat)?-Math.abs(t.lat):Math.abs(t.lat))*Math.PI/180,a=Math.abs(t.lat+n)*Math.PI/180,h=xi(o+s*(a-o)),l=xi(o),c=xi(a);return new e.W(t.lng+i*((h-l)/(c-l)),r)}return new e.W(t.lng+i*s,r)}class Si{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;const t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,e,i,n){const s=`${t.z}_${t.x}_${t.y}_${(null==n?void 0:n.terrain)?"t":""}`,r=this._cache.get(s);if(r)return r;const o=this._cachePrevious.get(s);if(o)return this._cache.set(s,o),o;const a=this._boundingVolumeFactory(t,e,i,n);return this._cache.set(s,a),this._hadAnyChanges=!0,a}}class zi{constructor(t,e,i,n){this.min=i,this.max=n,this.points=t,this.planes=e}static fromAabb(t,e){const i=[];for(let n=0;n<8;n++)i.push([1&~n?t[0]:e[0],1==(n>>1&1)?e[1]:t[1],1==(n>>2&1)?e[2]:t[2]]);return new zi(i,[[-1,0,0,e[0]],[1,0,0,-t[0]],[0,-1,0,e[1]],[0,1,0,-t[1]],[0,0,-1,e[2]],[0,0,1,-t[2]]],t,e)}static fromCenterSizeAngles(t,i,n){const s=e.bA([],n[0],n[1],n[2]),r=e.bB([],[i[0],0,0],s),o=e.bB([],[0,i[1],0],s),a=e.bB([],[0,0,i[2]],s),h=[...t],l=[...t];for(let e=0;e<8;e++)for(let i=0;i<3;i++){const n=t[i]+r[i]*(1&~e?-1:1)+o[i]*(1==(e>>1&1)?1:-1)+a[i]*(1==(e>>2&1)?1:-1);h[i]=Math.min(h[i],n),l[i]=Math.max(l[i],n)}const c=[];for(let i=0;i<8;i++){const n=[...t];e.a_(n,n,e.aZ([],r,1&~i?-1:1)),e.a_(n,n,e.aZ([],o,1==(i>>1&1)?1:-1)),e.a_(n,n,e.aZ([],a,1==(i>>2&1)?1:-1)),c.push(n)}return new zi(c,[[...r,-e.b3(r,c[0])],[...o,-e.b3(o,c[0])],[...a,-e.b3(a,c[0])],[-r[0],-r[1],-r[2],-e.b3(r,c[7])],[-o[0],-o[1],-o[2],-e.b3(o,c[7])],[-a[0],-a[1],-a[2],-e.b3(a,c[7])]],h,l)}intersectsFrustum(t){let e=!0;const i=this.points.length,n=this.planes.length,s=t.planes.length,r=t.points.length;for(let n=0;n<s;n++){const s=t.planes[n];let r=0;for(let t=0;t<i;t++){const e=this.points[t];s[0]*e[0]+s[1]*e[1]+s[2]*e[2]+s[3]>=0&&r++}if(0===r)return 0;r<i&&(e=!1)}if(e)return 2;for(let e=0;e<n;e++){const i=this.planes[e];let n=0;for(let e=0;e<r;e++){const s=t.points[e];i[0]*s[0]+i[1]*s[1]+i[2]*s[2]+i[3]>=0&&n++}if(0===n)return 0}return 1}intersectsPlane(t){const e=this.points.length;let i=0;for(let n=0;n<e;n++){const e=this.points[n];t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]>=0&&i++}return i===e?2:0===i?0:1}}function Ti(t,e,i){const n=t-e;return n<0?-n:Math.max(0,n-i)}function Ei(t,e,i,n,s){const r=t-i;let o;return o=r<0?Math.min(-r,1+r-s):r>s?Math.min(Math.max(r-s,0),1-r):0,Math.max(o,Ti(e,n,s))}class Ai{constructor(){this._boundingVolumeCache=new Si(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,e,i,n){const s=1<<i.z,r=1/s,o=i.x/s,a=i.y/s;let h=2;return h=Math.min(h,Ei(t,e,o,a,r)),h=Math.min(h,Ei(t,e,o+.5,-a-r,r)),h=Math.min(h,Ei(t,e,o+.5,2-a-r,r)),h}getWrap(t,e,i){const n=1<<e.z,s=1/n,r=e.x/n,o=Ti(t.x,r,s),a=Ti(t.x,r-1,s),h=Ti(t.x,r+1,s),l=Math.min(o,a,h);return l===h?1:l===a?-1:0}allowVariableZoom(t,e){return zt(t,e)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,e,i,n){return this._boundingVolumeCache.getTileBoundingVolume(t,e,i,n)}_computeTileBoundingVolume(t,i,n,s){var r,o;let a=0,h=0;if(null==s?void 0:s.terrain){const l=new e.a3(t.z,i,t.z,t.x,t.y),c=s.terrain.getMinMaxElevation(l);a=null!==(r=c.minElevation)&&void 0!==r?r:Math.min(0,n),h=null!==(o=c.maxElevation)&&void 0!==o?o:Math.max(0,n)}if(a/=e.bD,h/=e.bD,a+=1,h+=1,t.z<=0)return zi.fromAabb([-h,-h,-h],[h,h,h]);if(1===t.z)return zi.fromAabb([0===t.x?-h:0,0===t.y?0:-h,-h],[0===t.x?0:h,0===t.y?h:0,h]);{const i=[mi(0,0,t.x,t.y,t.z),mi(e.a6,0,t.x,t.y,t.z),mi(e.a6,e.a6,t.x,t.y,t.z),mi(0,e.a6,t.x,t.y,t.z)],n=[];for(const t of i)n.push(e.aZ([],t,h));if(h!==a)for(const t of i)n.push(e.aZ([],t,a));0===t.y&&n.push([0,1,0]),t.y===(1<<t.z)-1&&n.push([0,-1,0]);const s=[1,1,1],r=[-1,-1,-1];for(const t of n)for(let e=0;e<3;e++)s[e]=Math.min(s[e],t[e]),r[e]=Math.max(r[e],t[e]);const o=mi(e.a6/2,e.a6/2,t.x,t.y,t.z),l=e.b2([],[0,1,0],o);e.b1(l,l);const c=e.b2([],o,l);e.b1(c,c);const u=e.b2([],i[2],i[1]);e.b1(u,u);const f=e.b2([],i[0],i[3]);e.b1(f,f),n.push(e.aZ([],o,h)),t.y>=(1<<t.z)/2&&n.push(e.aZ([],mi(e.a6/2,0,t.x,t.y,t.z),h)),t.y<(1<<t.z)/2&&n.push(e.aZ([],mi(e.a6/2,e.a6,t.x,t.y,t.z),h));const d=Pi(o,n),p=Pi(c,n),m=[-o[0],-o[1],-o[2],d.max],_=[o[0],o[1],o[2],-d.min],g=[-c[0],-c[1],-c[2],p.max],v=[c[0],c[1],c[2],-p.min],y=[...u,0],w=[...f,0],b=[];return 0===t.y?b.push(e.bC(w,y,m),e.bC(w,y,_)):b.push(e.bC(g,y,m),e.bC(g,y,_),e.bC(g,w,m),e.bC(g,w,_)),t.y===(1<<t.z)-1?b.push(e.bC(w,y,m),e.bC(w,y,_)):b.push(e.bC(v,y,m),e.bC(v,y,_),e.bC(v,w,m),e.bC(v,w,_)),new zi(b,[m,_,g,v,y,w],s,r)}}}function Pi(t,i){let n=1/0,s=-1/0;for(const r of i){const i=e.b3(t,r);n=Math.min(n,i),s=Math.max(s,i)}return{min:n,max:s}}class Ci{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e){this._helper.resize(t,e)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(t){}constructor(t){this._cachedClippingPlane=e.bE(),this._projectionMatrix=e.bi(),this._globeViewProjMatrix32f=e.bh(),this._globeViewProjMatrixNoCorrection=e.bi(),this._globeViewProjMatrixNoCorrectionInverted=e.bi(),this._globeProjMatrixInverted=e.bi(),this._cameraPosition=e.bz(),this._globeLatitudeErrorCorrectionRadians=0,this.defaultConstrain=(t,i)=>{const n=e.al(t.lat,-e.am,e.am),s=e.al(+i,this.minZoom+wi(0,n),this.maxZoom);return{center:new e.W(t.lng,n),zoom:s}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new qe({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Ai}clone(){const t=new Ci;return t.apply(this,!1),t}apply(t,e,i){this._globeLatitudeErrorCorrectionRadians=i||0,this._helper.apply(t,e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const t=e.bz();return t[0]=this._cameraPosition[0],t[1]=this._cameraPosition[1],t[2]=this._cameraPosition[2],t}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(t){const{overscaledTileID:e,applyGlobeMatrix:i}=t,n=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(t){const i=this.pitchInRadians,n=this.cameraToCenterDistance/t,s=Math.sin(i)*n,r=Math.cos(i)*n+1,o=1/Math.sqrt(s*s+r*r)*1;let a=-s,h=r;const l=Math.sqrt(a*a+h*h);a/=l,h/=l;const c=[0,a,h];e.bF(c,c,[0,0,0],-this.bearingInRadians),e.bG(c,c,[0,0,0],-1*this.center.lat*Math.PI/180),e.bH(c,c,[0,0,0],this.center.lng*Math.PI/180);const u=1/e.b5(c);return e.aZ(c,c,u),[...c,-o*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(_i(t))}transformLightDirection(t){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,s=Math.cos(n),r=[Math.sin(i)*s,Math.sin(n),Math.cos(i)*s],o=[r[2],0,-r[0]],a=[0,0,0];e.b2(a,o,r),e.b1(o,o),e.b1(a,a);const h=[0,0,0];return e.b1(h,[o[0]*t[0]+a[0]*t[1]+r[0]*t[2],o[1]*t[0]+a[1]*t[1]+r[1]*t[2],o[2]*t[0]+a[2]*t[1]+r[2]*t[2]]),h}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,i,n){const s=function(t,i,n){const s=1/(1<<n.z);return new e.a7(t/e.a6*s+n.x*s,i/e.a6*s+n.y*s)}(t,i,n.canonical),r=(o=s.y,[e.by(s.x*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI]);var o;return this.getCircleRadiusCorrection()/Math.cos(r[1])}projectTileCoordinates(t,i,n,s){const r=n.canonical,o=mi(t,i,r.x,r.y,r.z),a=1+(s?s(t,i):0)/e.bD,h=[o[0]*a,o[1]*a,o[2]*a,1];e.aE(h,h,this._globeViewProjMatrixNoCorrection);const l=this._cachedClippingPlane,c=l[0]*o[0]+l[1]*o[1]+l[2]*o[2]+l[3]<0;return{point:new e.P(h[0]/h[3],h[1]/h[3]),signedDistanceFromCamera:h[3],isOccluded:c}}_calcMatrices(){if(!this._helper._width||!this._helper._height)return;const t=gi(this.worldSize,this.center.lat),i=e.bj(),n=e.bj();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),e.bc(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);const s=this.centerOffset;i[8]=2*-s.x/this._helper._width,i[9]=2*s.y/this._helper._height,this._projectionMatrix=e.bd(i),this._globeProjMatrixInverted=e.bj(),e.bg(this._globeProjMatrixInverted,i),e.Q(i,i,[0,0,-this.cameraToCenterDistance]),e.be(i,i,this.rollInRadians),e.bf(i,i,-this.pitchInRadians),e.be(i,i,this.bearingInRadians),e.Q(i,i,[0,0,-t]);const r=e.bz();r[0]=t,r[1]=t,r[2]=t,e.bf(n,i,this.center.lat*Math.PI/180),e.bI(n,n,-this.center.lng*Math.PI/180),e.S(n,n,r),this._globeViewProjMatrixNoCorrection=n,e.bf(i,i,this.center.lat*Math.PI/180-this._globeLatitudeErrorCorrectionRadians),e.bI(i,i,-this.center.lng*Math.PI/180),e.S(i,i,r),this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixNoCorrectionInverted=e.bj(),e.bg(this._globeViewProjMatrixNoCorrectionInverted,n);const o=e.bz();this._cameraPosition=e.bz(),this._cameraPosition[2]=this.cameraToCenterDistance/t,e.bF(this._cameraPosition,this._cameraPosition,o,-this.rollInRadians),e.bG(this._cameraPosition,this._cameraPosition,o,this.pitchInRadians),e.bF(this._cameraPosition,this._cameraPosition,o,-this.bearingInRadians),e.a_(this._cameraPosition,this._cameraPosition,[0,0,1]),e.bG(this._cameraPosition,this._cameraPosition,o,-this.center.lat*Math.PI/180),e.bH(this._cameraPosition,this._cameraPosition,o,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);const a=e.bd(this._globeViewProjMatrixNoCorrectionInverted);e.S(a,a,[1,1,-1]),this._cachedFrustum=He.fromInvProjectionMatrix(a,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){e.w("calculateFogMatrix is not supported on globe projection.");const i=e.bj();return e.ap(i),i}getVisibleUnwrappedCoordinates(t){return[new e.ba(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t&&e.w("terrain is not fully supported on vertical perspective projection."),this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,i){if(!this._globeViewProjMatrixNoCorrection)return 1;const n=_i(t);e.aZ(n,n,1+i/e.bD);const s=e.bE();return e.aE(s,[n[0],n[1],n[2],1],this._globeViewProjMatrixNoCorrection),s[2]/s[3]}populateCache(t){}getBounds(){const t=.5*this.width,i=.5*this.height,n=[new e.P(0,0),new e.P(t,0),new e.P(this.width,0),new e.P(this.width,i),new e.P(this.width,this.height),new e.P(t,this.height),new e.P(0,this.height),new e.P(0,i)],s=[];for(const t of n)s.push(this.unprojectScreenPoint(t));let r=0,o=0,a=0,h=0;const l=this.center;for(const t of s){const i=e.bJ(l.lng,t.lng),n=e.bJ(l.lat,t.lat);i<o&&(o=i),i>r&&(r=i),n<h&&(h=n),n>a&&(a=n)}const c=[l.lng+o,l.lat+h,l.lng+r,l.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(c[3]=90,c[0]=-180,c[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(c[1]=-90,c[0]=-180,c[2]=180),new G(c)}calculateCenterFromCameraLngLatAlt(t,e,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,n)}setLocationAtPoint(t,i){const n=_i(this.unprojectScreenPoint(i)),s=_i(t),r=e.bz();e.bK(r);const o=e.bz();e.bH(o,n,r,-this.center.lng*Math.PI/180),e.bG(o,o,r,this.center.lat*Math.PI/180);const a=s[0]*s[0]+s[2]*s[2],h=o[0]*o[0];if(a<h)return;const l=Math.sqrt(a-h),c=-l,u=e.bL(s[0],s[2],o[0],l),f=e.bL(s[0],s[2],o[0],c),d=e.bz();e.bH(d,s,r,-u);const p=e.bL(d[1],d[2],o[1],o[2]),m=e.bz();e.bH(m,s,r,-f);const _=e.bL(m[1],m[2],o[1],o[2]),g=.5*Math.PI,v=p>=-g&&p<=g,y=_>=-g&&_<=g;let w,b;if(v&&y){const t=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;e.bM(u,t)+e.bM(p,i)<e.bM(f,t)+e.bM(_,i)?(w=u,b=p):(w=f,b=_)}else if(v)w=u,b=p;else{if(!y)return;w=f,b=_}const x=w/Math.PI*180,M=b/Math.PI*180,S=this.center.lat;this.setCenter(new e.W(x,e.al(M,-90,90))),this.setZoom(this.zoom+wi(S,this.center.lat))}locationToScreenPoint(t,i){const n=_i(t);if(i){const s=i.getElevationForLngLatZoom(t,this._helper._tileZoom);e.aZ(n,n,1+s/e.bD)}return this._projectSurfacePointToScreen(n)}_projectSurfacePointToScreen(t){const i=e.bE();return e.aE(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],new e.P((.5*i[0]+.5)*this.width,(.5*-i[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,i){if(i){const e=i.pointCoordinate(t);if(e)return e}return e.a7.fromLngLat(this.unprojectScreenPoint(t))}screenPointToLocation(t,e){var i;return null===(i=this.screenPointToMercatorCoordinate(t,e))||void 0===i?void 0:i.toLngLat()}isPointOnMapSurface(t,e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(t);return!!this.rayPlanetIntersection(i,n)}getRayDirectionFromPixel(t){const i=e.bE();i[0]=t.x/this.width*2-1,i[1]=-1*(t.y/this.height*2-1),i[2]=1,i[3]=1,e.aE(i,i,this._globeViewProjMatrixNoCorrectionInverted),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3];const n=e.bz();n[0]=i[0]-this._cameraPosition[0],n[1]=i[1]-this._cameraPosition[1],n[2]=i[2]-this._cameraPosition[2];const s=e.bz();return e.b1(s,n),s}isSurfacePointVisible(t){const e=this._cachedClippingPlane;return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]>=0}isSurfacePointOnScreen(t){if(!this.isSurfacePointVisible(t))return!1;const i=e.bE();return e.aE(i,[...t,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(t,i){const n=e.b3(t,i),s=e.bz(),r=e.bz();e.aZ(r,i,n),e.b0(s,t,r);const o=1-e.b3(s,s);if(o<0)return null;const a=e.b3(t,t)-1,h=-n+(n<0?1:-1)*Math.sqrt(o),l=a/h,c=h;return{tMin:Math.min(l,c),tMax:Math.max(l,c)}}unprojectScreenPoint(t){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(t),s=this.rayPlanetIntersection(i,n);if(s){const t=e.bz();e.a_(t,i,[n[0]*s.tMin,n[1]*s.tMin,n[2]*s.tMin]);const r=e.bz();return e.b1(r,t),vi(r)}const r=this._cachedClippingPlane,o=r[0]*n[0]+r[1]*n[1]+r[2]*n[2],a=-e.b9(r,i)/o,h=e.bz();if(a>0)e.a_(h,i,[n[0]*a,n[1]*a,n[2]*a]);else{const t=e.bz();e.a_(t,i,[2*n[0],2*n[1],2*n[2]]);const s=e.b9(this._cachedClippingPlane,t);e.b0(h,t,[this._cachedClippingPlane[0]*s,this._cachedClippingPlane[1]*s,this._cachedClippingPlane[2]*s])}const l=function(t){const i=e.bz();return i[0]=t[0]*-t[3],i[1]=t[1]*-t[3],i[2]=t[2]*-t[3],{center:i,radius:Math.sqrt(1-t[3]*t[3])}}(r);return vi(function(t,i,n){const s=e.bz();e.b0(s,n,t);const r=e.bz();return e.bx(r,t,s,i/e.b7(s)),r}(l.center,l.radius,h))}getMatrixForModel(t,i){const n=e.W.convert(t),s=1/e.bD,r=e.bi();return e.bI(r,r,n.lng/180*Math.PI),e.bf(r,r,-n.lat/180*Math.PI),e.Q(r,r,[0,0,1+i/e.bD]),e.bf(r,r,.5*Math.PI),e.S(r,r,[s,s,s]),r}getProjectionDataForCustomLayer(t=!0){const i=this.getProjectionData({overscaledTileID:new e.a3(0,0,0,0,0),applyGlobeMatrix:t});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(t){}}class Di{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(t){this._helper.setMinZoom(t)}setMaxZoom(t){this._helper.setMaxZoom(t)}setMinPitch(t){this._helper.setMinPitch(t)}setMaxPitch(t){this._helper.setMaxPitch(t)}setRenderWorldCopies(t){this._helper.setRenderWorldCopies(t)}setBearing(t){this._helper.setBearing(t)}setPitch(t){this._helper.setPitch(t)}setRoll(t){this._helper.setRoll(t)}setFov(t){this._helper.setFov(t)}setZoom(t){this._helper.setZoom(t)}setCenter(t){this._helper.setCenter(t)}setElevation(t){this._helper.setElevation(t)}setMinElevationForCurrentTile(t){this._helper.setMinElevationForCurrentTile(t)}setPadding(t){this._helper.setPadding(t)}interpolatePadding(t,e,i){this._helper.interpolatePadding(t,e,i)}isPaddingEqual(t){return this._helper.isPaddingEqual(t)}resize(t,e,i=!0){this._helper.resize(t,e,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(t){this._helper.setMaxBounds(t)}setConstrainOverride(t){this._helper.setConstrainOverride(t)}overrideNearFarZ(t,e){this._helper.overrideNearFarZ(t,e)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(t){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),t)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(t,e){this._globeness=t,this._globeLatitudeErrorCorrectionRadians=e,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(t,e)=>this.currentTransform.defaultConstrain(t,e),this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new qe({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new Ye,this._verticalPerspectiveTransform=new Ci}clone(){const t=new Di;return t._globeness=this._globeness,t._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,t.apply(this,!1),t}apply(t,e){this._helper.apply(t,e),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(t){const e=this._mercatorTransform.getProjectionData(t),i=this._verticalPerspectiveTransform.getProjectionData(t);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:e.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:t.applyGlobeMatrix?this._globeness:0,fallbackMatrix:e.fallbackMatrix}}isLocationOccluded(t){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return e.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return e.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,i,n){const s=this._mercatorTransform.getPitchedTextCorrection(t,i,n),r=this._verticalPerspectiveTransform.getPitchedTextCorrection(t,i,n);return e.bt(s,r,this._globeness)}projectTileCoordinates(t,e,i,n){return this.currentTransform.projectTileCoordinates(t,e,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,!1,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this._mercatorTransform.recalculateZoomAndCenter(t),this._verticalPerspectiveTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,e,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,n)}setLocationAtPoint(t,e){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,e),this.apply(this._verticalPerspectiveTransform,!1)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getMatrixForModel(t,e){return this.currentTransform.getMatrixForModel(t,e)}getProjectionDataForCustomLayer(t=!0){const e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}}class Fi{get useGlobeControls(){return!0}handlePanInertia(t,i){const n=bi(t,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new e.P(0,0)}}handleMapControlsRollPitchBearingZoom(t,i){const n=t.around,s=i.screenPointToLocation(n);t.bearingDelta&&i.setBearing(i.bearing+t.bearingDelta),t.pitchDelta&&i.setPitch(i.pitch+t.pitchDelta),t.rollDelta&&i.setRoll(i.roll+t.rollDelta);const r=i.zoom;t.zoomDelta&&i.setZoom(i.zoom+t.zoomDelta);const o=i.zoom-r;if(0===o)return;const a=e.bJ(i.center.lng,s.lng),h=a/(Math.abs(a/180)+1),l=e.bJ(i.center.lat,s.lat),c=i.getRayDirectionFromPixel(n),u=i.cameraPosition,f=-1*e.b3(u,c),d=e.bz();e.a_(d,u,[c[0]*f,c[1]*f,c[2]*f]);const p=e.b5(d)-1,m=Math.exp(.5*-Math.max(p-.3,0)),_=gi(i.worldSize,i.center.lat)/Math.min(i.width,i.height),g=e.bw(_,.9,.5,1,.25),v=(1-e.ao(-o))*Math.min(m,g),y=i.center.lat,w=i.zoom,b=new e.W(i.center.lng+h*v,e.al(i.center.lat+l*v,-e.am,e.am));i.setLocationAtPoint(s,n);const x=i.center,M=e.bw(Math.abs(a),45,85,0,1),S=e.bw(_,.75,.35,0,1),z=Math.pow(Math.max(M,S),.25),T=e.bJ(x.lng,b.lng),E=e.bJ(x.lat,b.lat);i.setCenter(new e.W(x.lng+T*z,x.lat+E*z).wrap()),i.setZoom(w+wi(y,i.center.lat))}handleMapControlsPan(t,e,i){if(!t.panDelta)return;const n=e.center.lat,s=e.zoom;e.setCenter(bi(t.panDelta,e).wrap()),e.setZoom(s+wi(n,e.center.lat))}cameraForBoxAndBearing(t,i,n,s,r){const o=Ke(t,i,n,s,r),a=i.left/r.width*2-1,h=(r.width-i.right)/r.width*2-1,l=i.top/r.height*-2+1,c=(r.height-i.bottom)/r.height*-2+1,u=e.bJ(n.getWest(),n.getEast())<0,f=u?n.getEast():n.getWest(),d=u?n.getWest():n.getEast(),p=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),_=f+.5*e.bJ(f,d),g=p+.5*e.bJ(p,m),v=r.clone();v.setCenter(o.center),v.setBearing(o.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(o.zoom);const y=v.modelViewProjectionMatrix,w=[_i(n.getNorthWest()),_i(n.getNorthEast()),_i(n.getSouthWest()),_i(n.getSouthEast()),_i(new e.W(d,g)),_i(new e.W(f,g)),_i(new e.W(_,p)),_i(new e.W(_,m))],b=_i(o.center);let x=Number.POSITIVE_INFINITY;for(const t of w)a<0&&(x=Fi.getLesserNonNegativeNonNull(x,Fi.solveVectorScale(t,b,y,"x",a))),h>0&&(x=Fi.getLesserNonNegativeNonNull(x,Fi.solveVectorScale(t,b,y,"x",h))),l>0&&(x=Fi.getLesserNonNegativeNonNull(x,Fi.solveVectorScale(t,b,y,"y",l))),c<0&&(x=Fi.getLesserNonNegativeNonNull(x,Fi.solveVectorScale(t,b,y,"y",c)));if(Number.isFinite(x)&&0!==x)return o.zoom=Math.min(v.zoom+e.ar(x),t.maxZoom),o;Xe()}handleJumpToCenterZoom(t,i){const n=t.center.lat,s=t.applyConstrain(i.center?e.W.convert(i.center):t.center,t.zoom).center;t.setCenter(s.wrap());const r=void 0!==i.zoom?+i.zoom:t.zoom+wi(n,s.lat);t.zoom!==r&&t.setZoom(r)}handleEaseTo(t,i){const n=t.zoom,s=t.center,r=t.padding,o={roll:t.roll,pitch:t.pitch,bearing:t.bearing},a={roll:void 0===i.roll?t.roll:i.roll,pitch:void 0===i.pitch?t.pitch:i.pitch,bearing:void 0===i.bearing?t.bearing:i.bearing},h=void 0!==i.zoom,l=!t.isPaddingEqual(i.padding);let c=!1;const u=i.center?e.W.convert(i.center):s,f=t.applyConstrain(u,n).center;Ge(t,f);const d=t.clone();d.setCenter(f),d.setZoom(h?+i.zoom:n+wi(s.lat,u.lat)),d.setBearing(i.bearing);const p=new e.P(e.al(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.al(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));d.setLocationAtPoint(f,p);const m=(i.offset&&i.offsetAsPoint.mag())>0?d.center:f,_=h?+i.zoom:n+wi(s.lat,m.lat),g=n+wi(s.lat,0),v=_+wi(m.lat,0),y=e.bJ(s.lng,m.lng),w=e.bJ(s.lat,m.lat),b=e.ao(v-g);return c=_!==n,{easeFunc:n=>{if(e.bn(o,a)||Je({startEulerAngles:o,endEulerAngles:a,tr:t,k:n,useSlerp:o.roll!=a.roll}),l&&t.interpolatePadding(r,i.padding,n),i.around)e.w("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(i.around,i.aroundPoint);else{const e=v>g?Math.min(2,b):Math.max(.5,b),i=Math.pow(e,1-n),r=Mi(s,y,w,n*i);t.setCenter(r.wrap())}if(c){const i=e.H.number(g,v,n)+wi(0,t.center.lat);t.setZoom(i)}},isZooming:c,elevationCenter:m}}handleFlyTo(t,i){const n=void 0!==i.zoom,s=t.center,r=t.zoom,o=t.padding,a=!t.isPaddingEqual(i.padding),h=t.applyConstrain(e.W.convert(i.center||i.locationAtOffset),r).center,l=n?+i.zoom:t.zoom+wi(t.center.lat,h.lat),c=t.clone();c.setCenter(h),c.setZoom(l),c.setBearing(i.bearing);const u=new e.P(e.al(t.centerPoint.x+i.offsetAsPoint.x,0,t.width),e.al(t.centerPoint.y+i.offsetAsPoint.y,0,t.height));c.setLocationAtPoint(h,u);const f=c.center;Ge(t,f);const d=function(t,i,n){const s=_i(i),r=_i(n),o=e.b3(s,r),a=Math.acos(o),h=pi(t);return a/(2*Math.PI)*h}(t,s,f),p=r+wi(s.lat,0),m=l+wi(f.lat,0),_=e.ao(m-p);let g;if("number"==typeof i.minZoom){const n=+i.minZoom+wi(f.lat,0),s=Math.min(n,p,m)+wi(0,f.lat),r=t.applyConstrain(f,s).zoom+wi(f.lat,0);g=e.ao(r-p)}const v=e.bJ(s.lng,f.lng),y=e.bJ(s.lat,f.lat);return{easeFunc:(n,r,h)=>{const c=Mi(s,v,y,h);a&&t.interpolatePadding(o,i.padding,n);const u=1===n?f:c;t.setCenter(u.wrap());const d=p+e.ar(r);t.setZoom(1===n?l:d+wi(0,u.lat))},scaleOfZoom:_,targetCenter:f,scaleOfMinZoom:g,pixelPathLength:d}}static solveVectorScale(t,e,i,n,s){const r="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],o=[i[3],i[7],i[11],i[15]],a=t[0]*r[0]+t[1]*r[1]+t[2]*r[2],h=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],l=e[0]*r[0]+e[1]*r[1]+e[2]*r[2],c=e[0]*o[0]+e[1]*o[1]+e[2]*o[2];return l+s*h===a+s*c||o[3]*(a-l)+r[3]*(c-h)+a*c==l*h?null:(l+r[3]-s*c-s*o[3])/(l-a-s*c+s*h)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}}class Ii{constructor(t){this._globe=t,this._mercatorCameraHelper=new Qe,this._verticalPerspectiveCameraHelper=new Fi}get useGlobeControls(){return this._globe.useGlobeRendering}get currentHelper(){return this.useGlobeControls?this._verticalPerspectiveCameraHelper:this._mercatorCameraHelper}handlePanInertia(t,e){return this.currentHelper.handlePanInertia(t,e)}handleMapControlsRollPitchBearingZoom(t,e){this.currentHelper.handleMapControlsRollPitchBearingZoom(t,e)}handleMapControlsPan(t,e,i){this.currentHelper.handleMapControlsPan(t,e,i)}cameraForBoxAndBearing(t,e,i,n,s){return this.currentHelper.cameraForBoxAndBearing(t,e,i,n,s)}handleJumpToCenterZoom(t,e){this.currentHelper.handleJumpToCenterZoom(t,e)}handleEaseTo(t,e){return this.currentHelper.handleEaseTo(t,e)}handleFlyTo(t,e){return this.currentHelper.handleFlyTo(t,e)}}const ki=(t,i)=>e.C(t,null==i?void 0:i.filter((t=>"source.canvas"!==t.identifier))),$i=e.bN();class Oi extends e.E{constructor(t,i={}){var n,s;super(),this._rtlPluginLoaded=()=>{for(const t in this.tileManagers){const e=this.tileManagers[t].getSource().type;"vector"!==e&&"geojson"!==e||this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new O($(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.dispatcher.registerMessageHandler("GDA",((t,e)=>this.getDashes(t,e))),this.imageManager=new g,this.imageManager.setEventedParent(this);const r=(null===(n=t._container)||void 0===n?void 0:n.lang)||"undefined"!=typeof document&&(null===(s=document.documentElement)||void 0===s?void 0:s.lang)||void 0;this.glyphManager=new M(t._requestManager,i.localIdeographFontFamily,r),this.lineAtlas=new P(256,512),this.crossTileSymbolIndex=new Ie,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",e.bO()),lt().on(ot,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;const e=this.tileManagers[t.sourceId];if(!e)return;const i=e.getSource();if(null==i?void 0:i.vectorLayerIds)for(const t in this._layers){const e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}_setInitialValues(){var t;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new e.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(t=this.crossTileSymbolIndex)||void 0===t?void 0:t.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,i){var n,s,r;this._checkLoaded();const o=null===i?null!==(r=null===(s=null===(n=this.stylesheet.state)||void 0===n?void 0:n[t])||void 0===s?void 0:s.default)&&void 0!==r?r:null:i;if(e.bQ(o,this._globalState[t]))return this;this._globalState[t]=o,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();const i=[];for(const n in t)!e.bQ(this._globalState[n],t[n].default)&&(i.push(n),this._globalState[n]=t[n].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(t){if(0===t.length)return;const e=new Set,i={};for(const n of t){i[n]=this._globalState[n];for(const t in this._layers){const i=this._layers[t],s=i.getLayoutAffectingGlobalStateRefs(),r=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(s.has(n)&&e.add(i.source),r.has(n))for(const{name:t,value:e}of r.get(n))this._updatePaintProperty(i,t,e);(null==o?void 0:o.has(n))&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(const t in this.tileManagers)e.has(t)&&(this._reloadSource(t),this._changed=!0)}loadURL(t){return e._(this,arguments,void 0,(function*(t,i={},n){this.fire(new e.n("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate,this._loadStyleRequest=new AbortController;const s=this._loadStyleRequest;try{const r=yield this.map._requestManager.transformRequest(t,"Style");e.bR(s.signal);const o=yield e.k(r,s);this._loadStyleRequest===s&&(this._loadStyleRequest=null),this._load(o.data,i,n)}catch(t){this._loadStyleRequest===s&&(this._loadStyleRequest=null),t&&!s.signal.aborted&&this.fire(new e.l(e.d(t)))}}))}loadJSON(t,i={},n){this.fire(new e.n("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(t,i,n)})).catch((()=>{}))}loadEmpty(){this.fire(new e.n("dataloading",{dataType:"style"})),this._load($i,{validate:!1})}_load(t,i,n){var s,r;let o=i.transformStyle?i.transformStyle(n,t):t;if(!i.validate||!ki(this,e.F(o))){o=Object.assign({},o),this._loaded=!0,this.stylesheet=o;for(const t in o.sources)this.addSource(t,o.sources[t],{validate:!1});o.sprite?this._loadSprite(o.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(o.glyphs),this._createLayers(),this.light=new T(this.stylesheet.light),this._setProjectionInternal((null===(s=this.stylesheet.projection)||void 0===s?void 0:s.type)||"mercator"),this.sky=new A(this.stylesheet.sky),this.map.setTerrain(null!==(r=this.stylesheet.terrain)&&void 0!==r?r:null),this.fire(new e.n("data",{dataType:"style"})),this.fire(new e.n("style.load"))}}_createLayers(){var t,i,n;const s=e.bS(this.stylesheet.layers);this.setGlobalState(null!==(t=this.stylesheet.state)&&void 0!==t?t:null),this.dispatcher.broadcast("SL",s),this._order=s.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(const t of s){const s=e.bT(t,this._globalState);if(s.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=s,e.bU(s)&&this.tileManagers[s.source]){const e=null!==(n=null===(i=t.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==n?n:s.paint.get("raster-fade-duration");this.tileManagers[s.source].setRasterFadeDuration(e)}}}_loadSprite(t,i=!1,n){this.imageManager.setLoaded(!1);const s=new AbortController;let r;this._spriteRequest=s,function(t,i,n,s){return e._(this,void 0,void 0,(function*(){const r=p(t),o=n>1?"@2x":"",h={},l={};for(const{id:t,url:n}of r){const r=yield i.transformRequest(m(n,o,".json"),"SpriteJSON");h[t]=e.k(r,s);const a=yield i.transformRequest(m(n,o,".png"),"SpriteImage");l[t]=u.getImage(a,s)}return yield Promise.all([...Object.values(h),...Object.values(l)]),function(t,i){return e._(this,void 0,void 0,(function*(){const e={};for(const n in t){e[n]={};const s=a.getImageCanvasContext((yield i[n]).data),r=(yield t[n]).data;for(const t in r){const{width:i,height:o,x:a,y:h,sdf:l,pixelRatio:c,stretchX:u,stretchY:f,content:d,textFitWidth:p,textFitHeight:m}=r[t];e[n][t]={data:null,pixelRatio:c,sdf:l,stretchX:u,stretchY:f,content:d,textFitWidth:p,textFitHeight:m,spriteData:{width:i,height:o,x:a,y:h,context:s}}}}return e}))}(h,l)}))}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then((t=>{if(this._spriteRequest=null,t)for(const e in t){this._spritesImagesIds[e]=[];const n=this._spritesImagesIds[e]?this._spritesImagesIds[e].filter((e=>!(e in t))):[];for(const t of n)this.imageManager.removeImage(t),this._changedImages[t]=!0;for(const n in t[e]){const s="default"===e?n:`${e}:${n}`;this._spritesImagesIds[e].push(s),s in this.imageManager.images?this.imageManager.updateImage(s,t[e][n],!1):this.imageManager.addImage(s,t[e][n]),i&&(this._changedImages[s]=!0)}}})).catch((t=>{this._spriteRequest=null,r=t,s.signal.aborted||this.fire(new e.l(r))})).finally((()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.n("data",{dataType:"style"})),n&&n(r)}))}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.n("data",{dataType:"style"}))}_validateLayer(t){const i=this.tileManagers[t.source];if(!i)return;const n=t.sourceLayer;if(!n)return;const s=i.getSource();("geojson"===s.type||s.vectorLayerIds&&!s.vectorLayerIds.includes(n))&&this.fire(new e.l(new Error(`Source layer "${n}" does not exist on source "${s.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,i=!1){const n=this._serializedAllLayers();if(!t||0===t.length)return Object.values(i?e.bV(n):n);const s=[];for(const r of t)if(n[r]){const t=i?e.bV(n[r]):n[r];s.push(t)}return s}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const e=Object.keys(this._layers);for(const i of e){const e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){var t,e,i;if(null===(t=this.light)||void 0===t?void 0:t.hasTransition())return!0;if(null===(e=this.sky)||void 0===e?void 0:e.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const i=this._changed;if(i){const e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(const t in this._updatedSources){const e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw new Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.sky.updateTransitions(t),this._resetUpdates()}const n={};for(const t in this.tileManagers){const e=this.tileManagers[t];n[t]=e.used,e.used=!1}for(const e of this._order){const i=this._layers[e];i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const t in n){const i=this.tileManagers[t];!!n[t]!=!!i.used&&i.fire(new e.n("data",{sourceDataType:"visibility",dataType:"source",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,i&&this.fire(new e.n("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,e){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t,!1),removedIds:e})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,i={}){var n;this._checkLoaded();const s=this.serialize();if(t=i.transformStyle?i.transformStyle(s,t):t,(null===(n=i.validate)||void 0===n||n)&&ki(this,e.F(t)))return!1;(t=e.bV(t)).layers=e.bS(t.layers);const r=e.bW(s,t),o=this._getOperationsToPerform(r);if(o.unimplemented.length>0)throw new Error(`Unimplemented: ${o.unimplemented.join(", ")}.`);if(0===o.operations.length)return!1;for(const t of o.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new e.n("style.load",{style:this})),!0}_getOperationsToPerform(t){const e=[],i=[];for(const n of t)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":e.push((()=>this.addLayer.apply(this,n.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,n.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,n.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,n.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,n.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,n.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,n.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,n.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,n.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,n.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,n.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,n.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,n.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,n.args)));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":e.push((()=>this.setGlobalState.apply(this,n.args)));break;case"setTransition":e.push((()=>{}));break;default:i.push(n.command)}return{operations:e,unimplemented:i}}addImage(t,i){if(this.getImage(t))return this.fire(new e.l(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,i),this._afterImageUpdated(t)}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new e.l(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.n("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,i,n={}){var s;if(this._checkLoaded(),void 0!==this.tileManagers[t])throw new Error(`Source "${t}" already exists.`);if(!i.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(i).join(", ")}.`);if(["vector","raster","geojson","video","image"].includes(i.type)&&this._validate(e.F.source,`sources.${t}`,i,null,n))return;(null===(s=this.map)||void 0===s?void 0:s._collectResourceTiming)&&(i.collectResourceTiming=!0);const r=this.tileManagers[t]=new $t(t,i,this.dispatcher);r.style=this,r.setEventedParent(this,(()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:t}))),r.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),void 0===this.tileManagers[t])throw new Error(`There is no source with this ID=${t}`);for(const i in this._layers)if(this._layers[i].source===t)return this.fire(new e.l(new Error(`Source "${t}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],i.fire(new e.n("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.tileManagers[t])throw new Error(`There is no source with this ID=${t}`);const i=this.tileManagers[t].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){var e;return null===(e=this.tileManagers[t])||void 0===e?void 0:e.getSource()}addLayer(t,i,n={}){this._checkLoaded();const s=t.id;if(this.getLayer(s))return void this.fire(new e.l(new Error(`Layer "${s}" already exists on this map.`)));let r;if("custom"===t.type){if(ki(this,e.bX(t)))return;r=e.bT(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(s,t.source),t=e.bV(t),t=e.e(t,{source:s})),this._validate(e.F.layer,`layers.${s}`,t,{arrayIndex:-1},n))return;r=e.bT(t,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:s}})}const o=i?this._order.indexOf(i):this._order.length;if(i&&-1===o)this.fire(new e.l(new Error(`Cannot add layer "${s}" before non-existing layer "${i}".`)));else{if(this._order.splice(o,0,s),this._layerOrderChanged=!0,this._layers[s]=r,this._removedLayers[s]&&r.source&&"custom"!==r.type){const t=this._removedLayers[s];delete this._removedLayers[s],t.type!==r.type?this._updatedSources[r.source]="clear":(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause())}this._updateLayer(r),r.onAdd&&r.onAdd(this.map)}}moveLayer(t,i){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.l(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);const s=i?this._order.indexOf(i):this._order.length;i&&-1===s?this.fire(new e.l(new Error(`Cannot move layer "${t}" before non-existing layer "${i}".`))):(this._order.splice(s,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const i=this._layers[t];if(!i)return void this.fire(new e.l(new Error(`Cannot remove non-existing layer "${t}".`)));i.setEventedParent(null);const n=this._order.indexOf(t);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=i,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],i.onRemove&&i.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,i,n){this._checkLoaded();const s=this.getLayer(t);s?s.minzoom===i&&s.maxzoom===n||(null!=i&&(s.minzoom=i),null!=n&&(s.maxzoom=n),this._updateLayer(s)):this.fire(new e.l(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,i,n={}){this._checkLoaded();const s=this.getLayer(t);if(s){if(!e.bQ(s.filter,i))return null==i?(s.setFilter(void 0),void this._updateLayer(s)):void(this._validate(e.F.filter,`layers.${s.id}.filter`,i,null,n)||(s.setFilter(e.bV(i)),this._updateLayer(s)))}else this.fire(new e.l(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return e.bV(this.getLayer(t).filter)}setLayoutProperty(t,i,n,s={}){this._checkLoaded();const r=this.getLayer(t);r?e.bQ(r.getLayoutProperty(i),n)||(r.setLayoutProperty(i,n,s),this._updateLayer(r)):this.fire(new e.l(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,i){const n=this.getLayer(t);if(n)return n.getLayoutProperty(i);this.fire(new e.l(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,i,n,s={}){this._checkLoaded();const r=this.getLayer(t);r?e.bQ(r.getPaintProperty(i),n)||this._updatePaintProperty(r,i,n,s):this.fire(new e.l(new Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,i,n,s={}){t.setPaintProperty(i,n,s)&&this._updateLayer(t),e.bU(t)&&"raster-fade-duration"===i&&this.tileManagers[t.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[t.id]=!0,this._serializedLayers=null}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,i){this._checkLoaded();const n=t.source,s=t.sourceLayer,r=this.tileManagers[n];if(void 0===r)return void this.fire(new e.l(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type;"geojson"===o&&s?this.fire(new e.l(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==o||s?(void 0===t.id&&this.fire(new e.l(new Error("The feature id parameter must be provided."))),r.setFeatureState(s,t.id,i)):this.fire(new e.l(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,i){this._checkLoaded();const n=t.source,s=this.tileManagers[n];if(void 0===s)return void this.fire(new e.l(new Error(`The source '${n}' does not exist in the map's style.`)));const r=s.getSource().type,o="vector"===r?t.sourceLayer:void 0;"vector"!==r||o?i&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new e.l(new Error("A feature id is required to remove its specific state property."))):s.removeFeatureState(o,t.id,i):this.fire(new e.l(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const i=t.source,n=t.sourceLayer,s=this.tileManagers[i];if(void 0!==s)return"vector"!==s.getSource().type||n?(void 0===t.id&&this.fire(new e.l(new Error("The feature id parameter must be provided."))),s.getFeatureState(n,t.id)):void this.fire(new e.l(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new e.l(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){var t;return e.e({duration:300,delay:0},null===(t=this.stylesheet)||void 0===t?void 0:t.transition)}serialize(){if(!this._loaded)return;const t=e.bY(this.tileManagers,(t=>t.serialize())),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,s=this.stylesheet;return e.bZ({version:s.version,name:s.name,metadata:s.metadata,light:s.light,sky:s.sky,center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch,sprite:s.sprite,glyphs:s.glyphs,transition:s.transition,projection:s.projection,sources:t,layers:i,terrain:n},(t=>void 0!==t))}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&"raster"!==this.tileManagers[t.source].getSource().type&&(this._updatedSources[t.source]="reload",this.tileManagers[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const e=t=>"fill-extrusion"===this._layers[t].type,i={},n=[];for(let s=this._order.length-1;s>=0;s--){const r=this._order[s];if(e(r)){i[r]=s;for(const e of t){const t=e[r];if(t)for(const e of t)n.push(e)}}}n.sort(((t,e)=>e.intersectionZ-t.intersectionZ));const s=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(e(o))for(let t=n.length-1;t>=0;t--){const e=n[t].feature;if(i[e.layer.id]<r)break;s.push(e),n.pop()}else for(const e of t){const t=e[o];if(t)for(const e of t)s.push(e.feature)}}return s}queryRenderedFeatures(t,i,n){(null==i?void 0:i.filter)&&this._validate(e.F.filter,"queryRenderedFeatures.filter",i.filter,null,i);const s={};if(null==i?void 0:i.layers){if(!(Array.isArray(i.layers)||i.layers instanceof Set))return this.fire(new e.l(new Error("parameters.layers must be an Array or a Set of strings"))),[];for(const t of i.layers){const i=this._layers[t];if(!i)return this.fire(new e.l(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s[i.source]=!0}}const r=[];i.availableImages=this._availableImages;const o=this._serializedAllLayers(),a=i.layers instanceof Set?i.layers:Array.isArray(i.layers)?new Set(i.layers):null,h=Object.assign(Object.assign({},i),{layers:a,globalState:this._globalState});for(const e in this.tileManagers)i.layers&&!s[e]||r.push(L(this.tileManagers[e],this._layers,o,t,h,n,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));return this.placement&&r.push(function(t,e,i,n,s,r,o){const a={},h=r.queryRenderedSymbols(n),l=[];for(const t of Object.keys(h).map(Number))l.push(o[t]);l.sort(B);for(const i of l){const n=i.featureIndex.lookupSymbolFeatures(h[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,{filterSpec:s.filter,globalState:s.globalState},s.layers,s.availableImages,t);for(const t in n){a[t]||(a[t]=[]);const e=n[t];e.sort(((t,e)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(t.featureIndex);return n.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(const i of e)a[t].push(i)}}return function(t,e,i){for(const n in t)for(const s of t[n])N(s,i[e[n].source]);return t}(a,t,i)}(this._layers,o,this.tileManagers,t,h,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(r)}querySourceFeatures(t,i){(null==i?void 0:i.filter)&&this._validate(e.F.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.tileManagers[t];return n?function(t,e){const i=t.getRenderableIds().map((e=>t.getTileByID(e))),n=[],s={};for(const t of i){const i=t.tileID.canonical.key;s[i]||(s[i]=!0,t.querySourceFeatures(n,e))}return n}(n,i?Object.assign(Object.assign({},i),{globalState:this._globalState}):{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,i={}){this._checkLoaded();const n=this.light.getLight();let s=!1;for(const i in t)if(!e.bQ(t[i],n[i])){s=!0;break}if(!s)return;const r={now:l(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,i),this.light.updateTransitions(r)}getProjection(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.projection}setProjection(t){this._checkLoaded();const e=null!=t?t:{type:"mercator"};if(this.stylesheet.projection=t,this.projection){if(this.projection.name===e.type)return;this.projection.destroy(),delete this.projection}this._setProjectionInternal(e.type)}getSky(){var t;return null===(t=this.stylesheet)||void 0===t?void 0:t.sky}setSky(t,i={}){this._checkLoaded();const n=this.getSky();let s=!1;if(!t&&!n)return;if(t&&!n)s=!0;else if(!t&&n)s=!0;else for(const i in t)if(!e.bQ(t[i],n[i])){s=!0;break}if(!s)return;const r={now:l(),transition:e.e({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,i),this.sky.updateTransitions(r)}_setProjectionInternal(t){const i=function(t,i){const n={constrainOverride:i};if(Array.isArray(t)){const e=new di({type:t});return{projection:e,transform:new Di(n),cameraHelper:new Ii(e)}}switch(t){case"mercator":return{projection:new Ne,transform:new Ye(n),cameraHelper:new Qe};case"globe":{const t=new di({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]});return{projection:t,transform:new Di(n),cameraHelper:new Ii(t)}}case"vertical-perspective":return{projection:new ui,transform:new Ci(n),cameraHelper:new Fi};default:return e.w(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Ne,transform:new Ye(n),cameraHelper:new Qe}}}(t,this.map.transformConstrain);this.projection=i.projection,this.map.migrateProjection(i.transform,i.cameraHelper);for(const t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,i,n,s,r={}){return!1!==(null==r?void 0:r.validate)&&ki(this,t.call(e.F,e.e({key:i,style:this.serialize(),value:n,styleSpec:e.x},s)))}_remove(t=!0){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null),lt().off(ot,this._rtlPluginLoaded);for(const t in this._layers)this._layers[t].setEventedParent(null);for(const t in this.tileManagers){const e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.imageManager.setEventedParent(null),this.setEventedParent(null),t&&this.dispatcher.broadcast("RM",void 0),this.dispatcher.remove(t)}_clearSource(t){this.tileManagers[t].clearTiles()}_reloadSource(t){this.tileManagers[t].resume(),this.tileManagers[t].reload()}_updateSources(t){for(const e in this.tileManagers)this.tileManagers[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(const t in this.tileManagers)this._reloadSource(t)}_updatePlacement(t,e,i,n,s=!1){let r=!1,o=!1;const a={};for(const e of this._order){const i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){const t=this.tileManagers[i.source];a[i.source]=t.getRenderableIds(!0).map((e=>t.getTileByID(e))).sort(((t,e)=>e.tileID.overscaledZ-t.tileID.overscaledZ||(t.tileID.isLessThan(e.tileID)?-1:1)))}const n=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng);r||(r=n)}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),s||(s=this._layerOrderChanged||0===i),(s||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(l(),t.zoom))&&(this.pauseablePlacement=new Ae(t,this.map.terrain,this._order,s,e,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(l()),o=!0),r&&this.pauseablePlacement.placement.setStale()),o||r)for(const t of this._order){const e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(l())}_releaseSymbolFadeTiles(){for(const t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}getImages(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const e=this.tileManagers[i.source];return e&&e.setDependencies(i.tileID.key,i.type,i.icons),t}))}getGlyphs(t,i){return e._(this,void 0,void 0,(function*(){const t=yield this.glyphManager.getGlyphs(i.stacks),e=this.tileManagers[i.source];return e&&e.setDependencies(i.tileID.key,i.type,[""]),t}))}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,i={}){this._checkLoaded(),t&&this._validate(e.F.glyphs,"glyphs",t,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getDashes(t,i){return e._(this,void 0,void 0,(function*(){const t={};for(const[e,n]of Object.entries(i.dashes))t[e]=this.lineAtlas.getDash(n.dasharray,n.round);return t}))}addSprite(t,i,n={},s){this._checkLoaded();const r=[{id:t,url:i}],o=[...p(this.stylesheet.sprite),...r];this._validate(e.F.sprite,"sprite",o,null,n)||(this.stylesheet.sprite=o,this._loadSprite(r,!0,s))}removeSprite(t){this._checkLoaded();const i=p(this.stylesheet.sprite);if(i.find((e=>e.id===t))){if(this._spritesImagesIds[t])for(const e of this._spritesImagesIds[t])this.imageManager.removeImage(e),this._changedImages[e]=!0;i.splice(i.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new e.n("data",{dataType:"style"}))}else this.fire(new e.l(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return p(this.stylesheet.sprite)}setSprite(t,i={},n){this._checkLoaded(),t&&this._validate(e.F.sprite,"sprite",t,null,i)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const t in this.tileManagers){const e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const t in this._layers){const e=this._layers[t];e.setEventedParent(null),e.onRemove&&e.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var ji=e.aS([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Ri{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,e,i,n,s,r,o,a,h){this.context=t;let l=this.boundPaintVertexBuffers.length!==n.length;for(let t=0;!l&&t<n.length;t++)this.boundPaintVertexBuffers[t]!==n[t]&&(l=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||l||this.boundIndexBuffer!==s||this.boundVertexOffset!==r||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==h?this.freshBind(e,i,n,s,r,o,a,h):(t.bindVertexArray.set(this.vao),o&&o.bind(),(null==s?void 0:s.dynamicDraw)&&s.bind(),a&&a.bind(),h&&h.bind())}freshBind(t,e,i,n,s,r,o,a){const h=t.numAttributes,l=this.context,c=l.gl;this.vao&&this.destroy(),this.vao=l.createVertexArray(),l.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=n,this.boundVertexOffset=s,this.boundDynamicVertexBuffer=r,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=a,e.enableAttributes(c,t);for(const e of i)e.enableAttributes(c,t);r&&r.enableAttributes(c,t),o&&o.enableAttributes(c,t),a&&a.enableAttributes(c,t),e.bind(),e.setVertexAttribPointers(c,t,s);for(const e of i)e.bind(),e.setVertexAttribPointers(c,t,s);r&&(r.bind(),r.setVertexAttribPointers(c,t,s)),n&&n.bind(),o&&(o.bind(),o.setVertexAttribPointers(c,t,s)),a&&(a.bind(),a.setVertexAttribPointers(c,t,s)),l.currentNumAttributes=h}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Li=(t,i,n,s,r)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):e.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:r?0:n?n.calculateFogBlendOpacity(s):0,u_horizon_color:n?n.properties.get("horizon-color"):e.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:r?1:0}),Bi={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Ni(t){const e=[];for(const i of t){if(null===i)continue;const t=i.split(" ");e.push(t.pop())}return e}class Ui{constructor(t,i,n,s,r,o,a,h,l=[]){const c=t.gl;this.program=c.createProgram();const u=Ni(i.staticAttributes),f=n?n.getBinderAttributes():[],d=u.concat(f),p=$e.prelude.staticUniforms?Ni($e.prelude.staticUniforms):[],m=a.staticUniforms?Ni(a.staticUniforms):[],_=i.staticUniforms?Ni(i.staticUniforms):[],g=n?n.getBinderUniforms():[],v=p.concat(m).concat(_).concat(g),y=[];for(const t of v)y.includes(t)||y.push(t);const w=n?n.defines():[];oi(c)&&w.unshift("#version 300 es"),r&&w.push("#define OVERDRAW_INSPECTOR;"),o&&w.push("#define TERRAIN3D;"),h&&w.push(h),l&&w.push(...l);let b=w.concat($e.prelude.fragmentSource,a.fragmentSource,i.fragmentSource).join("\n"),x=w.concat($e.prelude.vertexSource,a.vertexSource,i.vertexSource).join("\n");oi(c)||(b=function(t){return t.replace(/\bin\s/g,"varying ").replace("out highp vec4 fragColor;","").replace(/fragColor/g,"gl_FragColor").replace(/texture\(/g,"texture2D(")}(b),x=function(t){return t.replace(/\bin\s/g,"attribute ").replace(/\bout\s/g,"varying ").replace(/texture\(/g,"texture2D(")}(x));const M=c.createShader(c.FRAGMENT_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(M,b),c.compileShader(M),!c.getShaderParameter(M,c.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${c.getShaderInfoLog(M)}`);c.attachShader(this.program,M);const S=c.createShader(c.VERTEX_SHADER);if(c.isContextLost())return void(this.failedToCreate=!0);if(c.shaderSource(S,x),c.compileShader(S),!c.getShaderParameter(S,c.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${c.getShaderInfoLog(S)}`);c.attachShader(this.program,S),this.attributes={};const z={};this.numAttributes=d.length;for(let t=0;t<this.numAttributes;t++)d[t]&&(c.bindAttribLocation(this.program,t,d[t]),this.attributes[d[t]]=t);if(c.linkProgram(this.program),!c.getProgramParameter(this.program,c.LINK_STATUS))throw new Error(`Program failed to link: ${c.getProgramInfoLog(this.program)}`);c.deleteShader(S),c.deleteShader(M);for(const t of y)if(t&&!z[t]){const e=c.getUniformLocation(this.program,t);e&&(z[t]=e)}this.fixedUniforms=s(t,z),this.terrainUniforms=((t,i)=>({u_depth:new e.b_(t,i.u_depth),u_terrain:new e.b_(t,i.u_terrain),u_terrain_dim:new e.bp(t,i.u_terrain_dim),u_terrain_matrix:new e.c0(t,i.u_terrain_matrix),u_terrain_unpack:new e.c1(t,i.u_terrain_unpack),u_terrain_exaggeration:new e.bp(t,i.u_terrain_exaggeration)}))(t,z),this.projectionUniforms=((t,i)=>({u_projection_matrix:new e.c0(t,i.u_projection_matrix),u_projection_tile_mercator_coords:new e.c1(t,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new e.c1(t,i.u_projection_clipping_plane),u_projection_transition:new e.bp(t,i.u_projection_transition),u_projection_fallback_matrix:new e.c0(t,i.u_projection_fallback_matrix)}))(t,z),this.binderUniforms=n?n.getUniforms(t,z):[]}draw(t,e,i,n,s,r,o,a,h,l,c,u,f,d,p,m,_,g,v){var y;const w=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(i),t.setStencilMode(n),t.setColorMode(s),t.setCullFace(r),a){t.activeTexture.set(w.TEXTURE2),w.bindTexture(w.TEXTURE_2D,a.depthTexture),t.activeTexture.set(w.TEXTURE3),w.bindTexture(w.TEXTURE_2D,a.texture);for(const t in this.terrainUniforms)this.terrainUniforms[t].set(a[t])}if(h)for(const t in h)this.projectionUniforms[Bi[t]].set(h[t]);if(o)for(const t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,d,{zoom:p});let b=0;switch(e){case w.LINES:b=2;break;case w.TRIANGLES:b=3;break;case w.LINE_STRIP:b=1}for(const i of f.get())i.vaos||(i.vaos={}),(y=i.vaos)[l]||(y[l]=new Ri),i.vaos[l].bind(t,this,c,m?m.getPaintVertexBuffers():[],u,i.vertexOffset,_,g,v),w.drawElements(e,i.primitiveLength*b,w.UNSIGNED_SHORT,i.primitiveOffset*b*2)}}function Gi(t,i,n){const s=1/e.aK(n,1,i.transform.tileZoom),r=Math.pow(2,n.tileID.overscaledZ),o=n.tileSize*Math.pow(2,i.transform.tileZoom)/r,a=o*(n.tileID.canonical.x+n.tileID.wrap*r),h=o*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[a>>16,h>>16],u_pixel_coord_lower:[65535&a,65535&h]}}const Vi=(t,i,n,s)=>{const r=t.style.light,o=r.properties.get("position"),a=[o.x,o.y,o.z],h=e.c4();"viewport"===r.properties.get("anchor")&&e.c5(h,t.transform.bearingInRadians),e.c6(a,a,h);const l=t.transform.transformLightDirection(a),c=r.properties.get("color");return{u_lightpos:a,u_lightpos_globe:l,u_lightintensity:r.properties.get("intensity"),u_lightcolor:[c.r,c.g,c.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:s}},qi=(t,i,n,s,r,o,a)=>e.e(Vi(t,i,n,s),Gi(o,t,a),{u_height_factor:-Math.pow(2,r.overscaledZ)/a.tileSize/8}),Zi=(t,i,n,s)=>e.e(Gi(i,t,n),{u_fill_translate:s}),Wi=(t,e)=>({u_world:t,u_fill_translate:e}),Hi=(t,i,n,s,r)=>e.e(Zi(t,i,n,r),{u_world:s}),Yi=(t,i,n,s,r)=>{const o=t.transform;let a,h,l=0;if("map"===n.paint.get("circle-pitch-alignment")){const t=e.aK(i,1,o.zoom);a=!0,h=[t,t],l=t/(e.a6*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*r}else a=!1,h=o.pixelsToGLUnits;return{u_camera_to_center_distance:o.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:t.pixelRatio,u_extrude_scale:h,u_globe_extrude_scale:l,u_translate:s}},Xi=t=>({u_pixel_extrude_scale:[1/t.width,1/t.height]}),Ji=t=>({u_viewport_size:[t.width,t.height]}),Ki=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Qi=(t,i,n,s)=>{const r=e.aK(t,1,i)/(e.a6*Math.pow(2,t.tileID.overscaledZ))*2*Math.PI*s;return{u_extrude_scale:e.aK(t,1,i),u_intensity:n,u_globe_extrude_scale:r}},tn=(t,i,n,s)=>{const r=e.O();e.c7(r,0,t.width,t.height,0,0,1);const o=t.context.gl;return{u_matrix:r,u_world:[o.drawingBufferWidth,o.drawingBufferHeight],u_image:n,u_color_ramp:s,u_opacity:i.paint.get("heatmap-opacity")}},en=(t,e,i)=>{const n=i.paint.get("hillshade-accent-color");let s;switch(i.paint.get("hillshade-method")){case"basic":s=4;break;case"combined":s=1;break;case"igor":s=2;break;case"multidirectional":s=3;break;default:s=0}const r=i.getIlluminationProperties();for(let e=0;e<r.directionRadians.length;e++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(r.directionRadians[e]+=t.transform.bearingInRadians);return{u_image:0,u_latrange:sn(0,e.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:r.altitudeRadians,u_azimuths:r.directionRadians,u_accent:n,u_method:s,u_highlights:r.highlightColor,u_shadows:r.shadowColor}},nn=(t,i)=>{const n=i.stride,s=e.O();return e.c7(s,0,e.a6,-e.a6,0,0,1),e.Q(s,s,[0,-e.a6,0]),{u_matrix:s,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ,u_unpack:i.getUnpackVector()}};function sn(t,i){const n=Math.pow(2,i.canonical.z),s=i.canonical.y;return[new e.a7(0,s/n).toLngLat().lat,new e.a7(0,(s+1)/n).toLngLat().lat]}const rn=(t,e,i=0)=>({u_image:0,u_unpack:e.getUnpackVector(),u_dimension:[e.stride,e.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:t.paint.get("color-relief-opacity")}),on=(t,i,n,s)=>{const r=t.transform;return{u_translation:fn(t,i,n),u_ratio:s/e.aK(i,1,r.zoom),u_device_pixel_ratio:t.pixelRatio,u_units_to_pixels:[1/r.pixelsToGLUnits[0],1/r.pixelsToGLUnits[1]]}},an=(t,i,n,s,r)=>e.e(on(t,i,n,s),{u_image:0,u_image_height:r}),hn=(t,i,n,s,r)=>{const o=t.transform,a=un(i,o);return{u_translation:fn(t,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:s/e.aK(i,1,o.zoom),u_device_pixel_ratio:t.pixelRatio,u_image:0,u_scale:[a,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},ln=(t,i,n,s,r)=>{const o=un(i,t.transform);return e.e(on(t,i,n,s),{u_tileratio:o,u_crossfade_from:r.fromScale,u_crossfade_to:r.toScale,u_image:0,u_mix:r.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},cn=(t,i,n,s,r,o)=>{const a=un(i,t.transform);return e.e(on(t,i,n,s),{u_image:0,u_image_height:o,u_tileratio:a,u_crossfade_from:r.fromScale,u_crossfade_to:r.toScale,u_image_dash:1,u_mix:r.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function un(t,i){return 1/e.aK(t,1,i.tileZoom)}function fn(t,i,n){return e.aL(t.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const dn=(t,e,i,n,s)=>{return{u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(o=n.paint.get("raster-saturation"),o>0?1-1/(1.001-o):-o),u_contrast_factor:(r=n.paint.get("raster-contrast"),r>0?1/(1-r):1+r),u_spin_weights:pn(n.paint.get("raster-hue-rotate")),u_coords_top:[s[0].x,s[0].y,s[1].x,s[1].y],u_coords_bottom:[s[3].x,s[3].y,s[2].x,s[2].y]};var r,o};function pn(t){t*=Math.PI/180;const e=Math.sin(t),i=Math.cos(t);return[(2*i+1)/3,(-Math.sqrt(3)*e-i+1)/3,(Math.sqrt(3)*e-i+1)/3]}const mn=(t,e,i,n,s,r,o,a,h,l,c,u,f)=>{const d=o.transform;return{u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:e?e.uSizeT:0,u_size:e?e.uSize:0,u_camera_to_center_distance:d.cameraToCenterDistance,u_pitch:d.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:d.width/d.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:h,u_is_text:+c,u_pitch_with_map:+n,u_is_along_line:s,u_is_variable_anchor:r,u_texsize:u,u_texture:0,u_translation:l,u_pitched_scale:f}},_n=(t,i,n,s,r,o,a,h,l,c,u,f,d,p)=>{const m=a.transform;return e.e(mn(t,i,n,s,r,o,a,h,l,c,u,f,p),{u_gamma_scale:s?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:d?1:0,u_is_plain:1})},gn=(t,i,n,s,r,o,a,h,l,c,u,f,d)=>e.e(_n(t,i,n,s,r,o,a,h,l,c,!0,u,!0,d),{u_texsize_icon:f,u_texture_icon:1}),vn=(t,e)=>({u_opacity:t,u_color:e}),yn=(t,i,n,s,r)=>e.e(function(t,i,n,s){const r=n.imageManager.getPattern(t.from.toString()),o=n.imageManager.getPattern(t.to.toString()),{width:a,height:h}=n.imageManager.getPixelSize(),l=Math.pow(2,s.tileID.overscaledZ),c=s.tileSize*Math.pow(2,n.transform.tileZoom)/l,u=c*(s.tileID.canonical.x+s.tileID.wrap*l),f=c*s.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:r.tl,u_pattern_br_a:r.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,h],u_mix:i.t,u_pattern_size_a:r.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/e.aK(s,1,n.transform.tileZoom),u_pixel_coord_upper:[u>>16,f>>16],u_pixel_coord_lower:[65535&u,65535&f]}}(n,r,i,s),{u_opacity:t}),wn=()=>{},bn={fillExtrusion:(t,i)=>({u_lightpos:new e.c2(t,i.u_lightpos),u_lightpos_globe:new e.c2(t,i.u_lightpos_globe),u_lightintensity:new e.bp(t,i.u_lightintensity),u_lightcolor:new e.c2(t,i.u_lightcolor),u_vertical_gradient:new e.bp(t,i.u_vertical_gradient),u_opacity:new e.bp(t,i.u_opacity),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillExtrusionPattern:(t,i)=>({u_lightpos:new e.c2(t,i.u_lightpos),u_lightpos_globe:new e.c2(t,i.u_lightpos_globe),u_lightintensity:new e.bp(t,i.u_lightintensity),u_lightcolor:new e.c2(t,i.u_lightcolor),u_vertical_gradient:new e.bp(t,i.u_vertical_gradient),u_height_factor:new e.bp(t,i.u_height_factor),u_opacity:new e.bp(t,i.u_opacity),u_fill_translate:new e.c3(t,i.u_fill_translate),u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bp(t,i.u_fade)}),fill:(t,i)=>({u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillPattern:(t,i)=>({u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bp(t,i.u_fade),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillOutline:(t,i)=>({u_world:new e.c3(t,i.u_world),u_fill_translate:new e.c3(t,i.u_fill_translate)}),fillOutlinePattern:(t,i)=>({u_world:new e.c3(t,i.u_world),u_image:new e.b_(t,i.u_image),u_texsize:new e.c3(t,i.u_texsize),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bp(t,i.u_fade),u_fill_translate:new e.c3(t,i.u_fill_translate)}),circle:(t,i)=>({u_camera_to_center_distance:new e.bp(t,i.u_camera_to_center_distance),u_scale_with_map:new e.b_(t,i.u_scale_with_map),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_extrude_scale:new e.c3(t,i.u_extrude_scale),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_globe_extrude_scale:new e.bp(t,i.u_globe_extrude_scale),u_translate:new e.c3(t,i.u_translate)}),collisionBox:(t,i)=>({u_pixel_extrude_scale:new e.c3(t,i.u_pixel_extrude_scale)}),collisionCircle:(t,i)=>({u_viewport_size:new e.c3(t,i.u_viewport_size)}),debug:(t,i)=>({u_color:new e.b$(t,i.u_color),u_overlay:new e.b_(t,i.u_overlay),u_overlay_scale:new e.bp(t,i.u_overlay_scale)}),depth:wn,clippingMask:wn,heatmap:(t,i)=>({u_extrude_scale:new e.bp(t,i.u_extrude_scale),u_intensity:new e.bp(t,i.u_intensity),u_globe_extrude_scale:new e.bp(t,i.u_globe_extrude_scale)}),heatmapTexture:(t,i)=>({u_matrix:new e.c0(t,i.u_matrix),u_world:new e.c3(t,i.u_world),u_image:new e.b_(t,i.u_image),u_color_ramp:new e.b_(t,i.u_color_ramp),u_opacity:new e.bp(t,i.u_opacity)}),hillshade:(t,i)=>({u_image:new e.b_(t,i.u_image),u_latrange:new e.c3(t,i.u_latrange),u_exaggeration:new e.bp(t,i.u_exaggeration),u_altitudes:new e.c9(t,i.u_altitudes),u_azimuths:new e.c9(t,i.u_azimuths),u_accent:new e.b$(t,i.u_accent),u_method:new e.b_(t,i.u_method),u_shadows:new e.c8(t,i.u_shadows),u_highlights:new e.c8(t,i.u_highlights)}),hillshadePrepare:(t,i)=>({u_matrix:new e.c0(t,i.u_matrix),u_image:new e.b_(t,i.u_image),u_dimension:new e.c3(t,i.u_dimension),u_zoom:new e.bp(t,i.u_zoom),u_unpack:new e.c1(t,i.u_unpack)}),colorRelief:(t,i)=>({u_image:new e.b_(t,i.u_image),u_unpack:new e.c1(t,i.u_unpack),u_dimension:new e.c3(t,i.u_dimension),u_elevation_stops:new e.b_(t,i.u_elevation_stops),u_color_stops:new e.b_(t,i.u_color_stops),u_color_ramp_size:new e.b_(t,i.u_color_ramp_size),u_opacity:new e.bp(t,i.u_opacity)}),line:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bp(t,i.u_ratio),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels)}),lineGradient:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bp(t,i.u_ratio),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_image_height:new e.bp(t,i.u_image_height)}),linePattern:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_texsize:new e.c3(t,i.u_texsize),u_ratio:new e.bp(t,i.u_ratio),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_image:new e.b_(t,i.u_image),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_scale:new e.c2(t,i.u_scale),u_fade:new e.bp(t,i.u_fade)}),lineSDF:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bp(t,i.u_ratio),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_mix:new e.bp(t,i.u_mix),u_tileratio:new e.bp(t,i.u_tileratio),u_crossfade_from:new e.bp(t,i.u_crossfade_from),u_crossfade_to:new e.bp(t,i.u_crossfade_to),u_lineatlas_width:new e.bp(t,i.u_lineatlas_width),u_lineatlas_height:new e.bp(t,i.u_lineatlas_height)}),lineGradientSDF:(t,i)=>({u_translation:new e.c3(t,i.u_translation),u_ratio:new e.bp(t,i.u_ratio),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_units_to_pixels:new e.c3(t,i.u_units_to_pixels),u_image:new e.b_(t,i.u_image),u_image_height:new e.bp(t,i.u_image_height),u_tileratio:new e.bp(t,i.u_tileratio),u_crossfade_from:new e.bp(t,i.u_crossfade_from),u_crossfade_to:new e.bp(t,i.u_crossfade_to),u_image_dash:new e.b_(t,i.u_image_dash),u_mix:new e.bp(t,i.u_mix),u_lineatlas_width:new e.bp(t,i.u_lineatlas_width),u_lineatlas_height:new e.bp(t,i.u_lineatlas_height)}),raster:(t,i)=>({u_tl_parent:new e.c3(t,i.u_tl_parent),u_scale_parent:new e.bp(t,i.u_scale_parent),u_buffer_scale:new e.bp(t,i.u_buffer_scale),u_fade_t:new e.bp(t,i.u_fade_t),u_opacity:new e.bp(t,i.u_opacity),u_image0:new e.b_(t,i.u_image0),u_image1:new e.b_(t,i.u_image1),u_brightness_low:new e.bp(t,i.u_brightness_low),u_brightness_high:new e.bp(t,i.u_brightness_high),u_saturation_factor:new e.bp(t,i.u_saturation_factor),u_contrast_factor:new e.bp(t,i.u_contrast_factor),u_spin_weights:new e.c2(t,i.u_spin_weights),u_coords_top:new e.c1(t,i.u_coords_top),u_coords_bottom:new e.c1(t,i.u_coords_bottom)}),symbolIcon:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bp(t,i.u_size_t),u_size:new e.bp(t,i.u_size),u_camera_to_center_distance:new e.bp(t,i.u_camera_to_center_distance),u_pitch:new e.bp(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bp(t,i.u_aspect_ratio),u_fade_change:new e.bp(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texture:new e.b_(t,i.u_texture),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bp(t,i.u_pitched_scale)}),symbolSDF:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bp(t,i.u_size_t),u_size:new e.bp(t,i.u_size),u_camera_to_center_distance:new e.bp(t,i.u_camera_to_center_distance),u_pitch:new e.bp(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bp(t,i.u_aspect_ratio),u_fade_change:new e.bp(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texture:new e.b_(t,i.u_texture),u_gamma_scale:new e.bp(t,i.u_gamma_scale),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_is_halo:new e.b_(t,i.u_is_halo),u_is_plain:new e.b_(t,i.u_is_plain),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bp(t,i.u_pitched_scale)}),symbolTextAndIcon:(t,i)=>({u_is_size_zoom_constant:new e.b_(t,i.u_is_size_zoom_constant),u_is_size_feature_constant:new e.b_(t,i.u_is_size_feature_constant),u_size_t:new e.bp(t,i.u_size_t),u_size:new e.bp(t,i.u_size),u_camera_to_center_distance:new e.bp(t,i.u_camera_to_center_distance),u_pitch:new e.bp(t,i.u_pitch),u_rotate_symbol:new e.b_(t,i.u_rotate_symbol),u_aspect_ratio:new e.bp(t,i.u_aspect_ratio),u_fade_change:new e.bp(t,i.u_fade_change),u_label_plane_matrix:new e.c0(t,i.u_label_plane_matrix),u_coord_matrix:new e.c0(t,i.u_coord_matrix),u_is_text:new e.b_(t,i.u_is_text),u_pitch_with_map:new e.b_(t,i.u_pitch_with_map),u_is_along_line:new e.b_(t,i.u_is_along_line),u_is_variable_anchor:new e.b_(t,i.u_is_variable_anchor),u_texsize:new e.c3(t,i.u_texsize),u_texsize_icon:new e.c3(t,i.u_texsize_icon),u_texture:new e.b_(t,i.u_texture),u_texture_icon:new e.b_(t,i.u_texture_icon),u_gamma_scale:new e.bp(t,i.u_gamma_scale),u_device_pixel_ratio:new e.bp(t,i.u_device_pixel_ratio),u_is_halo:new e.b_(t,i.u_is_halo),u_translation:new e.c3(t,i.u_translation),u_pitched_scale:new e.bp(t,i.u_pitched_scale)}),background:(t,i)=>({u_opacity:new e.bp(t,i.u_opacity),u_color:new e.b$(t,i.u_color)}),backgroundPattern:(t,i)=>({u_opacity:new e.bp(t,i.u_opacity),u_image:new e.b_(t,i.u_image),u_pattern_tl_a:new e.c3(t,i.u_pattern_tl_a),u_pattern_br_a:new e.c3(t,i.u_pattern_br_a),u_pattern_tl_b:new e.c3(t,i.u_pattern_tl_b),u_pattern_br_b:new e.c3(t,i.u_pattern_br_b),u_texsize:new e.c3(t,i.u_texsize),u_mix:new e.bp(t,i.u_mix),u_pattern_size_a:new e.c3(t,i.u_pattern_size_a),u_pattern_size_b:new e.c3(t,i.u_pattern_size_b),u_scale_a:new e.bp(t,i.u_scale_a),u_scale_b:new e.bp(t,i.u_scale_b),u_pixel_coord_upper:new e.c3(t,i.u_pixel_coord_upper),u_pixel_coord_lower:new e.c3(t,i.u_pixel_coord_lower),u_tile_units_to_pixels:new e.bp(t,i.u_tile_units_to_pixels)}),terrain:(t,i)=>({u_texture:new e.b_(t,i.u_texture),u_ele_delta:new e.bp(t,i.u_ele_delta),u_fog_matrix:new e.c0(t,i.u_fog_matrix),u_fog_color:new e.b$(t,i.u_fog_color),u_fog_ground_blend:new e.bp(t,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new e.bp(t,i.u_fog_ground_blend_opacity),u_horizon_color:new e.b$(t,i.u_horizon_color),u_horizon_fog_blend:new e.bp(t,i.u_horizon_fog_blend),u_is_globe_mode:new e.bp(t,i.u_is_globe_mode)}),terrainDepth:(t,i)=>({u_ele_delta:new e.bp(t,i.u_ele_delta)}),terrainCoords:(t,i)=>({u_texture:new e.b_(t,i.u_texture),u_terrain_coords_id:new e.bp(t,i.u_terrain_coords_id),u_ele_delta:new e.bp(t,i.u_ele_delta)}),projectionErrorMeasurement:(t,i)=>({u_input:new e.bp(t,i.u_input),u_output_expected:new e.bp(t,i.u_output_expected)}),atmosphere:(t,i)=>({u_sun_pos:new e.c2(t,i.u_sun_pos),u_atmosphere_blend:new e.bp(t,i.u_atmosphere_blend),u_globe_position:new e.c2(t,i.u_globe_position),u_globe_radius:new e.bp(t,i.u_globe_radius),u_inv_proj_matrix:new e.c0(t,i.u_inv_proj_matrix)}),sky:(t,i)=>({u_sky_color:new e.b$(t,i.u_sky_color),u_horizon_color:new e.b$(t,i.u_horizon_color),u_horizon:new e.c3(t,i.u_horizon),u_horizon_normal:new e.c3(t,i.u_horizon_normal),u_sky_horizon_blend:new e.bp(t,i.u_sky_horizon_blend),u_sky_blend:new e.bp(t,i.u_sky_blend)})};class xn{constructor(t,e,i){this.context=t;const n=t.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const e=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),e.bufferSubData(e.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Mn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Sn{constructor(t,e,i,n){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=n,this.context=t;const s=t.gl;this.buffer=s.createBuffer(),t.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(const i of this.attributes){const n=e.attributes[i.name];void 0!==n&&t.enableVertexAttribArray(n)}}setVertexAttribPointers(t,e,i){for(const n of this.attributes){const s=e.attributes[n.name];void 0!==s&&t.vertexAttribPointer(s,n.components,t[Mn[n.type]],!1,this.itemSize,n.offset+this.itemSize*(i||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class zn{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Tn extends zn{getDefault(){return e.bo.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class En extends zn{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class An extends zn{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Pn extends zn{getDefault(){return[!0,!0,!0,!0]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Cn extends zn{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Dn extends zn{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class Fn extends zn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){const e=this.current;(t.func!==e.func||t.ref!==e.ref||t.mask!==e.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class In extends zn{getDefault(){const t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class kn extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}}class $n extends zn{getDefault(){return[0,1]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class On extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}}class jn extends zn{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class Rn extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}}class Ln extends zn{getDefault(){const t=this.gl;return[t.ONE,t.ZERO]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Bn extends zn{getDefault(){return e.bo.transparent}set(t){const e=this.current;(t.r!==e.r||t.g!==e.g||t.b!==e.b||t.a!==e.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Nn extends zn{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class Un extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}}class Gn extends zn{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Vn extends zn{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class qn extends zn{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Zn extends zn{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class Wn extends zn{getDefault(){const t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){const e=this.current;(t[0]!==e[0]||t[1]!==e[1]||t[2]!==e[2]||t[3]!==e[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class Hn extends zn{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class Yn extends zn{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class Xn extends zn{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class Jn extends zn{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Kn extends zn{getDefault(){return null}set(t){const e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Qn extends zn{getDefault(){return null}set(t){var e;if(t===this.current&&!this.dirty)return;const i=this.gl;oi(i)?i.bindVertexArray(t):null===(e=i.getExtension("OES_vertex_array_object"))||void 0===e||e.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class ts extends zn{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class es extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class is extends zn{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;const e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class ns extends zn{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}}class ss extends ns{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class rs extends ns{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class os extends ns{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}}const as="Framebuffer is not complete";class hs{constructor(t,e,i,n,s){this.context=t,this.width=e,this.height=i;const r=t.gl,o=this.framebuffer=r.createFramebuffer();if(this.colorAttachment=new ss(t,o),n)this.depthAttachment=s?new os(t,o):new rs(t,o);else if(s)throw new Error("Stencil cannot be set without depth");if(r.checkFramebufferStatus(r.FRAMEBUFFER)!==r.FRAMEBUFFER_COMPLETE)throw new Error(as)}destroy(){const t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){const e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}}class ls{constructor(t){var e,i;if(this.gl=t,this.clearColor=new Tn(this),this.clearDepth=new En(this),this.clearStencil=new An(this),this.colorMask=new Pn(this),this.depthMask=new Cn(this),this.stencilMask=new Dn(this),this.stencilFunc=new Fn(this),this.stencilOp=new In(this),this.stencilTest=new kn(this),this.depthRange=new $n(this),this.depthTest=new On(this),this.depthFunc=new jn(this),this.blend=new Rn(this),this.blendFunc=new Ln(this),this.blendColor=new Bn(this),this.blendEquation=new Nn(this),this.cullFace=new Un(this),this.cullFaceSide=new Gn(this),this.frontFace=new Vn(this),this.program=new qn(this),this.activeTexture=new Zn(this),this.viewport=new Wn(this),this.bindFramebuffer=new Hn(this),this.bindRenderbuffer=new Yn(this),this.bindTexture=new Xn(this),this.bindVertexBuffer=new Jn(this),this.bindElementBuffer=new Kn(this),this.bindVertexArray=new Qn(this),this.pixelStoreUnpack=new ts(this),this.pixelStoreUnpackPremultiplyAlpha=new es(this),this.pixelStoreUnpackFlipY=new is(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),oi(t)){this.HALF_FLOAT=t.HALF_FLOAT;const n=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=null!==(e=t.RGBA16F)&&void 0!==e?e:null==n?void 0:n.RGBA16F_EXT,this.RGB16F=null!==(i=t.RGB16F)&&void 0!==i?i:null==n?void 0:n.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");const e=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=null==e?void 0:e.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,e){return new xn(this,t,e)}createVertexBuffer(t,e,i){return new Sn(this,t,e,i)}createRenderbuffer(t,e,i){const n=this.gl,s=n.createRenderbuffer();return this.bindRenderbuffer.set(s),n.renderbufferStorage(n.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),s}createFramebuffer(t,e,i,n){return new hs(this,t,e,i,n)}clear({color:t,depth:e,stencil:i}){const n=this.gl;let s=0;t&&(s|=n.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(s|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(s|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.clear(s)}setCullFace(t){!1===t.enable?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){e.bQ(t.blendFunction,ti.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return oi(this.gl)?this.gl.createVertexArray():null===(t=this.gl.getExtension("OES_vertex_array_object"))||void 0===t?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var e;oi(this.gl)?this.gl.deleteVertexArray(t):null===(e=this.gl.getExtension("OES_vertex_array_object"))||void 0===e||e.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}let cs;function us(t,i,n,s,r){var o,a;const h=t.context,l=t.transform,c=h.gl,u=t.useProgram("collisionBox"),f=[];let d=0,p=0;for(const e of s){const s=i.getTile(e).getBucket(n);if(!s)continue;const a=r?s.textCollisionBox:s.iconCollisionBox,m=s.collisionCircleArray;m.length>0&&(f.push({circleArray:m,circleOffset:p,coord:e}),d+=m.length/4,p=d),a&&u.draw(h,c.LINES,ni.disabled,ri.disabled,t.colorModeForRenderPass(),ii.disabled,Xi(t.transform),null===(o=t.style.map.terrain)||void 0===o?void 0:o.getTerrainData(e),l.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,null,t.transform.zoom,null,null,a.collisionVertexBuffer)}if(!r||!f.length)return;const m=t.useProgram("collisionCircle"),_=new e.ca;_.resize(4*d),_._trim();let g=0;for(const t of f)for(let e=0;e<t.circleArray.length/4;e++){const i=4*e,n=t.circleArray[i+0],s=t.circleArray[i+1],r=t.circleArray[i+2],o=t.circleArray[i+3];_.emplace(g++,n,s,r,o,0),_.emplace(g++,n,s,r,o,1),_.emplace(g++,n,s,r,o,2),_.emplace(g++,n,s,r,o,3)}(!cs||cs.length<2*d)&&(cs=function(t){const i=2*t,n=new e.cc;n.resize(i),n._trim();for(let t=0;t<i;t++){const e=6*t;n.uint16[e+0]=4*t+0,n.uint16[e+1]=4*t+1,n.uint16[e+2]=4*t+2,n.uint16[e+3]=4*t+2,n.uint16[e+4]=4*t+3,n.uint16[e+5]=4*t+0}return n}(d));const v=h.createIndexBuffer(cs,!0),y=h.createVertexBuffer(_,e.cb.members,!0);for(const i of f){const s=Ji(t.transform);m.draw(h,c.TRIANGLES,ni.disabled,ri.disabled,t.colorModeForRenderPass(),ii.disabled,s,null===(a=t.style.map.terrain)||void 0===a?void 0:a.getTerrainData(i.coord),null,n.id,y,v,e.aV.simpleSegment(0,2*i.circleOffset,i.circleArray.length,i.circleArray.length/2),null,t.transform.zoom,null,null,null)}y.destroy(),v.destroy()}const fs=e.ap(new Float32Array(16));function ds(t,i,n,s,r,o){const{horizontalAlign:a,verticalAlign:h}=e.aP(t);return new e.P((-(a-.5)*i/r+s[0])*o,(-(h-.5)*n/r+s[1])*o)}function ps(t,i,n,s,r,o){const a=i.tileAnchorPoint.add(new e.P(i.translation[0],i.translation[1]));if(i.pitchWithMap){let t=s.mult(o);n||(t=t.rotate(-r));const e=a.add(t);return Vt(e.x,e.y,i.pitchedLabelPlaneMatrix,i.getElevation).point}if(n){const e=Qt(i.tileAnchorPoint.x+1,i.tileAnchorPoint.y,i).point.sub(t),n=Math.atan(e.y/e.x)+(e.x<0?Math.PI:0);return t.add(s.rotate(n))}return t.add(s)}function ms(t,i,n,s,r,o,a,h,l,c,u,f){const d=t.text.placedSymbolArray,p=t.text.dynamicLayoutVertexArray,m=t.icon.dynamicLayoutVertexArray,_={};p.clear();for(let m=0;m<d.length;m++){const g=d.get(m),v=g.hidden||!g.crossTileID||t.allowVerticalPlacement&&!g.placedOrientation?null:s[g.crossTileID];if(v){const s=new e.P(g.anchorX,g.anchorY),d={getElevation:f,width:r.width,height:r.height,pitchedLabelPlaneMatrix:o,pitchWithMap:n,transform:r,tileAnchorPoint:s,translation:c,unwrappedTileID:u},m=n?ee(s.x,s.y,d):Qt(s.x,s.y,d),y=qt(r.cameraToCenterDistance,m.signedDistanceFromCamera);let w=e.ay(t.textSizeData,h,g)*y/e.aJ;n&&(w*=t.tilePixelRatio/a);const{width:b,height:x,anchor:M,textOffset:S,textBoxScale:z}=v,T=ds(M,b,x,S,z,w),E=r.getPitchedTextCorrection(s.x+c[0],s.y+c[1],u),A=ps(m.point,d,i,T,-r.bearingInRadians,E),P=t.allowVerticalPlacement&&g.placedOrientation===e.ax.vertical?Math.PI/2:0;for(let t=0;t<g.numGlyphs;t++)e.aD(p,A,P);l&&g.associatedIconIndex>=0&&(_[g.associatedIconIndex]={shiftedAnchor:A,angle:P})}else oe(g.numGlyphs,p)}if(l){m.clear();const i=t.icon.placedSymbolArray;for(let t=0;t<i.length;t++){const n=i.get(t);if(n.hidden)oe(n.numGlyphs,m);else{const i=_[t];if(i)for(let t=0;t<n.numGlyphs;t++)e.aD(m,i.shiftedAnchor,i.angle);else oe(n.numGlyphs,m)}}t.icon.dynamicLayoutVertexBuffer.updateData(m)}t.text.dynamicLayoutVertexBuffer.updateData(p)}function _s(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function gs(t,i,n,s,r,o,a,h,l,c,u,f,d){var p,m;const _=t.context,g=_.gl,v=t.transform,y="map"===h,w="map"===l,b="viewport"!==h&&"point"!==n.layout.get("symbol-placement"),x=y&&!w&&!b,M=!n.layout.get("symbol-sort-key").isConstant();let S=!1;const z=t.getDepthModeForSublayer(0,ni.ReadOnly),T=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[],A=v.getCircleRadiusCorrection();for(const h of s){const s=i.getTile(h),l=s.getBucket(n);if(!l)continue;const u=r?l.text:l.icon;if(!(null==u?void 0:u.segments.get().length)||!u.hasVisibleVertices)continue;const f=u.programConfigurations.get(n.id),m=r||l.sdfIcons,_=r?l.textSizeData:l.iconSizeData,z=w||0!==v.pitch,P=t.useProgram(_s(m,r,l),f),C=e.aw(_,v.zoom),D=null===(p=t.style.map.terrain)||void 0===p?void 0:p.getTerrainData(h);let F,I,k,$,O=[0,0],j=null;if(r)I=s.glyphAtlasTexture,k=g.LINEAR,F=s.glyphAtlasTexture.size,l.iconsInText&&(O=s.imageAtlasTexture.size,j=s.imageAtlasTexture,$=z||t.options.rotating||t.options.zooming||"composite"===_.kind||"camera"===_.kind?g.LINEAR:g.NEAREST);else{const e=1!==n.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;I=s.imageAtlasTexture,k=m||t.options.rotating||t.options.zooming||e||z?g.LINEAR:g.NEAREST,F=s.imageAtlasTexture.size}const R=e.aK(s,1,t.transform.zoom),L=Nt(y,t.transform,R),B=Ut(w,y,t.transform,R),N=e.aL(v,s,o,a),U=v.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!d,applyTerrainMatrix:!0}),G=T&&l.hasTextData(),V="none"!==n.layout.get("icon-text-fit")&&G&&l.hasIconData();if(b){const i=e.O();Lt(i,L);const s=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(h,e,i):null,o="map"===n.layout.get("text-rotation-alignment");Wt(l,t,r,L,i,w,c,o,h.toUnwrapped(),v.width,v.height,N,s)}const q=r&&T||V,Z=b||q?fs:w?L:t.transform.clipSpaceToPixelsMatrix,W=m&&0!==n.paint.get(r?"text-halo-width":"icon-halo-width").constantOr(1);let H;H=m?l.iconsInText?gn(_.kind,C,x,w,b,q,t,Z,B,N,F,O,A):_n(_.kind,C,x,w,b,q,t,Z,B,N,r,F,W,A):mn(_.kind,C,x,w,b,q,t,Z,B,N,r,F,A);const Y={program:P,buffers:u,uniformValues:H,projectionData:U,atlasTexture:I,atlasTextureIcon:j,atlasInterpolation:k,atlasInterpolationIcon:$,isSDF:m,hasHalo:W};if(M&&l.canOverlap){S=!0;const t=u.segments.get();for(const i of t)E.push({segments:new e.aV([i]),sortKey:i.sortKey,state:Y,terrainData:D})}else E.push({segments:u.segments,sortKey:0,state:Y,terrainData:D})}S&&E.sort(((t,e)=>t.sortKey-e.sortKey));const P=null!==(m=n.paint.get(r?"text-halo-width":"icon-halo-width").constantOr(null))&&void 0!==m?m:1/0,C=n.layout.get("text-letter-spacing").constantOr(0)*e.aJ<0||P>1;for(const e of E){const i=e.state;_.activeTexture.set(g.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,g.CLAMP_TO_EDGE),i.atlasTextureIcon&&(_.activeTexture.set(g.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,g.CLAMP_TO_EDGE));const s=i.isSDF&&i.hasHalo;if(s){const s=i.uniformValues;s.u_is_halo=1,C&&(s.u_is_plain=0,vs(i.buffers,e.segments,n,t,i.program,z,u,f,s,i.projectionData,e.terrainData),s.u_is_halo=0,s.u_is_plain=1)}vs(i.buffers,e.segments,n,t,i.program,z,u,f,i.uniformValues,i.projectionData,e.terrainData),s&&!C&&(i.uniformValues.u_is_halo=0)}}function vs(t,e,i,n,s,r,o,a,h,l,c){const u=n.context;s.draw(u,u.gl.TRIANGLES,r,o,a,ii.backCCW,h,c,l,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,n.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ys(t,i,n,s,r){const o=t.context,a=o.gl,h=ri.disabled,l=new ti([a.ONE,a.ONE],e.bo.transparent,[!0,!0,!0,!0]),c=i.getBucket(n);if(!c)return;const u=s.key;let f=n.heatmapFbos.get(u);f||(f=bs(o,i.tileSize,i.tileSize),n.heatmapFbos.set(u,f)),o.bindFramebuffer.set(f.framebuffer),o.viewport.set([0,0,i.tileSize,i.tileSize]),o.clear({color:e.bo.transparent});const d=c.programConfigurations.get(n.id),p=t.useProgram("heatmap",d,!r),m=t.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),_=t.style.map.terrain.getTerrainData(s);p.draw(o,a.TRIANGLES,ni.disabled,h,l,ii.disabled,Qi(i,t.transform.zoom,n.paint.get("heatmap-intensity"),1),_,m,n.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,n.paint,t.transform.zoom,d)}function ws(t,e,i,n,s){const r=t.context,o=r.gl,a=t.transform;r.setColorMode(t.colorModeForRenderPass());const h=xs(r,e),l=i.key,c=e.heatmapFbos.get(l);if(!c)return;r.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,c.colorAttachment.get()),r.activeTexture.set(o.TEXTURE1),h.bind(o.LINEAR,o.CLAMP_TO_EDGE);const u=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:s,applyGlobeMatrix:!n});t.useProgram("heatmapTexture").draw(r,o.TRIANGLES,ni.disabled,ri.disabled,t.colorModeForRenderPass(),ii.disabled,tn(t,e,0,1),null,u,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),c.destroy(),e.heatmapFbos.delete(l)}function bs(t,e,i){var n,s;const r=t.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR);const a=null!==(n=t.HALF_FLOAT)&&void 0!==n?n:r.UNSIGNED_BYTE,h=null!==(s=t.RGBA16F)&&void 0!==s?s:r.RGBA;r.texImage2D(r.TEXTURE_2D,0,h,e,i,0,r.RGBA,a,null);const l=t.createFramebuffer(e,i,!1,!1);return l.colorAttachment.set(o),l}function xs(t,i){return i.colorRampTexture||(i.colorRampTexture=new e.T(t,i.colorRamp,t.gl.RGBA)),i.colorRampTexture}function Ms(t,i,n,s,r,o,a,h){let l=256;if(r.stepInterpolant){const s=i.getSource().maxzoom,r=a.canonical.z===s?Math.ceil(1<<t.transform.maxZoom-a.canonical.z):1;l=e.al(e.ce(o.maxLineLength/e.a6*1024*r),256,n.maxTextureSize)}return h.gradient=e.cf({expression:r.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:h.gradient||void 0,clips:o.lineClipsArray}),h.texture?h.texture.update(h.gradient):h.texture=new e.T(n,h.gradient,s.RGBA),h.version=r.gradientVersion,h.texture}function Ss(t,e,i,n,s){t.activeTexture.set(e.TEXTURE0),i.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),n.updatePaintBuffers(s)}function zs(t,e,i,n,s,r){(s||t.lineAtlas.dirty)&&(e.activeTexture.set(i.TEXTURE0),t.lineAtlas.bind(e)),n.updatePaintBuffers(r)}function Ts(t,e,i,n,s,r,o){const a=r.gradients[s.id];let h=a.texture;s.gradientVersion!==a.version&&(h=Ms(t,e,i,n,s,r,o,a)),i.activeTexture.set(n.TEXTURE0),h.bind(s.stepInterpolant?n.NEAREST:n.LINEAR,n.CLAMP_TO_EDGE)}function Es(t,e,i,n,s,r,o,a,h){const l=r.gradients[s.id];let c=l.texture;s.gradientVersion!==l.version&&(c=Ms(t,e,i,n,s,r,o,l)),i.activeTexture.set(n.TEXTURE0),c.bind(s.stepInterpolant?n.NEAREST:n.LINEAR,n.CLAMP_TO_EDGE),i.activeTexture.set(n.TEXTURE1),t.lineAtlas.bind(i),a.updatePaintBuffers(h)}function As(t,e,i,n,s){if(!i||!(null==n?void 0:n.imageAtlas))return;const r=n.imageAtlas.patternPositions;let o=r[i.to.toString()],a=r[i.from.toString()];if(!o&&a&&(o=a),!a&&o&&(a=o),!o||!a){const t=s.getPaintProperty(e);o=r[t],a=r[t]}o&&a&&t.setConstantPatternPositions(o,a)}function Ps(t,i,n,s,r,o,a,h){var l;const c=t.context.gl,u="fill-pattern",f=n.paint.get(u),d=null==f?void 0:f.constantOr(1),p=n.getCrossfadeParameters();let m,_,g,v,y;const w=t.transform,b=n.paint.get("fill-translate"),x=n.paint.get("fill-translate-anchor");a?(_=d&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",m=c.LINES):(_=d?"fillPattern":"fill",m=c.TRIANGLES);const M=f.constantOr(null);for(const f of s){const s=i.getTile(f);if(d&&!s.patternsLoaded())continue;const S=s.getBucket(n);if(!S)continue;const z=S.programConfigurations.get(n.id),T=t.useProgram(_,z),E=null===(l=t.style.map.terrain)||void 0===l?void 0:l.getTerrainData(f);d&&(t.context.activeTexture.set(c.TEXTURE0),s.imageAtlasTexture.bind(c.LINEAR,c.CLAMP_TO_EDGE),z.updatePaintBuffers(p)),As(z,u,M,s,n);const A=w.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!h,applyTerrainMatrix:!0}),P=e.aL(w,s,b,x);if(a){v=S.indexBuffer2,y=S.segments2;const e=[c.drawingBufferWidth,c.drawingBufferHeight];g="fillOutlinePattern"===_&&d?Hi(t,p,s,e,P):Wi(e,P)}else v=S.indexBuffer,y=S.segments,g=d?Zi(t,p,s,P):{u_fill_translate:P};const C=t.stencilModeForClipping(f);T.draw(t.context,m,r,C,o,ii.backCCW,g,E,A,n.id,S.layoutVertexBuffer,v,y,n.paint,t.transform.zoom,z)}}function Cs(t,i,n,s,r,o,a,h){var l;const c=t.context,u=c.gl,f="fill-extrusion-pattern",d=n.paint.get(f),p=d.constantOr(1),m=n.getCrossfadeParameters(),_=n.paint.get("fill-extrusion-opacity"),g=d.constantOr(null),v=t.transform;for(const d of s){const s=i.getTile(d),y=s.getBucket(n);if(!y)continue;const w=null===(l=t.style.map.terrain)||void 0===l?void 0:l.getTerrainData(d),b=y.programConfigurations.get(n.id),x=t.useProgram(p?"fillExtrusionPattern":"fillExtrusion",b);p&&(t.context.activeTexture.set(u.TEXTURE0),s.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),b.updatePaintBuffers(m));const M=v.getProjectionData({overscaledTileID:d,applyGlobeMatrix:!h,applyTerrainMatrix:!0});As(b,f,g,s,n);const S=e.aL(v,s,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),z=n.paint.get("fill-extrusion-vertical-gradient"),T=p?qi(t,z,_,S,d,m,s):Vi(t,z,_,S);x.draw(c,c.gl.TRIANGLES,r,o,a,ii.backCCW,T,w,M,n.id,y.layoutVertexBuffer,y.indexBuffer,y.segments,n.paint,t.transform.zoom,b,t.style.map.terrain&&y.centroidVertexBuffer)}}function Ds(t,e,i,n,s,r,o,a,h){var l;const c=t.style.projection,u=t.context,f=t.transform,d=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],m=t.useProgram("hillshade",null,!1,p),_=!t.options.moving;for(const p of n){const n=e.getTile(p),g=n.fbo;if(!g)continue;const v=c.getMeshFromTileID(u,p.canonical,a,!0,"raster"),y=null===(l=t.style.map.terrain)||void 0===l?void 0:l.getTerrainData(p);u.activeTexture.set(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,g.colorAttachment.get());const w=f.getProjectionData({overscaledTileID:p,aligned:_,applyGlobeMatrix:!h,applyTerrainMatrix:!0});m.draw(u,d.TRIANGLES,r,s[p.overscaledZ],o,ii.backCCW,en(t,n,i),y,w,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}}let Fs=0;function Is(t,i,n,s,r,o,a,h,l){var c;const u=t.style.projection,f=t.context,d=t.transform,p=f.gl,m=t.useProgram("colorRelief"),_=!t.options.moving,g="nearest"===n.paint.get("resampling")?p.NEAREST:p.LINEAR;let v=!0,y=0;for(const w of s){const s=i.getTile(w),b=s.dem;if(v){Fs||(Fs=p.getParameter(p.MAX_TEXTURE_SIZE));const t=Fs,{elevationTexture:e,colorTexture:i}=n.getColorRampTextures(f,t,b.getUnpackVector());f.activeTexture.set(p.TEXTURE1),e.bind(p.NEAREST,p.CLAMP_TO_EDGE),f.activeTexture.set(p.TEXTURE4),i.bind(p.LINEAR,p.CLAMP_TO_EDGE),v=!1,y=e.size[0]}if(!(null==b?void 0:b.data))continue;const x=b.stride,M=b.getPixels();if(f.activeTexture.set(p.TEXTURE0),f.pixelStoreUnpackPremultiplyAlpha.set(!1),s.demTexture||(s.demTexture=t.getTileTexture(x)),s.demTexture){const t=s.demTexture;t.update(M,{premultiply:!1}),t.bind(g,p.CLAMP_TO_EDGE)}else s.demTexture=new e.T(f,M,p.RGBA,{premultiply:!1}),s.demTexture.bind(g,p.CLAMP_TO_EDGE);const S=u.getMeshFromTileID(f,w.canonical,h,!0,"raster"),z=null===(c=t.style.map.terrain)||void 0===c?void 0:c.getTerrainData(w),T=d.getProjectionData({overscaledTileID:w,aligned:_,applyGlobeMatrix:!l,applyTerrainMatrix:!0});m.draw(f,p.TRIANGLES,o,r[w.overscaledZ],a,ii.backCCW,rn(n,s.dem,y),z,T,n.id,S.vertexBuffer,S.indexBuffer,S.segments)}}const ks=[new e.P(0,0),new e.P(e.a6,0),new e.P(e.a6,e.a6),new e.P(0,e.a6)];function $s(t,e,i,n,s,r,o,a,h=!1,l=!1){var c;const u=n[n.length-1].overscaledZ,f=t.context,d=f.gl,p=t.useProgram("raster"),m=t.transform,_=t.style.projection,g=t.colorModeForRenderPass(),v=!t.options.moving,y=i.paint.get("raster-opacity"),w="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR,b=i.paint.get("raster-fade-duration"),x=!!t.style.map.terrain;for(const M of n){const n=t.getDepthModeForSublayer(M.overscaledZ-u,1===y?ni.ReadWrite:ni.ReadOnly,d.LESS),S=e.getTile(M);f.activeTexture.set(d.TEXTURE0),S.texture.bind(w,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),f.activeTexture.set(d.TEXTURE1);const{parentTile:z,parentScaleBy:T,parentTopLeft:E,fadeValues:A}=Os(S,e,b,x);S.fadeOpacity=A.tileOpacity,z?(z.fadeOpacity=A.parentTileOpacity,z.texture.bind(w,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)):S.texture.bind(w,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),S.texture.useMipmap&&f.extTextureFilterAnisotropic&&t.transform.pitch>t.options.anisotropicFilterPitch&&d.texParameterf(d.TEXTURE_2D,f.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,f.extTextureFilterAnisotropicMax);const P=null===(c=t.style.map.terrain)||void 0===c?void 0:c.getTerrainData(M),C=m.getProjectionData({overscaledTileID:M,aligned:v,applyGlobeMatrix:!l,applyTerrainMatrix:!0}),D=dn(E,T,A.fadeMix,i,a),F=_.getMeshFromTileID(f,M.canonical,r,o,"raster");p.draw(f,d.TRIANGLES,n,s?s[M.overscaledZ]:ri.disabled,g,h?ii.frontCCW:ii.backCCW,D,P,C,i.id,F.vertexBuffer,F.indexBuffer,F.segments)}}function Os(t,i,n,s){const r={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===n||s)return r;if(t.fadingParentID){const s=i.getLoadedTile(t.fadingParentID);if(!s)return r;const o=Math.pow(2,s.tileID.overscaledZ-t.tileID.overscaledZ),a=[t.tileID.canonical.x*o%1,t.tileID.canonical.y*o%1],h=function(t,i,n){const s=l(),r=(s-i.timeAdded)/n,o=t.fadingDirection===ut.Incoming,a=e.al((s-t.timeAdded)/n,0,1),h=e.al(1-r,0,1),c=o?a:h;return{tileOpacity:c,parentTileOpacity:o?h:a,fadeMix:{opacity:1,mix:1-c}}}(t,s,n);return{parentTile:s,parentScaleBy:o,parentTopLeft:a,fadeValues:h}}if(t.selfFading){const i=function(t,i){const n=(l()-t.timeAdded)/i,s=e.al(n,0,1);return{tileOpacity:s,fadeMix:{opacity:s,mix:0}}}(t,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return r}const js=new e.bo(1,0,0,1),Rs=new e.bo(0,1,0,1),Ls=new e.bo(0,0,1,1),Bs=new e.bo(1,0,1,1),Ns=new e.bo(0,1,1,1);function Us(t,e,i,n){Vs(t,0,e+i/2,t.transform.width,i,n)}function Gs(t,e,i,n){Vs(t,e-i/2,0,i,t.transform.height,n)}function Vs(t,e,i,n,s,r){const o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,n*t.pixelRatio,s*t.pixelRatio),o.clear({color:r}),a.disable(a.SCISSOR_TEST)}function qs(t,i,n){var s;const r=t.context,o=r.gl,a=t.useProgram("debug"),h=ni.disabled,l=ri.disabled,c=t.colorModeForRenderPass(),u="$debug",f=null===(s=t.style.map.terrain)||void 0===s?void 0:s.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor(((null==d?void 0:d.byteLength)||0)/1024),m=i.getTile(n).tileSize,_=512/Math.min(m,512)*(n.overscaledZ/t.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();const i=t.debugOverlayCanvas,n=t.context.gl,s=t.debugOverlayCanvas.getContext("2d");s.clearRect(0,0,i.width,i.height),s.shadowColor="white",s.shadowBlur=2,s.lineWidth=1.5,s.strokeStyle="white",s.textBaseline="top",s.font="bold 36px Open Sans, sans-serif",s.fillText(e,5,5),s.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}(t,`${g} ${p}kB`);const v=t.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});a.draw(r,o.TRIANGLES,h,l,ti.alphaBlended,ii.disabled,Ki(e.bo.transparent,_),null,v,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),a.draw(r,o.LINE_STRIP,h,l,c,ii.disabled,Ki(e.bo.red),f,v,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function Zs(t,e,i,n){const{isRenderingGlobe:s}=n,r=t.context,o=r.gl,a=t.transform,h=t.colorModeForRenderPass(),l=t.getDepthModeFor3D(),c=t.useProgram("terrain");r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height]);for(const n of i){const i=e.getTerrainMesh(n.tileID),u=t.renderToTexture.getTexture(n),f=e.getTerrainData(n.tileID);r.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.texture);const d=e.getMeshFrameDelta(a.zoom),p=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Li(d,p,t.style.sky,a.pitch,s),_=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});c.draw(r,o.TRIANGLES,l,ri.disabled,h,ii.backCCW,m,f,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Ws(t,i){if(!i.mesh){const n=new e.aU;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const s=new e.aW;s.emplaceBack(0,1,2),s.emplaceBack(0,2,3),i.mesh=new je(t.createVertexBuffer(n,Re.members),t.createIndexBuffer(s),e.aV.simpleSegment(0,0,n.length,s.length))}return i.mesh}const Hs={symbol:function(t,i,n,s,r,o){if("translucent"!==t.renderPass)return;const{isRenderingToTexture:a}=o,h=ri.disabled,l=t.colorModeForRenderPass();(n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,i,n,s,r,o,a,h,l){var c;const u=i.transform,f=i.style.map.terrain,d="map"===r,p="map"===o;for(const r of t){const t=s.getTile(r),o=t.getBucket(n);if(!(null===(c=null==o?void 0:o.text)||void 0===c?void 0:c.segments.get().length))continue;const m=e.aw(o.textSizeData,u.zoom),_=e.aK(t,1,i.transform.zoom),g=Nt(d,i.transform,_),v="none"!==n.layout.get("icon-text-fit")&&o.hasIconData();if(m){const i=Math.pow(2,u.zoom-t.tileID.overscaledZ),n=f?(t,e)=>f.getElevation(r,t,e):null;ms(o,d,p,l,u,g,i,m,v,e.aL(u,t,a,h),r.toUnwrapped(),n)}}}(s,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),r),0!==n.paint.get("icon-opacity").constantOr(1)&&gs(t,i,n,s,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),h,l,a),0!==n.paint.get("text-opacity").constantOr(1)&&gs(t,i,n,s,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),h,l,a),i.map.showCollisionBoxes&&(us(t,i,n,s,!0),us(t,i,n,s,!1))},circle:function(t,i,n,s,r){var o;if("translucent"!==t.renderPass)return;const{isRenderingToTexture:a}=r,h=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===h.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const f=t.context,d=f.gl,p=t.transform,m=t.getDepthModeForSublayer(0,ni.ReadOnly),_=ri.disabled,g=t.colorModeForRenderPass(),v=[],y=p.getCircleRadiusCorrection();for(const r of s){const s=i.getTile(r),h=s.getBucket(n);if(!h)continue;const l=n.paint.get("circle-translate"),c=n.paint.get("circle-translate-anchor"),f=e.aL(p,s,l,c),d=h.programConfigurations.get(n.id),m=t.useProgram("circle",d),_=h.layoutVertexBuffer,g=h.indexBuffer,w=null===(o=t.style.map.terrain)||void 0===o?void 0:o.getTerrainData(r),b={programConfiguration:d,program:m,layoutVertexBuffer:_,indexBuffer:g,uniformValues:Yi(t,s,n,f,y),terrainData:w,projectionData:p.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!a,applyTerrainMatrix:!0})};if(u){const t=h.segments.get();for(const i of t)v.push({segments:new e.aV([i]),sortKey:i.sortKey,state:b})}else v.push({segments:h.segments,sortKey:0,state:b})}u&&v.sort(((t,e)=>t.sortKey-e.sortKey));for(const e of v){const{programConfiguration:i,program:s,layoutVertexBuffer:r,indexBuffer:o,uniformValues:a,terrainData:h,projectionData:l}=e.state;s.draw(f,d.TRIANGLES,m,_,g,ii.backCCW,a,h,l,n.id,r,o,e.segments,n.paint,t.transform.zoom,i)}},heatmap:function(t,i,n,s,r){if(0===n.paint.get("heatmap-opacity"))return;const o=t.context,{isRenderingToTexture:a,isRenderingGlobe:h}=r;if(t.style.map.terrain){for(const e of s){const s=i.getTile(e);i.hasRenderableParent(e)||("offscreen"===t.renderPass?ys(t,s,n,e,h):"translucent"===t.renderPass&&ws(t,n,e,a,h))}o.viewport.set([0,0,t.width,t.height])}else"offscreen"===t.renderPass?function(t,i,n,s){const r=t.context,o=r.gl,a=t.transform,h=ri.disabled,l=new ti([o.ONE,o.ONE],e.bo.transparent,[!0,!0,!0,!0]);(function(t,i,n){const s=t.gl;t.activeTexture.set(s.TEXTURE1),t.viewport.set([0,0,i.width/4,i.height/4]);let r=n.heatmapFbos.get(e.cd);r?(s.bindTexture(s.TEXTURE_2D,r.colorAttachment.get()),t.bindFramebuffer.set(r.framebuffer)):(r=bs(t,i.width/4,i.height/4),n.heatmapFbos.set(e.cd,r))})(r,t,n),r.clear({color:e.bo.transparent});for(const e of s){if(i.hasRenderableParent(e))continue;const s=i.getTile(e),c=s.getBucket(n);if(!c)continue;const u=c.programConfigurations.get(n.id),f=t.useProgram("heatmap",u),d=a.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),p=a.getCircleRadiusCorrection();f.draw(r,o.TRIANGLES,ni.disabled,h,l,ii.backCCW,Qi(s,a.zoom,n.paint.get("heatmap-intensity"),p),null,d,n.id,c.layoutVertexBuffer,c.indexBuffer,c.segments,n.paint,a.zoom,u)}r.viewport.set([0,0,t.width,t.height])}(t,i,n,s):"translucent"===t.renderPass&&function(t,i){const n=t.context,s=n.gl;n.setColorMode(t.colorModeForRenderPass());const r=i.heatmapFbos.get(e.cd);r&&(n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,r.colorAttachment.get()),n.activeTexture.set(s.TEXTURE1),xs(n,i).bind(s.LINEAR,s.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(n,s.TRIANGLES,ni.disabled,ri.disabled,t.colorModeForRenderPass(),ii.disabled,tn(t,i,0,1),null,null,i.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,i.paint,t.transform.zoom))}(t,n)},line:function(t,e,i,n,s){var r;if("translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=s,a=i.paint.get("line-opacity"),h=i.paint.get("line-width");if(0===a.constantOr(1)||0===h.constantOr(1))return;const l=t.getDepthModeForSublayer(0,ni.ReadOnly),c=t.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),f=u.constantOr(1),d=i.paint.get("line-pattern"),p=d.constantOr(1),m=i.paint.get("line-gradient"),_=i.getCrossfadeParameters();let g;g=p?"linePattern":f&&m?"lineGradientSDF":f?"lineSDF":m?"lineGradient":"line";const v=t.context,y=v.gl,w=t.transform;let b=!0;for(const s of n){const n=e.getTile(s);if(p&&!n.patternsLoaded())continue;const a=n.getBucket(i);if(!a)continue;const h=a.programConfigurations.get(i.id),x=t.context.program.get(),M=t.useProgram(g,h),S=b||M.program!==x,z=null===(r=t.style.map.terrain)||void 0===r?void 0:r.getTerrainData(s),T=d.constantOr(null),E=null==u?void 0:u.constantOr(null);if(T&&n.imageAtlas){const t=n.imageAtlas,e=t.patternPositions[T.to.toString()],i=t.patternPositions[T.from.toString()];e&&i&&h.setConstantPatternPositions(e,i)}else if(E){const e="round"===i.layout.get("line-cap").constantOr(null),n=t.lineAtlas.getDash(E.to,e),s=t.lineAtlas.getDash(E.from,e);h.setConstantDashPositions(n,s)}const A=w.getProjectionData({overscaledTileID:s,applyGlobeMatrix:!o,applyTerrainMatrix:!0}),P=w.getPixelScale();let C;p?(C=hn(t,n,i,P,_),Ss(v,y,n,h,_)):f&&m?(C=cn(t,n,i,P,_,a.lineClipsArray.length),Es(t,e,v,y,i,a,s,h,_)):f?(C=ln(t,n,i,P,_),zs(t,v,y,h,S,_)):m?(C=an(t,n,i,P,a.lineClipsArray.length),Ts(t,e,v,y,i,a,s)):C=on(t,n,i,P);const D=t.stencilModeForClipping(s);M.draw(v,y.TRIANGLES,l,D,c,ii.disabled,C,z,A,i.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,i.paint,t.transform.zoom,h,a.layoutVertexBuffer2),b=!1}},fill:function(t,i,n,s,r){const o=n.paint.get("fill-color"),a=n.paint.get("fill-opacity");if(0===a.constantOr(1))return;const{isRenderingToTexture:h}=r,l=t.colorModeForRenderPass(),c=n.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.bo.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const e=t.getDepthModeForSublayer(1,"opaque"===t.renderPass?ni.ReadWrite:ni.ReadOnly);Ps(t,i,n,s,e,l,!1,h)}if("translucent"===t.renderPass&&n.paint.get("fill-antialias")){const e=t.getDepthModeForSublayer(n.getPaintProperty("fill-outline-color")?2:0,ni.ReadOnly);Ps(t,i,n,s,e,l,!0,h)}},fillExtrusion:function(t,e,i,n,s){const r=i.paint.get("fill-extrusion-opacity");if(0===r)return;const{isRenderingToTexture:o}=s;if("translucent"===t.renderPass){const s=new ni(t.context.gl.LEQUAL,ni.ReadWrite,t.depthRangeFor3D);if(1!==r||i.paint.get("fill-extrusion-pattern").constantOr(1))Cs(t,e,i,n,s,ri.disabled,ti.disabled,o),Cs(t,e,i,n,s,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{const r=t.colorModeForRenderPass();Cs(t,e,i,n,s,ri.disabled,r,o)}}},hillshade:function(t,i,n,s,r){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const{isRenderingToTexture:o}=r,a=t.context,h=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,ni.ReadOnly),c=t.colorModeForRenderPass();if("offscreen"===t.renderPass)!function(t,i,n,s,r,o,a){const h=t.context,l=h.gl,c="nearest"===s.paint.get("resampling")?l.NEAREST:l.LINEAR;for(const u of n){const n=i.getTile(u),f=n.dem;if(!(null==f?void 0:f.data))continue;if(!n.needsHillshadePrepare)continue;const d=f.dim,p=f.stride,m=f.getPixels();if(h.activeTexture.set(l.TEXTURE1),h.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture||(n.demTexture=t.getTileTexture(p)),n.demTexture){const t=n.demTexture;t.update(m,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else n.demTexture=new e.T(h,m,l.RGBA,{premultiply:!1}),n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);h.activeTexture.set(l.TEXTURE0);let _=n.fbo;if(!_){const t=new e.T(h,{width:d,height:d,data:null},l.RGBA);t.bind(c,l.CLAMP_TO_EDGE),_=n.fbo=h.createFramebuffer(d,d,!0,!1),_.colorAttachment.set(t.texture)}h.bindFramebuffer.set(_.framebuffer),h.viewport.set([0,0,d,d]),t.useProgram("hillshadePrepare").draw(h,l.TRIANGLES,r,o,a,ii.disabled,nn(n.tileID,f),null,null,s.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),n.needsHillshadePrepare=!1}}(t,i,s,n,l,ri.disabled,c),a.viewport.set([0,0,t.width,t.height]);else if("translucent"===t.renderPass)if(h){const[e,r,a]=t.stencilConfigForOverlapTwoPass(s);Ds(t,i,n,a,e,l,c,!1,o),Ds(t,i,n,a,r,l,c,!0,o)}else{const[e,r]=t.getStencilConfigForOverlapAndUpdateStencilID(s);Ds(t,i,n,r,e,l,c,!1,o)}},colorRelief:function(t,e,i,n,s){if("translucent"!==t.renderPass)return;if(!n.length)return;const{isRenderingToTexture:r}=s,o=t.style.projection.useSubdivision,a=t.getDepthModeForSublayer(0,ni.ReadOnly),h=t.colorModeForRenderPass();if(o){const[s,o,l]=t.stencilConfigForOverlapTwoPass(n);Is(t,e,i,l,s,a,h,!1,r),Is(t,e,i,l,o,a,h,!0,r)}else{const[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(n);Is(t,e,i,o,s,a,h,!1,r)}},raster:function(t,e,i,n,s){if("translucent"!==t.renderPass)return;if(0===i.paint.get("raster-opacity"))return;if(!n.length)return;const{isRenderingToTexture:r}=s,o=e.getSource(),a=t.style.projection.useSubdivision;if(o instanceof et)$s(t,e,i,n,null,!1,!1,o.tileCoords,o.flippedWindingOrder,r);else if(a){const[s,o,a]=t.stencilConfigForOverlapTwoPass(n);$s(t,e,i,a,s,!1,!0,ks,!1,r),$s(t,e,i,a,o,!0,!0,ks,!1,r)}else{const[s,o]=t.getStencilConfigForOverlapAndUpdateStencilID(n);$s(t,e,i,o,s,!1,!0,ks,!1,r)}},background:function(t,e,i,n,s){var r;const o=i.paint.get("background-color"),a=i.paint.get("background-opacity");if(0===a)return;const{isRenderingToTexture:h}=s,l=t.context,c=l.gl,u=t.style.projection,f=t.transform,d=f.tileSize,p=i.paint.get("background-pattern");if(t.isPatternMissing(p))return;const m=!p&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==m)return;const _=ri.disabled,g=t.getDepthModeForSublayer(0,"opaque"===m?ni.ReadWrite:ni.ReadOnly),v=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),w=n||Tt(f,{tileSize:d,terrain:t.style.map.terrain});p&&(l.activeTexture.set(c.TEXTURE0),t.imageManager.bind(t.context));const b=i.getCrossfadeParameters();for(const e of w){const n=f.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!h,applyTerrainMatrix:!0}),s=p?yn(a,t,p,{tileID:e,tileSize:d},b):vn(a,o),m=null===(r=t.style.map.terrain)||void 0===r?void 0:r.getTerrainData(e),w=u.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,c.TRIANGLES,g,_,v,ii.backCCW,s,m,n,i.id,w.vertexBuffer,w.indexBuffer,w.segments)}},sky:function(t,e){const i=t.context,n=i.gl,s=((t,e,i)=>{const n=Math.cos(e.rollInRadians),s=Math.sin(e.rollInRadians),r=gt(e),o=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-r*s)*i,(e.height/2+r*n)*i],u_horizon_normal:[-s,n],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:o}})(e,t.style.map.transform,t.pixelRatio),r=new ni(n.LEQUAL,ni.ReadWrite,[0,1]),o=ri.disabled,a=t.colorModeForRenderPass(),h=t.useProgram("sky"),l=Ws(i,e);h.draw(i,n.TRIANGLES,r,o,a,ii.disabled,s,null,void 0,"sky",l.vertexBuffer,l.indexBuffer,l.segments)},atmosphere:function(t,i,n){const s=t.context,r=s.gl,o=t.useProgram("atmosphere"),a=new ni(r.LEQUAL,ni.ReadOnly,[0,1]),h=t.transform,l=function(t,i){const n=t.properties.get("position"),s=[-n.x,-n.y,-n.z],r=e.ap(new Float64Array(16));return"map"===t.properties.get("anchor")&&(e.be(r,r,i.rollInRadians),e.bf(r,r,-i.pitchInRadians),e.be(r,r,i.bearingInRadians),e.bf(r,r,i.center.lat*Math.PI/180),e.bI(r,r,-i.center.lng*Math.PI/180)),e.cg(s,s,r),s}(n,t.transform),c=h.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=i.properties.get("atmosphere-blend")*c.projectionTransition;if(0===u)return;const f=gi(h.worldSize,h.center.lat),d=h.inverseProjectionMatrix,p=new Float64Array(4);p[3]=1,e.aE(p,p,h.modelViewProjectionMatrix),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1,e.aE(p,p,d),p[0]/=p[3],p[1]/=p[3],p[2]/=p[3],p[3]=1;const m=((t,e,i,n,s)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:s}))(l,u,[p[0],p[1],p[2]],f,d),_=Ws(s,i);o.draw(s,r.TRIANGLES,a,ri.disabled,ti.alphaBlended,ii.disabled,m,null,null,"atmosphere",_.vertexBuffer,_.indexBuffer,_.segments)},custom:function(t,e,i,n){const{isRenderingGlobe:s}=n,r=t.context,o=i.implementation,a=t.style.projection,h=t.transform,l=h.getProjectionDataForCustomLayer(s),c={farZ:h.farZ,nearZ:h.nearZ,fov:h.fov*Math.PI/180,modelViewProjectionMatrix:h.modelViewProjectionMatrix,projectionMatrix:h.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:l},u=o.renderingMode?o.renderingMode:"2d";if("offscreen"===t.renderPass){const e=o.prerender;e&&(t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),e.call(o,r.gl,c),r.setDirty(),t.setBaseState())}else if("translucent"===t.renderPass){t.setCustomLayerDefaults(),r.setColorMode(t.colorModeForRenderPass()),r.setStencilMode(ri.disabled);const e="3d"===u?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,ni.ReadOnly);r.setDepthMode(e),o.render(r.gl,c),r.setDirty(),t.setBaseState(),r.bindFramebuffer.set(null)}},debug:function(t,e,i){for(const n of i)qs(t,e,n)},debugPadding:function(t){const e=t.transform.padding;Us(t,t.transform.height-(e.top||0),3,js),Us(t,e.bottom||0,3,Rs),Gs(t,e.left||0,3,Ls),Gs(t,t.transform.width-(e.right||0),3,Bs);const i=t.transform.centerPoint;!function(t,e,i,n){Vs(t,e-1,i-10,2,20,n),Vs(t,e-10,i-1,20,2,n)}(t,i.x,t.transform.height-i.y,Ns)},terrainDepth:function(t,i){const n=t.context,s=n.gl,r=t.transform,o=ti.unblended,a=new ni(s.LEQUAL,ni.ReadWrite,[0,1]),h=i.tileManager.getRenderableTiles(),l=t.useProgram("terrainDepth");n.bindFramebuffer.set(i.getFramebuffer("depth").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.bo.transparent,depth:1});for(const t of h){const e=i.getTerrainMesh(t.tileID),h=i.getTerrainData(t.tileID),c=r.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),u={u_ele_delta:i.getMeshFrameDelta(r.zoom)};l.draw(n,s.TRIANGLES,a,ri.disabled,o,ii.backCCW,u,h,c,"terrain",e.vertexBuffer,e.indexBuffer,e.segments)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])},terrainCoords:function(t,i){const n=t.context,s=n.gl,r=t.transform,o=ti.unblended,a=new ni(s.LEQUAL,ni.ReadWrite,[0,1]),h=i.getCoordsTexture(),l=i.tileManager.getRenderableTiles(),c=t.useProgram("terrainCoords");n.bindFramebuffer.set(i.getFramebuffer("coords").framebuffer),n.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),n.clear({color:e.bo.transparent,depth:1}),i.coordsIndex=[];for(const t of l){const e=i.getTerrainMesh(t.tileID),l=i.getTerrainData(t.tileID);n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const u={u_terrain_coords_id:(255-i.coordsIndex.length)/255,u_texture:0,u_ele_delta:i.getMeshFrameDelta(r.zoom)},f=r.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});c.draw(n,s.TRIANGLES,a,ri.disabled,o,ii.backCCW,u,l,f,"terrain",e.vertexBuffer,e.indexBuffer,e.segments),i.coordsIndex.push(t.tileID.key)}n.bindFramebuffer.set(null),n.viewport.set([0,0,t.width,t.height])}};class Ys{constructor(t,i){this.drawFunctions=Hs,this.context=new ls(t),this.transform=i,this._tileTextures={},this.terrainFacilitator={depthDirty:!0,coordsDirty:!1,matrix:e.ap(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=$t.maxOverzooming+$t.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Ie}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const t of this.style._order)this.style._layers[t].resize()}setup(){const t=this.context,i=new e.aU;i.emplaceBack(0,0),i.emplaceBack(e.a6,0),i.emplaceBack(0,e.a6),i.emplaceBack(e.a6,e.a6),this.tileExtentBuffer=t.createVertexBuffer(i,Re.members),this.tileExtentSegments=e.aV.simpleSegment(0,0,4,2);const n=new e.aU;n.emplaceBack(0,0),n.emplaceBack(e.a6,0),n.emplaceBack(0,e.a6),n.emplaceBack(e.a6,e.a6),this.debugBuffer=t.createVertexBuffer(n,Re.members),this.debugSegments=e.aV.simpleSegment(0,0,4,5);const s=new e.ch;s.emplaceBack(0,0,0,0),s.emplaceBack(e.a6,0,e.a6,0),s.emplaceBack(0,e.a6,0,e.a6),s.emplaceBack(e.a6,e.a6,e.a6,e.a6),this.rasterBoundsBuffer=t.createVertexBuffer(s,ji.members),this.rasterBoundsSegments=e.aV.simpleSegment(0,0,4,2);const r=new e.aU;r.emplaceBack(0,0),r.emplaceBack(e.a6,0),r.emplaceBack(0,e.a6),r.emplaceBack(e.a6,e.a6),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(r,Re.members),this.rasterBoundsSegmentsPosOnly=e.aV.simpleSegment(0,0,4,5);const o=new e.aU;o.emplaceBack(0,0),o.emplaceBack(1,0),o.emplaceBack(0,1),o.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(o,Re.members),this.viewportSegments=e.aV.simpleSegment(0,0,4,2);const a=new e.ci;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(a);const h=new e.aW;h.emplaceBack(1,0,2),h.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(h);const l=this.context.gl;this.stencilClearMode=new ri({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new je(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const t=this.context,i=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=e.O();e.c7(n,0,this.width,this.height,0,0,1),e.S(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const s={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(t,i.TRIANGLES,ni.disabled,this.stencilClearMode,ti.disabled,ii.disabled,null,null,s,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!(null==e?void 0:e.length))return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();const n=this.context;n.setColorMode(ti.disabled),n.setDepthMode(ni.disabled);const s={};for(const t of e)s[t.key]=this.nextStencilID++;this._renderTileMasks(s,e,i,!0),this._renderTileMasks(s,e,i,!1),this._tileClippingMaskIDs=s}_renderTileMasks(t,e,i,n){var s;const r=this.context,o=r.gl,a=this.style.projection,h=this.transform,l=this.useProgram("clippingMask");for(const c of e){const e=t[c.key],u=null===(s=this.style.map.terrain)||void 0===s?void 0:s.getTerrainData(c),f=a.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=h.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,ni.disabled,new ri({func:o.ALWAYS,mask:0},e,255,o.KEEP,o.KEEP,o.REPLACE),ti.disabled,i?ii.disabled:ii.backCCW,null,u,d,"$clipping",f.vertexBuffer,f.indexBuffer,f.segments)}}_renderTilesDepthBuffer(){var t;const e=this.context,i=e.gl,n=this.style.projection,s=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),a=Tt(s,{tileSize:s.tileSize});for(const h of a){const a=null===(t=this.style.map.terrain)||void 0===t?void 0:t.getTerrainData(h),l=n.getMeshFromTileID(this.context,h.canonical,!0,!0,"raster"),c=s.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,i.TRIANGLES,o,ri.disabled,ti.disabled,ii.backCCW,null,a,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,e=this.context.gl;return new ri({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){const e=this.context.gl;return new ri({func:e.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=i[i.length-1].overscaledZ,s=i[0].overscaledZ-n+1;if(s>1){this.currentStencilSource=void 0,this.nextStencilID+s>256&&this.clearStencil();const t={};for(let i=0;i<s;i++)t[i+n]=new ri({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=s,[t,i]}return[{[n]:ri.disabled},i]}stencilConfigForOverlapTwoPass(t){const e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),n=i[i.length-1].overscaledZ,s=i[0].overscaledZ-n+1;if(this.clearStencil(),s>1){const t={},r={};for(let i=0;i<s;i++)t[i+n]=new ri({func:e.GREATER,mask:255},s+1+i,255,e.KEEP,e.KEEP,e.REPLACE),r[i+n]=new ri({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*s+1,[t,r,i]}return this.nextStencilID=3,[{[n]:new ri({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[n]:new ri({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){const t=this.context.gl;if(this._showOverdrawInspector){const i=1/8;return new ti([t.CONSTANT_COLOR,t.ONE],new e.bo(i,i,i,0),[!0,!0,!0,!0])}return"opaque"===this.renderPass?ti.unblended:ti.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return ni.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new ni(i||this.context.gl.LEQUAL,e,[n,n])}getDepthModeFor3D(){return new ni(this.context.gl.LEQUAL,ni.ReadWrite,this.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,i){var n,s,r;this.style=t,this.options=i,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(l()),this.imageManager.beginFrame();const o=this.style._order,a=this.style.tileManagers,h={},c={},u={},f={isRenderingToTexture:!1,isRenderingGlobe:(null===(n=t.projection)||void 0===n?void 0:n.transitionState)>0};for(const t in a){const e=a[t];e.used&&e.prepare(this.context),h[t]=e.getVisibleCoordinates(!1),c[t]=h[t].slice().reverse(),u[t]=e.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let t=0;t<o.length;t++)if(this.style._layers[o[t]].is3D()){this.opaquePassCutoff=t;break}this.maybeDrawDepth(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const t of o){const e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const i=c[e.source];("custom"===e.type||i.length)&&this.renderLayer(this,a[e.source],e,i,f)}if(null===(s=this.style.projection)||void 0===s||s.updateGPUdependent({context:this.context,useProgram:t=>this.useProgram(t)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?e.bo.black:e.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const t=this.style._layers[o[this.currentLayer]],e=a[t.source],i=h[t.source];this._renderTileClippingMasks(t,i,!1),this.renderLayer(this,e,t,i,f)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer<o.length;this.currentLayer++){const t=this.style._layers[o[this.currentLayer]],e=a[t.source];if(null===(r=this.renderToTexture)||void 0===r?void 0:r.renderLayer(t,f))continue;this.opaquePassEnabledForLayer()||d||(d=!0,f.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());const i=("symbol"===t.type?u:c)[t.source];this._renderTileClippingMasks(t,h[t.source],!!this.renderToTexture),this.renderLayer(this,e,t,i,f)}if(f.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const t=function(t,e){let i=null;const n=Object.values(t._layers).flatMap((i=>i.source&&!i.isHidden(e)?[t.tileManagers[i.source]]:[])),s=n.filter((t=>"vector"===t.getSource().type)),r=n.filter((t=>"vector"!==t.getSource().type)),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};for(const t of s)o(t);if(!i)for(const t of r)o(t);return i}(this.style,this.transform.zoom);t&&this.drawFunctions.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(t){var i,n;if(!(null===(n=null===(i=this.style)||void 0===i?void 0:i.map)||void 0===n?void 0:n.terrain))return;const s=this.terrainFacilitator.matrix,r=this.transform.modelViewProjectionMatrix;let o=this.terrainFacilitator.depthDirty;o||(o=t?!e.cj(s,r):!e.ck(s,r)),o||(o=this.style.map.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime)),o&&(e.cl(s,r),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.depthDirty=!1,this.terrainFacilitator.coordsDirty=!0,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}maybeDrawCoords(){var t,e;(null===(e=null===(t=this.style)||void 0===t?void 0:t.map)||void 0===e?void 0:e.terrain)&&this.terrainFacilitator.coordsDirty&&(this.terrainFacilitator.coordsDirty=!1,this.drawFunctions.terrainCoords(this,this.style.map.terrain))}renderLayer(t,i,n,s,r){if(n.isHidden(this.transform.zoom))return;if("background"!==n.type&&"custom"!==n.type&&!(s||[]).length)return;this.id=n.id;const o=this.drawFunctions;e.aQ(n)?o.symbol(t,i,n,s,this.style.placement.variableOffsets,r):e.cm(n)?o.circle(t,i,n,s,r):e.cn(n)?o.heatmap(t,i,n,s,r):e.co(n)?o.line(t,i,n,s,r):e.cp(n)?o.fill(t,i,n,s,r):e.cq(n)?o.fillExtrusion(t,i,n,s,r):e.cr(n)?o.hillshade(t,i,n,s,r):e.cs(n)?o.colorRelief(t,i,n,s,r):e.bU(n)?o.raster(t,i,n,s,r):e.ct(n)?o.background(t,i,n,s,r):e.cu(n)&&o.custom(t,i,n,r)}saveTileTexture(t){const e=this._tileTextures[t.size[0]];e?e.length<Ys.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?e.push(t):t.destroy():this._tileTextures[t.size[0]]=[t]}getTileTexture(t){const e=this._tileTextures[t];return e&&e.length>0?e.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const e=this.imageManager.getPattern(t.from.toString()),i=this.imageManager.getPattern(t.to.toString());return!e||!i}useProgram(t,e,i=!1,n=[]){var s;this.cache||(this.cache={});const r=!!this.style.map.terrain,o=this.style.projection,a=i?$e.projectionMercator:o.shaderPreludeCode,h=i?Le:o.shaderDefine,l=t+(e?e.cacheKey:"")+`/${i?Be:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return(s=this.cache)[l]||(s[l]=new Ui(this.context,$e[t],e,bn[t],this._showOverdrawInspector,r,a,h,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var t,e;if(this._tileTextures){for(const t in this._tileTextures){const e=this._tileTextures[t];if(e)for(const t of e)t.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.vertexBuffer)||void 0===t||t.destroy()),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.indexBuffer)||void 0===e||e.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const t in this.cache){const e=this.cache[t];(null==e?void 0:e.program)&&this.context.gl.deleteProgram(e.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}}function Xs(t,e){let i,n=!1,s=null;const r=()=>{s=null,n&&(t(...i),s=setTimeout(r,e),n=!1)};return(...t)=>(n=!0,i=t,s||r(),s)}Ys.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50;class Js{constructor(t){this._getCurrentHash=()=>{const t=window.location.hash.replace("#","");if(this._hashName){let e;const i=t.split("&").map((t=>t.split("=")));for(const t of i)t[0]===this._hashName&&(e=t);return(e&&e[1]||"").split("/")}return t.split("/")},this._onHashChange=()=>{const t=this._getCurrentHash();if(!this._isValidHash(t))return!1;const e=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(t[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:e,pitch:+(t[4]||0)}),!0},this._updateHashUnthrottled=()=>{const t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{const t=this._getCurrentHash();if(0===t.length)return;const e=t.join("/");let i=e;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${e}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let s=window.location.href.replace(/(#.+)?$/,n);s=s.replace("&&","&"),window.history.replaceState(window.history.state,null,s)},this._updateHash=Xs(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(t){const e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),s=Math.pow(10,n),r=Math.round(e.lng*s)/s,o=Math.round(e.lat*s)/s,a=this._map.getBearing(),h=this._map.getPitch();let l="";if(l+=t?`/${r}/${o}/${i}`:`${i}/${o}/${r}`,(a||h)&&(l+="/"+Math.round(10*a)/10),h&&(l+=`/${Math.round(h)}`),this._hashName){const t=this._hashName;let e=!1;const i=window.location.hash.slice(1).split("&").map((i=>{const n=i.split("=")[0];return n===t?(e=!0,`${n}=${l}`):i})).filter((t=>t));return e||i.push(`${t}=${l}`),`#${i.join("&")}`}return`#${l}`}_isValidHash(t){if(t.length<3||t.some(isNaN))return!1;try{new e.W(+t[2],+t[1])}catch(t){return!1}const i=+t[0],n=+(t[3]||0),s=+(t[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&s>=this._map.getMinPitch()&&s<=this._map.getMaxPitch()}}const Ks={linearity:.3,easing:e.cv(0,0,.3,1)},Qs=e.e({deceleration:2500,maxSpeed:1400},Ks),tr=e.e({deceleration:20,maxSpeed:1400},Ks),er=e.e({deceleration:1e3,maxSpeed:360},Ks),ir=e.e({deceleration:1e3,maxSpeed:90},Ks),nr=e.e({deceleration:1e3,maxSpeed:360},Ks);class sr{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:l(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,e=l();for(;t.length>0&&e-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new e.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:t}of this._inertiaBuffer)i.zoom+=t.zoomDelta||0,i.bearing+=t.bearingDelta||0,i.pitch+=t.pitchDelta||0,i.roll+=t.rollDelta||0,t.panDelta&&i.pan._add(t.panDelta),t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,s={};if(i.pan.mag()){const r=or(i.pan.mag(),n,e.e({},Qs,t||{})),o=i.pan.mult(r.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(o,this._map.transform);s.center=a.easingCenter,s.offset=a.easingOffset,rr(s,r)}if(i.zoom){const t=or(i.zoom,n,tr);s.zoom=e.cw(this._map.transform.zoom+t.amount,this._map.getZoomSnap(),t.amount),rr(s,t)}if(i.bearing){const t=or(i.bearing,n,er);s.bearing=this._map.transform.bearing+e.al(t.amount,-179,179),rr(s,t)}if(i.pitch){const t=or(i.pitch,n,ir);s.pitch=this._map.transform.pitch+t.amount,rr(s,t)}if(i.roll){const t=or(i.roll,n,nr);s.roll=this._map.transform.roll+e.al(t.amount,-179,179),rr(s,t)}if(s.zoom||s.bearing){const t=void 0===i.pinchAround?i.around:i.pinchAround;s.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),e.e(s,{noMoveStart:!0})}}function rr(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function or(t,i,n){const{maxSpeed:s,linearity:r,deceleration:o}=n,a=e.al(t*r/(i/1e3),-s,s),h=Math.abs(a)/(o*r);return{easing:n.easing,duration:1e3*h,amount:a*(h/2)}}class ar extends e.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n,s={}){n=n instanceof MouseEvent?n:new MouseEvent(t,n);const r=f.mousePos(i.getCanvas(),n),o=i.unproject(r);super(t,e.e({point:r,lngLat:o,originalEvent:n},s)),this._defaultPrevented=!1,this.target=i}}class hr extends e.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,i,n){const s="touchend"===t?n.changedTouches:n.touches,r=f.touchPos(i.getCanvasContainer(),s),o=r.map((t=>i.unproject(t))),a=r.reduce(((t,e,i,n)=>t.add(e.div(n.length))),new e.P(0,0));super(t,{points:r,point:a,lngLats:o,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class lr extends e.n{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){super(t,{originalEvent:i}),this._defaultPrevented=!1}}class cr{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new lr(t.type,this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new ar(t.type,this._map,t))}mouseup(t){this._map.fire(new ar(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new ar(t.type,this._map,t))}dblclick(t){return this._firePreventable(new ar(t.type,this._map,t))}mouseover(t){this._map.fire(new ar(t.type,this._map,t))}mouseout(t){this._map.fire(new ar(t.type,this._map,t))}touchstart(t){return this._firePreventable(new hr(t.type,this._map,t))}touchmove(t){this._map.fire(new hr(t.type,this._map,t))}touchend(t){this._map.fire(new hr(t.type,this._map,t))}touchcancel(t){this._map.fire(new hr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ur{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new ar(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ar("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new ar(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fr{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this._map.terrain)}}class dr{constructor(t,e){this._map=t,this._tr=new fr(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=e.clickTolerance||1,e.boxZoom&&"object"==typeof e.boxZoom&&(this._boxZoomEnd=e.boxZoom.boxZoomEnd)}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,e){this.isEnabled()&&t.shiftKey&&0===t.button&&(f.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;const i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;const n=this._startPos;this._lastPos=i,this._box||(this._box=f.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));const s=Math.min(n.x,i.x),r=Math.max(n.x,i.x),o=Math.min(n.y,i.y),a=Math.max(n.y,i.y);this._box.style.transform=`translate(${s}px,${o}px)`,this._box.style.width=r-s+"px",this._box.style.height=a-o+"px"}mouseupWindow(t,i){if(!this._active)return;if(0!==t.button)return;const n=this._startPos,s=i;if(this.reset(),f.suppressClick(),n.x!==s.x||n.y!==s.y)return this._map.fire(new e.n("boxzoomend",{originalEvent:t})),this._boxZoomEnd?void this._boxZoomEnd(this._map,n,s,t):{cameraAnimation:t=>t.fitScreenCoordinates(n,s,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&27===t.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(this._box.remove(),this._box=null),f.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.n(t,{originalEvent:i}))}}function pr(t,e){if(t.length!==e.length)throw new Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);const i={};for(let n=0;n<t.length;n++)i[t[n].identifier]=e[n];return i}class mr{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,i,n){(this.centroid||n.length>this.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=t.timeStamp),n.length===this.numTouches&&(this.centroid=function(t){const i=new e.P(0,0);for(const e of t)i._add(e);return i.div(t.length)}(i),this.touches=pr(n,i)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;const n=pr(i,e);for(const t in this.touches){const e=n[t];(!e||e.dist(this.touches[t])>30)&&(this.aborted=!0)}}touchend(t,e,i){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}}class _r{constructor(t){this.singleTap=new mr(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,e,i){this.singleTap.touchstart(t,e,i)}touchmove(t,e,i){this.singleTap.touchmove(t,e,i)}touchend(t,e,i){const n=this.singleTap.touchend(t,e,i);if(n){const e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(e&&i||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class gr{constructor(t){this._tr=new fr(t),this._zoomIn=new _r({numTouches:1,numTaps:2}),this._zoomOut=new _r({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,e,i){this._zoomIn.touchstart(t,e,i),this._zoomOut.touchstart(t,e,i)}touchmove(t,e,i){this._zoomIn.touchmove(t,e,i),this._zoomOut.touchmove(t,e,i)}touchend(t,i,n){const s=this._zoomIn.touchend(t,i,n),r=this._zoomOut.touchend(t,i,n),o=this._tr;return s?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:e.cw(o.zoom+1,i.getZoomSnap()),around:o.unproject(s)},{originalEvent:t})}):r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:i=>i.easeTo({duration:300,zoom:e.cw(o.zoom-1,i.getZoomSnap()),around:o.unproject(r)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class vr{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const e=this._moveFunction(...t);if(e.bearingDelta||e.pitchDelta||e.rollDelta||e.around||e.panDelta)return this._active=!0,e}dragStart(t,e){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=Array.isArray(e)?e[0]:e,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,e){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const n=Array.isArray(e)?e[0]:e;return!this._moved&&n.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=n,this._move(i,n))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&f.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const yr=0,wr=2,br={[yr]:1,[wr]:2};class xr{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){this._eventButton=t.button}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(t,e){const i=br[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return t.button===this._eventButton}}class Mr{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}class Sr{constructor(t=new xr({checkCorrectEvent:()=>!0}),e=new Mr){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):"undefined"!=typeof TouchEvent&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.startMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.startMove(t)}))}endMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.endMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.endMove(t)}))}isValidStartEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidStartEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t)))}isValidMoveEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidMoveEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t)))}isValidEndEvent(t){return this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidEndEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t)))}}const zr=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};class Tr{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new e.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,e,i){return this._calculateTransform(t,e,i)}touchmove(t,e,i){if(this._active){if(!this._shouldBePrevented(i.length))return t.preventDefault(),this._calculateTransform(t,e,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,i,n){n.length>0&&(this._active=!0);const s=pr(n,i),r=new e.P(0,0),o=new e.P(0,0);let a=0;for(const t in s){const e=s[t],i=this._touches[t];i&&(r._add(e),o._add(e.sub(i)),a++,s[t]=e)}if(this._touches=s,this._shouldBePrevented(a)||!o.mag())return;const h=o.div(a);return this._sum._add(h),this._sum.mag()<this._clickTolerance?void 0:{around:r.div(a),panDelta:h}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Er{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,e,i){this._firstTwoTouches||i.length<2||(this._firstTwoTouches=[i[0].identifier,i[1].identifier],this._start([e[0],e[1]]))}touchmove(t,e,i){if(!this._firstTwoTouches)return;t.preventDefault();const[n,s]=this._firstTwoTouches,r=Ar(i,e,n),o=Ar(i,e,s);if(!r||!o)return;const a=this._aroundCenter?null:r.add(o).div(2);return this._move([r,o],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;const[n,s]=this._firstTwoTouches,r=Ar(i,e,n),o=Ar(i,e,s);r&&o||(this._active&&f.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ar(t,e,i){for(let n=0;n<t.length;n++)if(t[n].identifier===i)return e[n]}function Pr(t,e){return Math.log(t/e)/Math.LN2}class Cr extends Er{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(t){this._zoomRate=null!=t?t:1}setZoomThreshold(t){this._zoomThreshold=null!=t?t:.1}reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,e){const i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(Pr(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:Pr(this._distance,i)*this._zoomRate,pinchAround:e}}}function Dr(t,e){return 180*t.angleWith(e)/Math.PI}class Fr extends Er{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,e,i){const n=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Dr(this._vector,n),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());const e=25/(Math.PI*this._minDiameter)*360,i=Dr(t,this._startVector);return Math.abs(i)<e}}function Ir(t){return Math.abs(t.y)>Math.abs(t.x)}class kr extends Er{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,e,i){super.touchstart(t,e,i),this._currentTouchCount=i.length}_start(t){this._lastPoints=t,Ir(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=t[0].sub(this._lastPoints[0]),s=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,s,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(n.y+s.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;const n=t.mag()>=2,s=e.mag()>=2;if(!n&&!s)return;if(!n||!s)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const r=t.y>0==e.y>0;return Ir(t)&&Ir(e)&&r}}const $r={panStep:100,bearingStep:15,pitchStep:10};class Or{constructor(t){this._tr=new fr(t);const e=$r;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let i=0,n=0,s=0,r=0,o=0;switch(t.keyCode){case 61:case 107:case 171:case 187:i=1;break;case 189:case 109:case 173:i=-1;break;case 37:t.shiftKey?n=-1:(t.preventDefault(),r=-1);break;case 39:t.shiftKey?n=1:(t.preventDefault(),r=1);break;case 38:t.shiftKey?s=1:(t.preventDefault(),o=-1);break;case 40:t.shiftKey?s=-1:(t.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,s=0),{cameraAnimation:a=>{const h=this._tr;a.easeTo({duration:300,easeId:"keyboardHandler",easing:jr,zoom:i?e.cw(h.zoom+i*(t.shiftKey?2:1),a.getZoomSnap()):h.zoom,bearing:h.bearing+n*this._bearingStep,pitch:h.pitch+s*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:h.center},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function jr(t){return t*(2-t)}const Rr=4.000244140625,Lr=1/450;class Br{constructor(t,e){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=new fr(t),this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Lr}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&"center"===t.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let e=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const i=l(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%Rr==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*e)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,e+=this._lastValue)),t.shiftKey&&e&&(e/=4),this._type&&(this._lastWheelEvent=t,this._delta-=e,this._active||this._start(t)),t.preventDefault()}_start(t){if(!this._delta)return;this._needsRerender=!1,this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=f.mousePos(this._map.getCanvas(),t),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(e.W.convert(n.center)):i,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender)return;if(this._needsRerender=!1,!this.isActive())return;const t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Rr?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const s="number"!=typeof this._targetZoom?t.scale:e.ao(this._targetZoom),r=t.applyConstrain(t.getCameraLngLat(),e.ar(s*n)).zoom,o=this._map.getZoomSnap();if("wheel"===this._type&&o>0){const i=e.cw(t.zoom,o);this._targetZoom=e.cw(r,o,r-i)}else this._targetZoom=r;"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?t.zoom:this._targetZoom,n=this._startZoom,s=this._easing;let r,o=!1;if("wheel"===this._type&&n&&s){const t=l()-this._lastWheelEventTime,a=Math.min((t+5)/200,1),h=s(a);r=e.H.number(n,i,h),a<1?this._needsRerender=!0:o=!0}else r=i,o=!0;return this._active=!0,o&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=r,{noInertia:!0,needsRenderFrame:!o,zoomDelta:r-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let i=e.cy;if(this._prevEase){const t=this._prevEase,n=(l()-t.start)/t.duration,s=t.easing(n+.01)-t.easing(n),r=.27/Math.sqrt(s*s+1e-4)*.01,o=Math.sqrt(.0729-r*r);i=e.cv(r,o,.25,1)}return this._prevEase={start:l(),duration:t,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Nr{constructor(t,e){this._clickZoom=t,this._tapZoom=e}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Ur{constructor(t){this._tr=new fr(t),this.reset()}reset(){this._active=!1}dblclick(t,i){return t.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:e.cw(this._tr.zoom+(t.shiftKey?-1:1),n.getZoomSnap()),around:this._tr.unproject(i)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Gr{constructor(){this._tap=new _r({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=null!=t?t:1}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,e,i){if(!this._swipePoint)if(this._tapTime){const n=e[0],s=t.timeStamp-this._tapTime<500,r=this._tapPoint.dist(n)<30;s&&r?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(t,e,i)}touchmove(t,e,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=e[0],s=n.y-this._swipePoint.y;return this._swipePoint=n,t.preventDefault(),this._active=!0,{zoomDelta:s/128*this._zoomRate}}}else this._tap.touchmove(t,e,i)}touchend(t,e,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(t,e,i);n&&(this._tapTime=t.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vr{constructor(t,e,i){this._el=t,this._mousePan=e,this._touchPan=i}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class qr{constructor(t,e,i,n){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class Zr{constructor(t,e,i,n){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}setZoomRate(t){this._touchZoom.setZoomRate(t),this._tapDragZoom.setZoomRate(t)}setZoomThreshold(t){this._touchZoom.setZoomThreshold(t)}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Wr{constructor(t,e){this._bypassKey=navigator.userAgent.includes("Mac")?"metaKey":"ctrlKey",this._map=t,this._options=e,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=f.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=e,this._container.appendChild(n);const s=document.createElement("div");s.className="maplibregl-mobile-message",s.textContent=i,this._container.appendChild(s),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(this._container.remove(),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,i){this._enabled&&(this._map.fire(new e.n("cooperativegestureprevented",{gestureType:t,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}}const Hr=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;class Yr extends e.n{}function Xr(t){var e;return(null===(e=t.panDelta)||void 0===e?void 0:e.mag())||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}class Jr{get _ownerDocument(){var t;return(null===(t=this._el)||void 0===t?void 0:t.ownerDocument)||document}get _ownerWindow(){var t,e;return(null===(e=null===(t=this._el)||void 0===t?void 0:t.ownerDocument)||void 0===e?void 0:e.defaultView)||window}constructor(t,i){this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,i)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===t.type?void 0:t,s={needsRenderFrame:!1},r={},o={};for(const{handlerName:a,handler:h,allowed:l}of this._handlers){if(!h.isEnabled())continue;let c;if(this._blockedByActive(o,l,a))h.reset();else if(h[i||t.type]){if(e.cz(t,i||t.type)){const e=f.mousePos(this._map.getCanvas(),t);c=h[i||t.type](t,e)}else if(e.cA(t,i||t.type)){const e=this._getMapTouches(t.touches),n=f.touchPos(this._map.getCanvas(),e);c=h[i||t.type](t,n,e)}else e.cB(i||t.type)||(c=h[i||t.type](t));this.mergeHandlerResult(s,r,c,a,n),(null==c?void 0:c.needsRenderFrame)&&this._triggerRenderFrame()}(c||h.isActive())&&(o[a]=h)}const a={};for(const t in this._previousActiveHandlers)o[t]||(a[t]=n);this._previousActiveHandlers=o,(Object.keys(a).length||Xr(s))&&(this._changes.push([s,r,a]),this._triggerRenderFrame()),(Object.keys(o).length||Xr(s))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:h}=s;h&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],h(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new sr(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(const[t,e,i]of this._listeners)t.addEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[t,e,i]of this._listeners)t.removeEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new cr(i,t));const s=i.boxZoom=new dr(i,t);this._add("boxZoom",s),t.interactive&&t.boxZoom&&s.enable();const r=i.cooperativeGestures=new Wr(i,t.cooperativeGestures);this._add("cooperativeGestures",r),t.cooperativeGestures&&r.enable();const o=new gr(i),a=new Ur(i);i.doubleClickZoom=new Nr(a,o),this._add("tapZoom",o),this._add("clickZoom",a),t.interactive&&t.doubleClickZoom&&i.doubleClickZoom.enable();const h=new Gr;this._add("tapDragZoom",h);const l=i.touchPitch=new kr(i);this._add("touchPitch",l),t.interactive&&t.touchPitch&&i.touchPitch.enable(t.touchPitch);const c=()=>i.project(i.getCenter()),u=function({enable:t,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:s=100,rotateDegreesPerPixelMoved:r=.8},o){const a=new xr({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey});return new vr({clickTolerance:i,move:(t,i)=>{const a=o();if(n&&Math.abs(a.y-t.y)>s)return{bearingDelta:e.cx(new e.P(t.x,i.y),i,a)};let h=(i.x-t.x)*r;return n&&i.y<a.y&&(h=-h),{bearingDelta:h}},moveStateManager:a,enable:t,assignEvents:zr})}(t,c),f=function({enable:t,clickTolerance:e,pitchDegreesPerPixelMoved:i=-.5}){const n=new xr({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button});return new vr({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:n,enable:t,assignEvents:zr})}(t),d=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},n){const s=new xr({checkCorrectEvent:t=>2===t.button&&t.ctrlKey});return new vr({clickTolerance:e,move:(t,e)=>{const s=n();let r=(e.x-t.x)*i;return e.y<s.y&&(r=-r),{rollDelta:r}},moveStateManager:s,enable:t,assignEvents:zr})}(t,c);i.dragRotate=new qr(t,u,f,d),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",f,["mouseRotate","mouseRoll"]),this._add("mouseRoll",d,["mousePitch"]),t.interactive&&t.dragRotate&&i.dragRotate.enable();const p=function({enable:t,clickTolerance:e}){const i=new xr({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey});return new vr({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:i,enable:t,assignEvents:zr})}(t),m=new Tr(t,i);i.dragPan=new Vr(n,p,m),this._add("mousePan",p),this._add("touchPan",m,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&i.dragPan.enable(t.dragPan);const _=new Fr,g=new Cr;i.touchZoomRotate=new Zr(n,g,_,h),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",g,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&i.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new ur(i));const v=i.scrollZoom=new Br(i,(()=>this._triggerRenderFrame()));this._add("scrollZoom",v,["mousePan"]),t.interactive&&t.scrollZoom&&i.scrollZoom.enable(t.scrollZoom);const y=i.keyboard=new Or(i);this._add("keyboard",y),t.interactive&&t.keyboard&&i.keyboard.enable()}_add(t,e,i){this._handlers.push({handlerName:t,handler:e,allowed:i}),this._handlersById[t]=e}stop(t){if(!this._updatingCamera){for(const{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(Hr(this._eventsInProgress))||this.isZooming()}_blockedByActive(t,e,i){for(const n in t)if(n!==i&&!(null==e?void 0:e.includes(n)))return!0;return!1}_getMapTouches(t){const e=[];for(const i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,i,n,s,r){if(!n)return;e.e(t,n);const o={handlerName:s,originalEvent:n.originalEvent||r};void 0!==n.zoomDelta&&(i.zoom=o),void 0!==n.panDelta&&(i.drag=o),void 0!==n.rollDelta&&(i.roll=o),void 0!==n.pitchDelta&&(i.pitch=o),void 0!==n.bearingDelta&&(i.rotate=o)}_applyChanges(){const t={},i={},n={};for(const[s,r,o]of this._changes)s.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(s.panDelta)),s.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+s.zoomDelta),s.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+s.bearingDelta),s.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+s.pitchDelta),s.rollDelta&&(t.rollDelta=(t.rollDelta||0)+s.rollDelta),void 0!==s.around&&(t.around=s.around),void 0!==s.pinchAround&&(t.pinchAround=s.pinchAround),s.noInertia&&(t.noInertia=s.noInertia),e.e(i,r),e.e(n,o);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,e,i){const n=this._map,s=n._getTransformForUpdate(),r=n.terrain;if(!(Xr(t)||r&&this._terrainMovement))return void this._fireEvents(e,i,!0);n._stop(!0);let{panDelta:o,zoomDelta:a,bearingDelta:h,pitchDelta:l,rollDelta:c,around:u,pinchAround:f}=t;void 0!==f&&(u=f),u||(u=n.transform.centerPoint),r&&!s.isPointOnMapSurface(u)&&(u=s.centerPoint);const d={panDelta:o,zoomDelta:a,rollDelta:c,pitchDelta:l,bearingDelta:h,around:u};this._map.cameraHelper.useGlobeControls&&!s.isPointOnMapSurface(u)&&(u=s.centerPoint);const p=u.distSqr(s.centerPoint)<.01?s.center:s.screenPointToLocation(o?u.sub(o):u);this._handleMapControls({terrain:r,tr:s,deltasForHelper:d,preZoomAroundLoc:p,combinedEventsInProgress:e,panDelta:o}),n._applyUpdatedTransform(s),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_handleMapControls({terrain:t,tr:e,deltasForHelper:i,preZoomAroundLoc:n,combinedEventsInProgress:s,panDelta:r}){const o=this._map.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,e),t)return o.useGlobeControls?(this._terrainMovement||!s.drag&&!s.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void o.handleMapControlsPan(i,e,n)):this._terrainMovement||!s.drag&&!s.zoom?void(s.drag&&this._terrainMovement&&r?e.setCenter(e.screenPointToLocation(e.centerPoint.sub(r))):o.handleMapControlsPan(i,e,n)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void o.handleMapControlsPan(i,e,n));o.handleMapControlsPan(i,e,n)}_fireEvents(t,i,n){const s=Hr(this._eventsInProgress),r=Hr(t),o={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(o[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!s&&r&&this._fireEvent("movestart",r.originalEvent);for(const t in o)this._fireEvent(t,o[t]);r&&this._fireEvent("move",r.originalEvent);for(const e in t){const{originalEvent:i}=t[e];this._fireEvent(e,i)}const h={};let l;for(const t in this._eventsInProgress){const{handlerName:e,originalEvent:n}=this._eventsInProgress[t];this._handlersById[e].isActive()||(delete this._eventsInProgress[t],l=i[e]||n,h[`${t}end`]=l)}for(const t in h)this._fireEvent(t,h[t]);const c=Hr(this._eventsInProgress),u=(s||r)&&!c;if(u&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const t=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(t)}if(n&&u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&a.prefersReducedMotion?(this._map.fire(new e.n("moveend",{originalEvent:l})),i(this._map.getBearing())&&this._map.resetNorth()):(i(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:l})),this._updatingCamera=!1}}_fireEvent(t,i){this._map.fire(new e.n(t,i?{originalEvent:i}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new Yr("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Kr extends e.E{constructor(t,e,i){super(),this._renderFrameCallback=()=>{const t=Math.min((l()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(t)),t<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=i.bearingSnap,this._zoomSnap=i.zoomSnap,this.cameraHelper=e,this.on("moveend",(()=>{delete this._requestedCameraState}))}migrateProjection(t,e){t.apply(this.transform,!0),this.transform=t,this.cameraHelper=e}getCenter(){return new e.W(this.transform.center.lng,this.transform.center.lat)}setCenter(t,e){return this.jumpTo({center:t},e)}getCenterElevation(){return this.transform.elevation}setCenterElevation(t,e){return this.jumpTo({elevation:t},e),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(t){this._centerClampedToGround=t}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,e.e({offset:t},i),n)}panTo(t,i,n){return this.easeTo(e.e({center:t},i),n)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,i,n){return this.easeTo(e.e({zoom:t},i),n)}zoomIn(t,i){return this.zoomTo(e.cw(this.getZoom()+1,this._zoomSnap),t,i),this}zoomOut(t,i){return this.zoomTo(e.cw(this.getZoom()-1,this._zoomSnap),t,i),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,i){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new e.n("movestart",i)).fire(new e.n("move",i)).fire(new e.n("moveend",i))),this}getBearing(){return this.transform.bearing}setZoomSnap(t){return this._zoomSnap=t,this}getZoomSnap(){return this._zoomSnap}setBearing(t,e){return this.jumpTo({bearing:t},e),this}getPadding(){return this.transform.padding}setPadding(t,e){return this.jumpTo({padding:t},e),this}rotateTo(t,i,n){return this.easeTo(e.e({bearing:t},i),n)}resetNorth(t,i){return this.rotateTo(0,e.e({duration:1e3},t),i),this}resetNorthPitch(t,i){return this.easeTo(e.e({bearing:0,pitch:0,roll:0,duration:1e3},t),i),this}snapToNorth(t,e){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,e):this}getPitch(){return this.transform.pitch}setPitch(t,e){return this.jumpTo({pitch:t},e),this}getRoll(){return this.transform.roll}setRoll(t,e){return this.jumpTo({roll:t},e),this}cameraForBounds(t,e){t=G.convert(t).adjustAntiMeridian();const i=(null==e?void 0:e.bearing)||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,i,n,s){const r={top:0,bottom:0,right:0,left:0};if("number"==typeof(s=e.e({padding:r,offset:[0,0],maxZoom:this.transform.maxZoom},s)).padding){const t=s.padding;s.padding={top:t,bottom:t,right:t,left:t}}const o=e.e(r,s.padding);s.padding=o;const a=this.transform,h=new G(t,i),l=this.cameraHelper.cameraForBoxAndBearing(s,o,h,n,a);return l&&this._zoomSnap&&(l.zoom=e.cw(l.zoom,this._zoomSnap,-1)),l}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,i,n,s,r){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(e.P.convert(t)),this.transform.screenPointToLocation(e.P.convert(i)),n,s),s,r)}_fitInternal(t,i,n){return t?(delete(i=e.e(t,i)).padding,i.linear?this.easeTo(i,n):this.flyTo(i,n)):this}jumpTo(t,i){this.stop(),"zoom"in t&&this._zoomSnap&&(t.zoom=e.cw(t.zoom,this._zoomSnap));const n=this._getTransformForUpdate();let s=!1,r=!1,o=!1;const a=n.zoom;this.terrain&&n.setElevation(this.terrain.getElevationForLngLatZoom(t.center?e.W.convert(t.center):n.center,t.zoom||n.tileZoom)),this.cameraHelper.handleJumpToCenterZoom(n,t);const h=n.zoom!==a;return"elevation"in t&&n.elevation!==+t.elevation&&n.setElevation(+t.elevation),"bearing"in t&&n.bearing!==+t.bearing&&(s=!0,n.setBearing(+t.bearing)),"pitch"in t&&n.pitch!==+t.pitch&&(r=!0,n.setPitch(+t.pitch)),"roll"in t&&n.roll!==+t.roll&&(o=!0,n.setRoll(+t.roll)),null==t.padding||n.isPaddingEqual(t.padding)||n.setPadding(t.padding),this._applyUpdatedTransform(n),this.fire(new e.n("movestart",i)).fire(new e.n("move",i)),h&&this.fire(new e.n("zoomstart",i)).fire(new e.n("zoom",i)).fire(new e.n("zoomend",i)),s&&this.fire(new e.n("rotatestart",i)).fire(new e.n("rotate",i)).fire(new e.n("rotateend",i)),r&&this.fire(new e.n("pitchstart",i)).fire(new e.n("pitch",i)).fire(new e.n("pitchend",i)),o&&this.fire(new e.n("rollstart",i)).fire(new e.n("roll",i)).fire(new e.n("rollend",i)),this.fire(new e.n("moveend",i))}calculateCameraOptionsFromTo(t,i,n,s=0){const r=e.a7.fromLngLat(t,i),o=e.a7.fromLngLat(n,s),a=o.x-r.x,h=o.y-r.y,l=o.z-r.z,c=Math.hypot(a,h,l);if(0===c)throw new Error("Can't calculate camera options with same From and To");const u=Math.hypot(a,h),f=e.ar(this.transform.cameraToCenterDistance/c/this.transform.tileSize),d=180*Math.atan2(a,-h)/Math.PI;let p=180*Math.acos(u/c)/Math.PI;return p=l<0?90-p:90+p,{center:o.toLngLat(),elevation:s,zoom:f,pitch:p,bearing:d}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,n,s){const r=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,n);return{center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:i,pitch:n,roll:s}}easeTo(t,i){this._stop(!1,t.easeId),"zoom"in(t=e.e({offset:[0,0],duration:500,easing:e.cy},t))&&this._zoomSnap&&(t.zoom=e.cw(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&a.prefersReducedMotion)&&(t.duration=0);const n=this._getTransformForUpdate(),s=this.getBearing(),r=n.pitch,o=n.roll,h="bearing"in t?this._normalizeBearing(t.bearing,s):s,l="pitch"in t?+t.pitch:r,c="roll"in t?this._normalizeBearing(t.roll,o):o,u="padding"in t?t.padding:n.padding,f=e.P.convert(t.offset);let d,p;t.around&&(d=e.W.convert(t.around),p=n.locationToScreenPoint(d));const m={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},_=this.cameraHelper.handleEaseTo(n,{bearing:h,pitch:l,roll:c,padding:u,around:d,aroundPoint:p,offsetAsPoint:f,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating||(this._rotating=s!==h),this._pitching||(this._pitching=l!==r),this._rolling||(this._rolling=c!==o),this._padding=!n.isPaddingEqual(u),this._zooming||(this._zooming=_.isZooming),this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,m),this.terrain&&this._prepareElevation(_.elevationCenter),this._ease((e=>{_.easeFunc(e),this.terrain&&!t.freezeElevation&&this._updateElevation(e),this._applyUpdatedTransform(n),this._fireMoveEvents(i)}),(e=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i,e)}),t),this}_prepareEase(t,i,n={}){this._moving=!0,i||n.moving||this.fire(new e.n("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.n("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.n("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.n("pitchstart",t)),this._rolling&&!n.rolling&&this.fire(new e.n("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&i!==this._elevationTarget){const e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.transform.setElevation(e.H.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};const e=t.getCameraLngLat(),i=t.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<n){const i=this.calculateCameraOptionsFromTo(e,n,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}_applyUpdatedTransform(t){const e=[];if(e.push((t=>this._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;const i=t.clone();for(const t of e){const e=i.clone(),{center:n,zoom:s,roll:r,pitch:o,bearing:a,elevation:h}=t(e);n&&e.setCenter(n),void 0!==h&&e.setElevation(h),void 0!==s&&e.setZoom(s),void 0!==r&&e.setRoll(r),void 0!==o&&e.setPitch(o),void 0!==a&&e.setBearing(a),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(t){this.fire(new e.n("move",t)),this._zooming&&this.fire(new e.n("zoom",t)),this._rotating&&this.fire(new e.n("rotate",t)),this._pitching&&this.fire(new e.n("pitch",t)),this._rolling&&this.fire(new e.n("roll",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,s=this._rotating,r=this._pitching,o=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new e.n("zoomend",t)),s&&this.fire(new e.n("rotateend",t)),r&&this.fire(new e.n("pitchend",t)),o&&this.fire(new e.n("rollend",t)),this.fire(new e.n("moveend",t))}flyTo(t,i){if(!t.essential&&a.prefersReducedMotion){const n=e.V(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(n,i)}this.stop(),"zoom"in(t=e.e({offset:[0,0],speed:1.2,curve:1.42,easing:e.cy},t))&&this._zoomSnap&&(t.zoom=e.cw(t.zoom,this._zoomSnap));const n=this._getTransformForUpdate(),s=n.bearing,r=n.pitch,o=n.roll,h=n.padding,l="bearing"in t?this._normalizeBearing(t.bearing,s):s,c="pitch"in t?+t.pitch:r,u="roll"in t?this._normalizeBearing(t.roll,o):o,f="padding"in t?t.padding:n.padding,d=e.P.convert(t.offset);let p=n.centerPoint.add(d);const m=n.screenPointToLocation(p),_=this.cameraHelper.handleFlyTo(n,{bearing:l,pitch:c,roll:u,padding:f,locationAtOffset:m,offsetAsPoint:d,center:t.center,minZoom:t.minZoom,zoom:t.zoom});let g=t.curve;const v=Math.max(n.width,n.height),y=v/_.scaleOfZoom,w=_.pixelPathLength;"number"==typeof _.scaleOfMinZoom&&(g=Math.sqrt(v/_.scaleOfMinZoom/w*2));const b=g*g;function x(t){const e=(y*y-v*v+(t?-1:1)*b*b*w*w)/(2*(t?y:v)*b*w);return Math.log(Math.sqrt(e*e+1)-e)}function M(t){return(Math.exp(t)-Math.exp(-t))/2}function S(t){return(Math.exp(t)+Math.exp(-t))/2}const z=x(!1);let T=function(t){return S(z)/S(z+g*t)},E=function(t){return v*((S(z)*(M(e=z+g*t)/S(e))-M(z))/b)/w;var e},A=(x(!0)-z)/g;if(Math.abs(w)<2e-6||!isFinite(A)){if(Math.abs(v-y)<1e-6)return this.easeTo(t,i);const e=y<v?-1:1;A=Math.abs(Math.log(y/v))/g,E=()=>0,T=t=>Math.exp(e*g*t)}return t.duration="duration"in t?+t.duration:1e3*A/("screenSpeed"in t?+t.screenSpeed/g:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=s!==l,this._pitching=c!==r,this._rolling=u!==o,this._padding=!n.isPaddingEqual(f),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(_.targetCenter),this._ease((a=>{const m=a*A,g=1/T(m),v=E(m);this._rotating&&n.setBearing(e.H.number(s,l,a)),this._pitching&&n.setPitch(e.H.number(r,c,a)),this._rolling&&n.setRoll(e.H.number(o,u,a)),this._padding&&(n.interpolatePadding(h,f,a),p=n.centerPoint.add(d)),_.easeFunc(a,g,v,p),this.terrain&&!t.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(n),this._fireMoveEvents(i)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(i)}),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,e){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=l(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,i){t=e.X(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)<n&&(t-=360),Math.abs(t+360-i)<n&&(t+=360),t}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(e.W.convert(t),this.transform):null}}const Qr={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class to{constructor(t=Qr){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=t=>{!t||"metadata"!==t.sourceDataType&&"visibility"!==t.sourceDataType&&"style"!==t.dataType&&"terrain"!==t.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=f.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=f.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=f.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,e){const i=this._map._getUIString(`AttributionControl.${e}`);t.title=i,t.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map((t=>"string"!=typeof t?"":t))):"string"==typeof this.options.customAttribution&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}const e=this._map.style.tileManagers;for(const i in e){const n=e[i];if(n.used||n.usedForTerrain){const e=n.getSource();e.attribution&&!t.includes(e.attribution)&&t.push(e.attribution)}}t=t.filter((t=>String(t).trim())),t.sort(((t,e)=>t.length-e.length)),t=t.filter(((e,i)=>{for(let n=i+1;n<t.length;n++)if(t[n].includes(e))return!1;return!0}));const i=t.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=f.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class eo{constructor(t={}){this._updateCompact=()=>{const t=this._container.children;if(t.length){const e=t[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&e.classList.add("maplibregl-compact"):e.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){var e;this._map=t,this._compact=null===(e=this.options)||void 0===e?void 0:e.compact,this._container=f.create("div","maplibregl-ctrl");const i=f.create("a","maplibregl-ctrl-logo");return i.target="_blank",i.rel="noopener nofollow",i.href="https://maplibre.org/",i.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),i.setAttribute("rel","noopener nofollow"),this._container.appendChild(i),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class io{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){const e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(const e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const e=this._currentlyRunning=this._queue;this._queue=[];for(const i of e)if(!i.cancelled&&(i.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var no=e.aS([{name:"a_pos3d",type:"Int16",components:3}]);class so extends e.E{constructor(t){super(),this._lastTilesetChange=l(),this.tileManager=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=t._source.tileSize*2**this.deltaZoom,t.usedForTerrain=!0,t.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(t,i){this.tileManager.update(t,i),this._renderableTilesKeys=[];const n={};for(const s of Tt(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))n[s.key]=!0,this._renderableTilesKeys.push(s.key),this._tiles[s.key]||(s.terrainRttPosMatrix32f=new Float64Array(16),e.c7(s.terrainRttPosMatrix32f,0,e.a6,e.a6,0,0,1),this._tiles[s.key]=new ft(s,this.tileSize),this._lastTilesetChange=l());for(const t in this._tiles)n[t]||delete this._tiles[t]}freeRtt(t){for(const e in this._tiles){const i=this._tiles[e];(!t||i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map((t=>this.getTileByID(t)))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t,e){return e?this._getTerrainCoordsForTileRanges(t,e):this._getTerrainCoordsForRegularTile(t)}_getTerrainCoordsForRegularTile(t){const i={};for(const n of this._renderableTilesKeys){const s=this._tiles[n].tileID,r=t.clone(),o=e.bj();if(s.canonical.equals(t.canonical))e.c7(o,0,e.a6,e.a6,0,0,1);else if(s.canonical.isChildOf(t.canonical)){const i=s.canonical.z-t.canonical.z,n=s.canonical.x-(s.canonical.x>>i<<i),r=s.canonical.y-(s.canonical.y>>i<<i),a=e.a6>>i;e.c7(o,0,a,a,0,0,1),e.Q(o,o,[-n*a,-r*a,0])}else{if(!t.canonical.isChildOf(s.canonical))continue;{const i=t.canonical.z-s.canonical.z,n=t.canonical.x-(t.canonical.x>>i<<i),r=t.canonical.y-(t.canonical.y>>i<<i),a=e.a6>>i;e.c7(o,0,e.a6,e.a6,0,0,1),e.Q(o,o,[n*a,r*a,0]),e.S(o,o,[1/2**i,1/2**i,0])}}r.terrainRttPosMatrix32f=new Float32Array(o),i[n]=r}return i}_getTerrainCoordsForTileRanges(t,i){const n={};for(const s of this._renderableTilesKeys){const r=this._tiles[s].tileID;if(!this._isWithinTileRanges(r,i))continue;const o=t.clone(),a=e.bj();if(r.canonical.z===t.canonical.z){const i=t.canonical.x-r.canonical.x+t.wrap*(1<<t.canonical.z),n=t.canonical.y-r.canonical.y;e.c7(a,0,e.a6,e.a6,0,0,1),e.Q(a,a,[i*e.a6,n*e.a6,0])}else if(r.canonical.z>t.canonical.z){const i=r.canonical.z-t.canonical.z,n=r.canonical.x-(r.canonical.x>>i<<i)+t.wrap*(1<<r.canonical.z),s=r.canonical.y-(r.canonical.y>>i<<i),o=t.canonical.x-(r.canonical.x>>i),h=t.canonical.y-(r.canonical.y>>i),l=e.a6>>i;e.c7(a,0,l,l,0,0,1),e.Q(a,a,[-n*l+o*e.a6,-s*l+h*e.a6,0])}else{const i=t.canonical.z-r.canonical.z,n=t.canonical.x-(t.canonical.x>>i<<i)+t.wrap*(1<<t.canonical.z),s=t.canonical.y-(t.canonical.y>>i<<i),o=(t.canonical.x>>i)-r.canonical.x,h=(t.canonical.y>>i)-r.canonical.y,l=e.a6<<i;e.c7(a,0,l,l,0,0,1),e.Q(a,a,[n*e.a6+o*l,s*e.a6+h*l,0])}o.terrainRttPosMatrix32f=new Float32Array(a),n[s]=o}return n}getSourceTile(t,e){var i,n;const s=this.tileManager._source;let r=t.overscaledZ-this.deltaZoom;if(r>s.maxzoom&&(r=s.maxzoom),r<s.minzoom)return;(i=this._sourceTileCache)[n=t.key]||(i[n]=t.scaledTo(r).key);let o=this.findTileInCaches(this._sourceTileCache[t.key]);if(!(null==o?void 0:o.dem)&&e)for(;r>=s.minzoom&&!(null==o?void 0:o.dem);)o=this.findTileInCaches(t.scaledTo(r--).key);return o}findTileInCaches(t){let e=this.tileManager.getTileByID(t);return e||(e=this.tileManager._outOfViewCache.getByKey(t),e)}anyTilesAfterTime(t=Date.now()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){const i=e[t.canonical.z];return!!i&&(t.wrap>i.minWrap||t.wrap<i.maxWrap||t.canonical.x>=i.minTileXWrapped&&t.canonical.x<=i.maxTileXWrapped&&t.canonical.y>=i.minTileY&&t.canonical.y<=i.maxTileY)}}class ro{constructor(t,e,i){this._meshCache={},this.painter=t,this.tileManager=new so(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}destroy(){this._fbo&&(this._fbo.destroy(),this._fbo=null),this._fboCoordsTexture&&(this._fboCoordsTexture.destroy(),this._fboCoordsTexture=null),this._fboDepthTexture&&(this._fboDepthTexture.destroy(),this._fboDepthTexture=null),this._emptyDemTexture&&(this._emptyDemTexture.destroy(),this._emptyDemTexture=null),this._emptyDepthTexture&&(this._emptyDepthTexture.destroy(),this._emptyDepthTexture=null),this._coordsTexture&&(this._coordsTexture.destroy(),this._coordsTexture=null);for(const t in this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,i,n,s=e.a6){var r;const o=t.normalizeCoordinates(i,n,s);if(!o)return 0;const a=this.getTerrainData(o.tileID),h=null===(r=a.tile)||void 0===r?void 0:r.dem;if(!h)return 0;const l=e.cC([],[o.x/s*e.a6,o.y/s*e.a6],a.u_terrain_matrix),c=[l[0]*h.dim,l[1]*h.dim],u=Math.floor(c[0]),f=Math.floor(c[1]),d=c[0]-u,p=c[1]-f;return h.get(u,f)*(1-d)*(1-p)+h.get(u+1,f)*d*(1-p)+h.get(u,f+1)*(1-d)*p+h.get(u+1,f+1)*d*p}getElevationForLngLatZoom(t,i){if(!e.cD(i,t.wrap()))return 0;const{tileID:n,mercatorX:s,mercatorY:r}=this._getOverscaledTileIDFromLngLatZoom(t,i);return this.getElevation(n,s%e.a6,r%e.a6,e.a6)}getElevationForLngLat(t,e){const i=Tt(e,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this});let n=0;for(const t of i)t.canonical.z>n&&(n=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,n)}getElevation(t,i,n,s=e.a6){return this.getDEMElevation(t,i,n,s)*this.exaggeration}getTerrainData(t){var i,n;if(!this._emptyDemTexture){const t=this.painter.context,i=new e.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new e.T(t,i,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new e.T(t,new e.R({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=e.ap([])}const s=this.tileManager.getSourceTile(t,!0);if((null==s?void 0:s.dem)&&(!s.demTexture||s.needsTerrainPrepare)){const t=this.painter.context;s.demTexture=this.painter.getTileTexture(s.dem.stride),s.demTexture?s.demTexture.update(s.dem.getPixels(),{premultiply:!1}):s.demTexture=new e.T(t,s.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),s.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),s.needsTerrainPrepare=!1}const r=s&&s.toString()+s.tileID.key+t.key;if(r&&!this._demMatrixCache[r]){const i=this.tileManager.getSource().maxzoom;let n=t.canonical.z-s.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=i?n=t.canonical.z-i:e.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=t.canonical.x-(t.canonical.x>>n<<n),a=t.canonical.y-(t.canonical.y>>n<<n),h=e.cE(new Float64Array(16),[1/(e.a6<<n),1/(e.a6<<n),0]);e.Q(h,h,[o*e.a6,a*e.a6,0]),this._demMatrixCache[r]={matrix:h,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:(null===(i=null==s?void 0:s.dem)||void 0===i?void 0:i.dim)||1,u_terrain_matrix:r?this._demMatrixCache[r].matrix:this._emptyDemMatrix,u_terrain_unpack:(null===(n=null==s?void 0:s.dem)||void 0===n?void 0:n.getUnpackVector())||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:((null==s?void 0:s.demTexture)||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:s}}getFramebuffer(t){const i=this.painter,n=i.width/devicePixelRatio,s=i.height/devicePixelRatio;return!this._fbo||this._fbo.width===n&&this._fbo.height===s||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new e.T(i.context,{width:n,height:s,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new e.T(i.context,{width:n,height:s,data:null},i.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(i.context.gl.NEAREST,i.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=i.context.createFramebuffer(n,s,!0,!1),this._fbo.depthAttachment.set(i.context.createRenderbuffer(i.context.gl.DEPTH_COMPONENT16,n,s))),this._fbo.colorAttachment.set("coords"===t?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const i=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let t=0,e=0;t<this._coordsTextureSize;t++)for(let n=0;n<this._coordsTextureSize;n++,e+=4)i[e+0]=255&n,i[e+1]=255&t,i[e+2]=n>>8<<4|t>>8,i[e+3]=0;const n=new e.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),s=new e.T(t,n,t.gl.RGBA,{premultiply:!1});return s.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=s,s}pointCoordinate(t){this.painter.maybeDrawDepth(!0),this.painter.maybeDrawCoords();const i=new Uint8Array(4),n=this.painter.context,s=n.gl,r=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),o=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),s.readPixels(r,a-o-1,1,1,s.RGBA,s.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const h=i[0]+(i[2]>>4<<8),l=i[1]+((15&i[2])<<8),c=this.coordsIndex[255-i[3]],u=c&&this.tileManager.getTileByID(c);if(!u)return null;const f=this._coordsTextureSize,d=(1<<u.tileID.canonical.z)*f;return new e.a7((u.tileID.canonical.x*f+h)/d+u.tileID.wrap,(u.tileID.canonical.y*f+l)/d,this.getElevation(u.tileID,h,l,f))}depthAtPoint(t){const e=new Uint8Array(4),i=this.painter.context,n=i.gl;return i.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),n.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,n.RGBA,n.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){var i;const n=(null===(i=this.painter.style.projection)||void 0===i?void 0:i.transitionState)>0,s=n&&0===t.canonical.y,r=n&&t.canonical.y===(1<<t.canonical.z)-1,o=`m_${s?"n":""}_${r?"s":""}`;if(this._meshCache[o])return this._meshCache[o];const a=this.painter.context,h=new e.cF,l=new e.aW,c=this.meshSize,u=e.a6/c,f=c*c;for(let t=0;t<=c;t++)for(let e=0;e<=c;e++)h.emplaceBack(e*u,t*u,0);for(let t=0;t<f;t+=c+1)for(let e=0;e<c;e++)l.emplaceBack(e+t,c+e+t+1,c+e+t+2),l.emplaceBack(e+t,c+e+t+2,e+t+1);const d=h.length,p=d+(c+1),m=(c+1)*c,_=s?e.bq:0,g=s?0:1,v=r?e.br:e.a6,y=r?0:1;for(let t=0;t<=c;t++)h.emplaceBack(t*u,_,g);for(let t=0;t<=c;t++)h.emplaceBack(t*u,v,y);for(let t=0;t<c;t++)l.emplaceBack(m+t,p+t,p+t+1),l.emplaceBack(m+t,p+t+1,m+t+1),l.emplaceBack(0+t,d+t+1,d+t),l.emplaceBack(0+t,0+t+1,d+t+1);const w=h.length,b=w+2*(c+1);for(const t of[0,1])for(let i=0;i<=c;i++)for(const n of[0,1])h.emplaceBack(t*e.a6,i*u,n);for(let t=0;t<2*c;t+=2)l.emplaceBack(w+t,w+t+1,w+t+3),l.emplaceBack(w+t,w+t+3,w+t+2),l.emplaceBack(b+t,b+t+3,b+t+1),l.emplaceBack(b+t,b+t+2,b+t+3);const x=new je(a.createVertexBuffer(h,no.members),a.createIndexBuffer(l),e.aV.simpleSegment(0,0,h.length,l.length));return this._meshCache[o]=x,x}getMeshFrameDelta(t){return 2*Math.PI*e.bD/Math.pow(2,Math.max(t,0))/5}getMinTileElevationForLngLatZoom(t,i){var n;if(!e.cD(i,t.wrap()))return 0;const{tileID:s}=this._getOverscaledTileIDFromLngLatZoom(t,i);return null!==(n=this.getMinMaxElevation(s).minElevation)&&void 0!==n?n:0}getMinMaxElevation(t){const e=this.getTerrainData(t).tile,i={minElevation:null,maxElevation:null};return(null==e?void 0:e.dem)&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,i){const n=e.a7.fromLngLat(t.wrap()),s=(1<<i)*e.a6,r=n.x*s,o=n.y*s,a=Math.floor(r/e.a6),h=Math.floor(o/e.a6);return{tileID:new e.a3(i,0,i,a,h),mercatorX:r,mercatorY:o}}}class oo{constructor(t,e,i){this._context=t,this._size=e,this._tileSize=i,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){const i=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),n=new e.T(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return n.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),this._context.extTextureFilterAnisotropic&&this._context.gl.texParameterf(this._context.gl.TEXTURE_2D,this._context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this._context.extTextureFilterAnisotropicMax),i.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),i.colorAttachment.set(n.texture),{id:t,fbo:i,texture:n,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter((e=>t.id!==e)),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const t of this._recentlyUsed)if(!this._objects[t].inUse)return this._objects[t];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&!1===this._objects.some((t=>!t.inUse))}}const ao={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class ho{constructor(t,e){this.painter=t,this.terrain=e,this.pool=new oo(t.context,30,e.tileManager.tileSize*e.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,e){var i,n,s;this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e))),this._coordsAscending={};for(const e in t.tileManagers){this._coordsAscending[e]={};const i=t.tileManagers[e].getVisibleCoordinates(),n=t.tileManagers[e].getSource(),r=n instanceof et?n.terrainTileRanges:null;for(const t of i){const i=this.terrain.tileManager.getTerrainCoords(t,r);for(const t in i)(s=this._coordsAscending[e])[t]||(s[t]=[]),this._coordsAscending[e][t].push(i[t])}}this._rttFingerprints={};for(const e of t._order){const s=t._layers[e],r=s.source;if(ao[s.type]&&!this._rttFingerprints[r]){this._rttFingerprints[r]={};const e=null!==(n=null===(i=t.tileManagers[r])||void 0===i?void 0:i.getState().revision)&&void 0!==n?n:0;for(const t in this._coordsAscending[r])this._rttFingerprints[r][t]=`${this._coordsAscending[r][t].map((t=>t.key)).sort().join()}#${e}`}}for(const t of this._renderableTiles)for(const e in this._rttFingerprints){const i=this._rttFingerprints[e][t.tileID.key];i&&i!==t.rttFingerprint[e]&&(t.rtt=[])}}renderLayer(t,i){if(t.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),s=t.type,r=this.painter,o=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(ao[s]&&(this._prevType&&ao[this._prevType]||this._stacks.push([]),this._prevType=s,this._stacks[this._stacks.length-1].push(t.id),!o))return!0;if(ao[this._prevType]||ao[s]&&o){this._prevType=s;const t=this._stacks.length-1,i=this._stacks[t]||[];for(const s of this._renderableTiles){if(this.pool.isFull()&&(Zs(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(s),s.rtt[t]){const e=this.pool.getObjectForId(s.rtt[t].id);if(e.stamp===s.rtt[t].stamp){this.pool.useObject(e);continue}}const o=this.pool.getOrCreateFreeObject();this.pool.useObject(o),this.pool.stampObject(o),s.rtt[t]={id:o.id,stamp:o.stamp},r.context.bindFramebuffer.set(o.fbo.framebuffer),r.context.clear({color:e.bo.transparent,stencil:0}),r.currentStencilSource=void 0;for(const t of i){const e=r.style._layers[t],i=e.source?this._coordsAscending[e.source][s.tileID.key]:[s.tileID];r.context.viewport.set([0,0,o.fbo.width,o.fbo.height]),r._renderTileClippingMasks(e,i,!0),r.renderLayer(r,r.style.tileManagers[e.source],e,i,n),e.source&&(s.rttFingerprint[e.source]=this._rttFingerprints[e.source][s.tileID.key])}}return Zs(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects(),ao[s]}return!1}}const lo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Drag to rotate map, click to reset north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","GlobeControl.Enable":"Enable globe","GlobeControl.Disable":"Disable globe","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},co=i,uo={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:Qr,maplibreLogo:!1,refreshExpiredTiles:!0,canvasContextAttributes:{antialias:!1,preserveDrawingBuffer:!1,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,desynchronized:!1,contextType:void 0},scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],elevation:0,zoom:0,bearing:0,pitch:0,roll:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:e.c.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,experimentalZoomLevelsToOverscale:void 0,anisotropicFilterPitch:20};let fo=class extends Kr{get _ownerWindow(){var t,e;return(null===(e=null===(t=this._container)||void 0===t?void 0:t.ownerDocument)||void 0===e?void 0:e.defaultView)||window}constructor(t){var i,n,s;const r=Object.assign(Object.assign(Object.assign({},uo),t),{canvasContextAttributes:Object.assign(Object.assign({},uo.canvasContextAttributes),t.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Ye,h=new Qe;void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),null!==r.transformConstrain&&o.setConstrainOverride(r.transformConstrain),super(o,h,{bearingSnap:r.bearingSnap,zoomSnap:r.zoomSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new io,this._controls=[],this._mapId=e.ad(),this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(const t of Object.values(this.style._layers))if("custom"===t.type&&console.warn(`Custom layer with id '${t.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),t._listeners)for(const[e]of Object.entries(t._listeners))console.warn(`Custom layer with id '${t.id}' had event listeners for event '${e}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this.style.destroy(),this.style=null,this.fire(new e.n("webglcontextlost",{originalEvent:t}))}else this.fire(new e.n("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style&&(this.style.imageManager.images=this._lostContextStyle.images),this._lostContextStyle={style:null,images:null},this._setupPainter(),this.resize(),this._update(),this._resizeInternal(),this.fire(new e.n("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._zoomSnap=r.zoomSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},lo),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(r.anisotropicFilterPitch),void 0!==r.reduceMotion&&(a.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=u.addThrottleControl((()=>this.isMoving())),this._requestManager=new d(r.transformRequest),this._container=this._resolveContainer(r.container),r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.terrainFacilitator.depthDirty=!0,this._update(!0)})),this.once("idle",(()=>this._idleTriggered=!0)),"undefined"!=typeof window&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this.handlers=new Jr(this,r),this._hash=r.hash?new Js("string"==typeof r.hash&&r.hash||void 0).addTo(this):void 0,(null===(i=this._hash)||void 0===i?void 0:i._onHashChange())||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,e.e({},r.fitBoundsOptions,{duration:0}))));const l="string"==typeof r.style||!("globe"===(null===(s=null===(n=r.style)||void 0===n?void 0:n.projection)||void 0===s?void 0:s.type));this.resize(null,l),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new to("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new eo,r.logoPosition),this.on("style.load",(()=>{if(l||this._resizeTransform(),this.transform.unmodified){const t=e.V(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire(new e.n(`${t.dataType}data`,t))})),this.on("dataloading",(t=>{this.fire(new e.n(`${t.dataType}dataloading`,t))})),this.on("dataabort",(t=>{this.fire(new e.n("sourcedataabort",t))}))}_getMapId(){return this._mapId}setGlobalStateProperty(t,e){return this.style.setGlobalStateProperty(t,e),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(t,i){if(void 0===i&&(i=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!(null==t?void 0:t.onAdd))return this.fire(new e.l(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const s=this._controlPositions[i];return i.includes("bottom")?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(t){if(!(null==t?void 0:t.onRemove))return this.fire(new e.l(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(t);return i>-1&&this._controls.splice(i,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return Tt(this.transform,t)}calculateCameraOptionsFromTo(t,e,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLat(i,this.transform)),super.calculateCameraOptionsFromTo(t,e,i,n)}resize(t,i=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(i);const n=!this._moving;return n&&(this.stop(),this.fire(new e.n("movestart",t)).fire(new e.n("move",t))),this.fire(new e.n("resize",t)),n&&this.fire(new e.n("moveend",t)),this}_resizeInternal(t=!0){const[e,i]=this._containerDimensions(),n=this._getClampedPixelRatio(e,i);if(this._resizeCanvas(e,i,n),this.painter.resize(e,i,n),this.painter.overLimit()){const t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];const n=this._getClampedPixelRatio(e,i);this._resizeCanvas(e,i,n),this.painter.resize(e,i,n)}this._resizeTransform(t)}_resizeTransform(t=!0){var e;const[i,n]=this._containerDimensions();this.transform.resize(i,n,t),null===(e=this._requestedCameraState)||void 0===e||e.resize(i,n,t)}_getClampedPixelRatio(t,e){const{0:i,1:n}=this._maxCanvasSize,s=this.getPixelRatio(),r=t*s,o=e*s;return Math.min(r>i?i/r:1,o>n?n/o:1)*s}getPixelRatio(){var t;return null!==(t=this._overridePixelRatio)&&void 0!==t?t:devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(t){return this.transform.setMaxBounds(G.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom){const i=this.transform.zoom,n=this._getTransformForUpdate();return n.setMinZoom(t),this._applyUpdatedTransform(n),this._update(),i!==this.transform.zoom&&this.fire(new e.n("zoomstart")).fire(new e.n("zoom")).fire(new e.n("zoomend")).fire(new e.n("movestart")).fire(new e.n("move")).fire(new e.n("moveend")),this}throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(t){if((t=null==t?22:t)>=this.transform.minZoom){const i=this.transform.zoom,n=this._getTransformForUpdate();return n.setMaxZoom(t),this._applyUpdatedTransform(n),this._update(),i!==this.transform.zoom&&this.fire(new e.n("zoomstart")).fire(new e.n("zoom")).fire(new e.n("zoomend")).fire(new e.n("movestart")).fire(new e.n("move")).fire(new e.n("moveend")),this}throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch){const i=this.transform.pitch,n=this._getTransformForUpdate();return n.setMinPitch(t),this._applyUpdatedTransform(n),this._update(),i!==this.transform.pitch&&this.fire(new e.n("pitchstart")).fire(new e.n("pitch")).fire(new e.n("pitchend")).fire(new e.n("movestart")).fire(new e.n("move")).fire(new e.n("moveend")),this}throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(t){if((t=null==t?60:t)>180)throw new Error("maxPitch must be less than or equal to 180");if(t>=this.transform.minPitch){const i=this.transform.pitch,n=this._getTransformForUpdate();return n.setMaxPitch(t),this._applyUpdatedTransform(n),this._update(),i!==this.transform.pitch&&this.fire(new e.n("pitchstart")).fire(new e.n("pitch")).fire(new e.n("pitchend")).fire(new e.n("movestart")).fire(new e.n("move")).fire(new e.n("moveend")),this}throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if((t=null==t?20:t)>180)throw new Error("anisotropicFilterPitch must be less than or equal to 180");if(t<0)throw new Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(t){return this.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this.transform.setConstrainOverride(t),this._update()}project(t){return this.transform.locationToScreenPoint(e.W.convert(t),this.style&&this.terrain)}unproject(t){return this.transform.screenPointToLocation(e.P.convert(t),this.terrain)}isMoving(){var t;return this._moving||(null===(t=this.handlers)||void 0===t?void 0:t.isMoving())}isZooming(){var t;return this._zooming||(null===(t=this.handlers)||void 0===t?void 0:t.isZooming())}isRotating(){var t;return this._rotating||(null===(t=this.handlers)||void 0===t?void 0:t.isRotating())}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let n=!1;const s=s=>{const r=e.filter((t=>this.getLayer(t))),o=0!==r.length?this.queryRenderedFeatures(s.point,{layers:r}):[];o.length?n||(n=!0,i.call(this,new ar(t,this,s.originalEvent,{features:o}))):n=!1};return{layers:e,listener:i,delegates:{mousemove:s,mouseout:()=>{n=!1}}}}if("mouseleave"===t||"mouseout"===t){let n=!1;const s=s=>{const r=e.filter((t=>this.getLayer(t)));(0!==r.length?this.queryRenderedFeatures(s.point,{layers:r}):[]).length?n=!0:n&&(n=!1,i.call(this,new ar(t,this,s.originalEvent)))},r=e=>{n&&(n=!1,i.call(this,new ar(t,this,e.originalEvent)))};return{layers:e,listener:i,delegates:{mousemove:s,mouseout:r}}}{const n=t=>{const n=e.filter((t=>this.getLayer(t))),s=0!==n.length?this.queryRenderedFeatures(t.point,{layers:n}):[];s.length&&(t.features=s,i.call(this,t),delete t.features)};return{layers:e,listener:i,delegates:{[t]:n}}}}_saveDelegatedListener(t,e){var i;this._delegatedListeners||(this._delegatedListeners={}),(i=this._delegatedListeners)[t]||(i[t]=[]),this._delegatedListeners[t].push(e)}_removeDelegatedListener(t,e,i){var n;if(!(null===(n=this._delegatedListeners)||void 0===n?void 0:n[t]))return;const s=this._delegatedListeners[t];for(let t=0;t<s.length;t++){const n=s[t];if(n.listener===i&&n.layers.length===e.length&&n.layers.every((t=>e.includes(t)))){for(const t in n.delegates)this.off(t,n.delegates[t]);return void s.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);const n="string"==typeof e?[e]:e,s=this._createDelegatedListener(t,n,i);this._saveDelegatedListener(t,s);for(const t in s.delegates)this.on(t,s.delegates[t]);return{unsubscribe:()=>{this._removeDelegatedListener(t,n,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);const n="string"==typeof e?[e]:e,s=this._createDelegatedListener(t,n,i);for(const e in s.delegates){const r=s.delegates[e];s.delegates[e]=(...e)=>{this._removeDelegatedListener(t,n,i),r(...e)}}this._saveDelegatedListener(t,s);for(const t in s.delegates)this.once(t,s.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,i){if(!this.style)return[];let n;const s=t instanceof e.P||Array.isArray(t),r=s?t:[[0,0],[this.transform.width,this.transform.height]];if(i||(i=(s?{}:t)||{}),r instanceof e.P||"number"==typeof r[0])n=[e.P.convert(r)];else{const t=e.P.convert(r[0]),i=e.P.convert(r[1]);n=[t,new e.P(i.x,t.y),i,new e.P(t.x,i.y),t]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,i){return!1!==(i=e.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(t,i))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){const e=this._locale[t];if(null==e)throw new Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){var i,n,s;if(null===(i=this._diffStyleRequest)||void 0===i||i.abort(),this._diffStyleRequest=null,e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));const r=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Oi(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,r):this.style.loadJSON(t,e,r),this):(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),null===(s=null===(n=this.style)||void 0===n?void 0:n.projection)||void 0===s||s.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Oi(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(t,i){return e._(this,void 0,void 0,(function*(){var n;if(null===(n=this._diffStyleRequest)||void 0===n||n.abort(),"string"==typeof t){const n=t;this._diffStyleRequest=new AbortController;const s=this._diffStyleRequest;try{const t=yield this._requestManager.transformRequest(n,"Style");if(s.signal.aborted)return void(this._diffStyleRequest=null);const r=yield e.k(t,s);this._diffStyleRequest=null,this._updateDiff(r.data,i)}catch(t){this._diffStyleRequest=null,e.$(t)||this.fire(new e.l(e.d(t)))}}else"object"==typeof t&&(this._diffStyleRequest=null,this._updateDiff(t,i))}))}_updateDiff(t,i){try{this.style.setState(t,i)&&this._update(!0)}catch(n){e.w(`Unable to perform style diff: ${e.d(n).message}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();e.w("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){var i;const n=null===(i=this.style)||void 0===i?void 0:i.tileManagers[t];if(void 0!==n)return n.loaded();this.fire(new e.l(new Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){const i=this.style.tileManagers[t.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===t.source&&e.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===t.source&&e.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new ro(this.painter,i,t),this.painter.renderToTexture=new ho(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=e=>{var i;"style"===e.dataType?this.terrain.tileManager.freeRtt():"source"===e.dataType&&e.tile&&(e.sourceId!==t.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=e.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(e.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new e.n("terrain",{terrain:t})),this}getTerrain(){var t,e;return null!==(e=null===(t=this.terrain)||void 0===t?void 0:t.options)&&void 0!==e?e:null}areTilesLoaded(){var t;const e=null===(t=this.style)||void 0===t?void 0:t.tileManagers;for(const t of Object.values(e))if(!t.areTilesLoaded())return!1;return!0}removeSource(t){return this.style.removeSource(t),this._update(!0)}getSource(t){return this.style.getSource(t)}setSourceTileLodParams(t,e,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=Mt(Math.max(1,t),Math.max(1,e))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=Mt(Math.max(1,t),Math.max(1,e));return this._update(!0),this}refreshTiles(t,i){const n=this.style.tileManagers[t];if(!n)throw new Error(`There is no tile manager with ID "${t}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map((t=>new e.aa(t.z,t.x,t.y))))}addImage(t,i,n={}){const{pixelRatio:s=1,sdf:r=!1,stretchX:o,stretchY:h,content:l,textFitWidth:c,textFitHeight:u}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||e.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new e.l(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:n,height:a,data:f}=i,d=i;return this.style.addImage(t,{data:new e.R({width:n,height:a},new Uint8Array(f)),pixelRatio:s,stretchX:o,stretchY:h,content:l,textFitWidth:c,textFitHeight:u,sdf:r,version:0,userImage:d}),d.onAdd&&d.onAdd(this,t),this}}{const{width:n,height:f,data:d}=a.getImageData(i);this.style.addImage(t,{data:new e.R({width:n,height:f},d),pixelRatio:s,stretchX:o,stretchY:h,content:l,textFitWidth:c,textFitHeight:u,sdf:r,version:0})}}updateImage(t,i){const n=this.style.getImage(t);if(!n)return this.fire(new e.l(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=i instanceof HTMLImageElement||e.b(i)?a.getImageData(i):i,{width:r,height:o,data:h}=s;if(void 0===r||void 0===o)return this.fire(new e.l(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(r!==n.data.width||o!==n.data.height)return this.fire(new e.l(new Error("The width and height of the updated image must be that same as the previous version of the image")));const l=!(i instanceof HTMLImageElement||e.b(i));return n.data.replace(h,l),this.style.updateImage(t,n),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.l(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}loadImage(t){return e._(this,void 0,void 0,(function*(){return u.getImage(yield this._requestManager.transformRequest(t,"Image"),new AbortController)}))}listImages(){return this.style.listImages()}addLayer(t,e){return this._lazyInitEmptyStyle(),this.style.addLayer(t,e),this._update(!0)}moveLayer(t,e){return this.style.moveLayer(t,e),this._update(!0)}removeLayer(t){return this.style.removeLayer(t),this._update(!0)}getLayer(t){return this.style.getLayer(t)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(t,e,i){return this.style.setLayerZoomRange(t,e,i),this._update(!0)}setFilter(t,e,i={}){return this.style.setFilter(t,e,i),this._update(!0)}getFilter(t){return this.style.getFilter(t)}setPaintProperty(t,e,i,n={}){return this.style.setPaintProperty(t,e,i,n),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,n={}){return this.style.setLayoutProperty(t,e,i,n),this._update(!0)}getLayoutProperty(t,e){return this.style.getLayoutProperty(t,e)}setGlyphs(t,e={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(t,e),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(t,e,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(t,e,i,(t=>{t||this._update(!0)})),this}removeSprite(t){return this._lazyInitEmptyStyle(),this.style.removeSprite(t),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSprite(t,e,(t=>{t||this._update(!0)})),this}setLight(t,e={}){return this._lazyInitEmptyStyle(),this.style.setLight(t,e),this._update(!0)}getLight(){return this.style.getLight()}setSky(t,e={}){return this._lazyInitEmptyStyle(),this.style.setSky(t,e),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(t,e){return this.style.setFeatureState(t,e),this._update()}removeFeatureState(t,e){return this.style.removeFeatureState(t,e),this._update()}getFeatureState(t){return this.style.getFeatureState(t)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let t=0,e=0;return this._container&&(t=this._container.clientWidth||400,e=this._container.clientHeight||300),[t,e]}_setupResizeObserver(){var t;let e=!1;const i=Xs((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())}),50),n=null!==(t=this._ownerWindow.ResizeObserver)&&void 0!==t?t:ResizeObserver;this._resizeObserver=new n((t=>{e?i(t):e=!0})),this._resizeObserver.observe(this._container)}_resolveContainer(t){if("string"==typeof t){const e=document.getElementById(t);if(!e)throw new Error(`Container '${t}' not found.`);return e}if(t instanceof HTMLElement)return t;if(t&&"object"==typeof t&&1===t.nodeType)return t;throw new Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){const t=this._container;t.classList.add("maplibregl-map");const e=this._canvasContainer=f.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=f.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const s=this._controlContainer=f.create("div","maplibregl-control-container",t),r=this._controlPositions={};for(const t of["top-left","top-right","bottom-left","bottom-right"])r[t]=f.create("div",`maplibregl-ctrl-${t} `,s);this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,e,i){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){const t=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let e=null;this._canvas.addEventListener("webglcontextcreationerror",(i=>{e={requestedAttributes:t},i&&(e.statusMessage=i.statusMessage,e.type=i.type)}),{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,t):this._canvas.getContext("webgl2",t)||this._canvas.getContext("webgl",t),!i){const t="Failed to initialize WebGL";throw e?(e.message=t,new Error(JSON.stringify(e))):new Error(t)}this.painter=new Ys(i,this.transform)}migrateProjection(t,i){super.migrateProjection(t,i),this.painter.transform=t,this.fire(new e.n("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){var e;return(null===(e=this.style)||void 0===e?void 0:e._loaded)?(this._styleDirty||(this._styleDirty=t),this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(t){return this._update(),this._renderTaskQueue.add(t)}_cancelRenderFrame(t){this._renderTaskQueue.remove(t)}_render(t){var i,n,s,r,o,a;const h=this._idleTriggered?this._fadeDuration:0,c=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=l();this.style.zoomHistory.update(t,i);const n=new e.J(t,{now:i,fadeDuration:h,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=n.crossFadingFactor();1===s&&s===this._crossFadingFactor||(u=!0,this._crossFadingFactor=s),this.style.update(n)}const f=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==c;null===(s=this.style.projection)||void 0===s||s.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState,null===(o=this.style.projection)||void 0===o?void 0:o.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||f)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=null===(a=this.style)||void 0===a?void 0:a._updatePlacement(this.transform,this.showCollisionBoxes,h,this._crossSourceCollisions,f),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:h,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new e.n("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.n("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new e.n("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var t,i;this._hash&&this._hash.remove();for(const t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),null===(t=this._diffStyleRequest)||void 0===t||t.abort(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),u.removeThrottleControl(this._imageQueueHandle),null===(i=this._resizeObserver)||void 0===i||i.disconnect();const n=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==n?void 0:n.loseContext)&&n.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),this._removed=!0,this.fire(new e.n("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,(t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!e.$(t)&&!function(t){return t.message===as}(t))throw t}}),(()=>{}),this._ownerWindow))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(t){this._showTileBoundaries!==t&&(this._showTileBoundaries=t,this._update())}get showPadding(){return!!this._showPadding}set showPadding(t){this._showPadding!==t&&(this._showPadding=t,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(t){this._showCollisionBoxes!==t&&(this._showCollisionBoxes=t,t?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(t){this._showOverdrawInspector!==t&&(this._showOverdrawInspector=t,this._update())}get repaint(){return!!this._repaint}set repaint(t){this._repaint!==t&&(this._repaint=t,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(t){this._vertices=t,this._update()}get version(){return co}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const po={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};class mo{constructor(t,i,n=!1){this.mousedown=t=>{this.startMove(t,f.mousePos(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,f.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1!==t.targetTouches.length?this.reset():(this._startPos=this._lastPos=f.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend))},this.touchmove=t=>{1!==t.targetTouches.length?this.reset():(this._lastPos=f.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos))},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const s=new Sr;this._rotatePitchHandler=new vr({clickTolerance:3,move:(t,s)=>{const r=i.getBoundingClientRect(),o=new e.P((r.bottom-r.top)/2,(r.right-r.left)/2);return{bearingDelta:e.cx(new e.P(t.x,s.y),s,o),pitchDelta:n?-.5*(s.y-t.y):void 0}},moveStateManager:s,enable:!0,assignEvents:()=>{}}),this.map=t,i.addEventListener("mousedown",this.mousedown),i.addEventListener("touchstart",this.touchstart,{passive:!1}),i.addEventListener("touchcancel",this.reset)}startMove(t,e){this._rotatePitchHandler.dragStart(t,e),f.disableDrag()}move(t,e){const i=this.map,{bearingDelta:n,pitchDelta:s}=this._rotatePitchHandler.dragMove(t,e)||{};n&&i.setBearing(i.getBearing()+n),s&&i.setPitch(i.getPitch()+s)}off(){const t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){f.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}}let _o;function go(t,i,n,s=!1){if(s||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==t?void 0:t.wrap();const r=new e.W(t.lng,t.lat);if(t=new e.W(t.lng,t.lat),i){const s=new e.W(t.lng-360,t.lat),r=new e.W(t.lng+360,t.lat),o=n.locationToScreenPoint(t).distSqr(i);n.locationToScreenPoint(s).distSqr(i)<o?t=s:n.locationToScreenPoint(r).distSqr(i)<o&&(t=r)}for(;Math.abs(t.lng-n.center.lng)>180;){const e=n.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t.lng!==r.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(t))?t:r}const vo={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function yo(t,e,i){const n=t.classList;for(const t in vo)n.remove(`maplibregl-${i}-anchor-${t}`);n.add(`maplibregl-${i}-anchor-${e}`)}class wo extends e.E{constructor(t){if(super(),this._onClick=t=>{this.fire(new e.n("click",{originalEvent:t}))},this._onKeyPress=t=>{"Space"!==t.code&&"Enter"!==t.code||this.togglePopup()},this._onMapClick=t=>{const e=t.originalEvent.target,i=this._element;this._popup&&(e===i||i.contains(e))&&this.togglePopup()},this._update=t=>{if(!this._map)return;const e=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==t?void 0:t.type)||"render"===(null==t?void 0:t.type)&&!e)&&this._map.once("render",this._update),this._lngLat=go(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||t&&"moveend"!==t.type||(this._pos=this._pos.round()),this._element.style.transform=`${vo[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`,a.frameAsync(new AbortController,this._map._ownerWindow).then((()=>{this._updateOpacity("moveend"===(null==t?void 0:t.type))})).catch((()=>{}))},this._onMove=t=>{if(!this._isDragging){const e=this._clickTolerance||this._map._clickTolerance;this._isDragging=t.point.dist(this._pointerdownPos)>=e}this._isDragging&&(this._pos=t.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new e.n("dragstart"))),this.fire(new e.n("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new e.n("dragend")),this._state="inactive"},this._addDragHandler=t=>{this._element.contains(t.originalEvent.target)&&(t.preventDefault(),this._positionDelta=t.point.sub(this._pos).add(this._offset),this._pointerdownPos=t.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=(null==t?void 0:t.anchor)||"center",this._color=(null==t?void 0:t.color)||"#3FB1CE",this._scale=(null==t?void 0:t.scale)||1,this._draggable=(null==t?void 0:t.draggable)||!1,this._clickTolerance=(null==t?void 0:t.clickTolerance)||0,this._subpixelPositioning=(null==t?void 0:t.subpixelPositioning)||!1,this._isDragging=!1,this._state="inactive",this._rotation=(null==t?void 0:t.rotation)||0,this._rotationAlignment=(null==t?void 0:t.rotationAlignment)||"auto",this._pitchAlignment=(null==t?void 0:t.pitchAlignment)&&"auto"!==t.pitchAlignment?t.pitchAlignment:this._rotationAlignment,this.setOpacity(null==t?void 0:t.opacity,null==t?void 0:t.opacityWhenCovered),null==t?void 0:t.element)this._element=t.element,this._offset=e.P.convert((null==t?void 0:t.offset)||[0,0]);else{this._defaultMarker=!0,this._element=f.create("div");const i=f.createNS("http://www.w3.org/2000/svg","svg"),n=41,s=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${s}px`),i.setAttributeNS(null,"viewBox",`0 0 ${s} ${n}`);const r=f.createNS("http://www.w3.org/2000/svg","g");r.setAttributeNS(null,"stroke","none"),r.setAttributeNS(null,"stroke-width","1"),r.setAttributeNS(null,"fill","none"),r.setAttributeNS(null,"fill-rule","evenodd");const o=f.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"fill-rule","nonzero");const a=f.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const h=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const t of h){const e=f.createNS("http://www.w3.org/2000/svg","ellipse");e.setAttributeNS(null,"opacity","0.04"),e.setAttributeNS(null,"cx","10.5"),e.setAttributeNS(null,"cy","5.80029008"),e.setAttributeNS(null,"rx",t.rx),e.setAttributeNS(null,"ry",t.ry),a.appendChild(e)}const l=f.createNS("http://www.w3.org/2000/svg","g");l.setAttributeNS(null,"fill",this._color);const c=f.createNS("http://www.w3.org/2000/svg","path");c.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),l.appendChild(c);const u=f.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"opacity","0.25"),u.setAttributeNS(null,"fill","#000000");const d=f.createNS("http://www.w3.org/2000/svg","path");d.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),u.appendChild(d);const p=f.createNS("http://www.w3.org/2000/svg","g");p.setAttributeNS(null,"transform","translate(6.0, 7.0)"),p.setAttributeNS(null,"fill","#FFFFFF");const m=f.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const _=f.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#000000"),_.setAttributeNS(null,"opacity","0.25"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962");const g=f.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#FFFFFF"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962"),m.appendChild(_),m.appendChild(g),o.appendChild(a),o.appendChild(l),o.appendChild(u),o.appendChild(p),o.appendChild(m),i.appendChild(o),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",s*this._scale+"px"),this._element.appendChild(i),this._offset=e.P.convert((null==t?void 0:t.offset)||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",(t=>{t.preventDefault()})),this._element.addEventListener("mousedown",(t=>{t.preventDefault()})),yo(this._element,this._anchor,"marker"),null==t?void 0:t.className)for(const e of t.className.split(" "))this._element.classList.add(e);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),t.on("projectiontransition",this._update),this._element.addEventListener("click",this._onClick),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),this._element.removeEventListener("click",this._onClick),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.W.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const e=38.1,i=13.5,n=Math.abs(i)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-e],"bottom-left":[n,-1*(e-i+n)],"bottom-right":[-n,-1*(e-i+n)],left:[i,-1*(e-i)],right:[-i,-1*(e-i)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var i,n;const s=null===(i=this._map)||void 0===i?void 0:i.terrain,r=this._map.transform.isLocationOccluded(this._lngLat);if(!s||r){const t=r?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==t&&(this._element.style.opacity=t,this._element.classList.toggle("maplibregl-marker-covered",r)))}if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout((()=>{this._opacityTimeout=null}),100)}const o=this._map,a=o.terrain.depthAtPoint(this._pos),h=o.terrain.getElevationForLngLat(this._lngLat,o.transform);if(o.transform.lngLatToCameraDepth(this._lngLat,h)-a<.006)return this._element.style.opacity=this._opacity,void this._element.classList.remove("maplibregl-marker-covered");const l=-this._offset.y/o.transform.pixelsPerMeter,c=Math.sin(o.getPitch()*Math.PI/180)*l,u=o.terrain.depthAtPoint(new e.P(this._pos.x,this._pos.y-this._offset.y)),f=o.transform.lngLatToCameraDepth(this._lngLat,h+c)-u>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&f&&this._popup.remove(),this._element.style.opacity=f?this._opacityWhenCovered:this._opacity,this._element.classList.toggle("maplibregl-marker-covered",f)}getOffset(){return this._offset}setOffset(t){return this._offset=e.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&"auto"!==t?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,e){return(void 0===this._opacity||void 0===t&&void 0===e)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==t&&(this._opacity=String(t)),void 0!==e&&(this._opacityWhenCovered=String(e)),this._map&&this._updateOpacity(!0),this}}const bo={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let xo=0,Mo=!1;const So={maxWidth:100,unit:"metric"};function zo(t,e,i){const n=(null==i?void 0:i.maxWidth)||100,s=t._container.clientHeight/2,r=t._container.clientWidth/2,o=t.unproject([r-n/2,s]),a=t.unproject([r+n/2,s]),h=Math.round(t.project(a).x-t.project(o).x),l=Math.min(n,h,t._container.clientWidth),c=o.distanceTo(a);if("imperial"===(null==i?void 0:i.unit)){const i=3.2808*c;i>5280?To(e,l,i/5280,t._getUIString("ScaleControl.Miles")):To(e,l,i,t._getUIString("ScaleControl.Feet"))}else"nautical"===(null==i?void 0:i.unit)?To(e,l,c/1852,t._getUIString("ScaleControl.NauticalMiles")):c>=1e3?To(e,l,c/1e3,t._getUIString("ScaleControl.Kilometers")):To(e,l,c,t._getUIString("ScaleControl.Meters"))}function To(t,e,i,n){const s=function(t){const e=Math.pow(10,`${Math.floor(t)}`.length-1);let i=t/e;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(t){const e=Math.pow(10,Math.ceil(-Math.log(t)/Math.LN10));return Math.round(t*e)/e}(i),e*i}(i);t.style.width=e*(s/i)+"px",t.innerHTML=`${s}&nbsp;${n}`}const Eo={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},Ao=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Po(t){if(t){if("number"==typeof t){const i=Math.round(Math.abs(t)/Math.SQRT2);return{center:new e.P(0,0),top:new e.P(0,t),"top-left":new e.P(i,i),"top-right":new e.P(-i,i),bottom:new e.P(0,-t),"bottom-left":new e.P(i,-i),"bottom-right":new e.P(-i,-i),left:new e.P(t,0),right:new e.P(-t,0)}}if(t instanceof e.P||Array.isArray(t)){const i=e.P.convert(t);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:e.P.convert(t.center||[0,0]),top:e.P.convert(t.top||[0,0]),"top-left":e.P.convert(t["top-left"]||[0,0]),"top-right":e.P.convert(t["top-right"]||[0,0]),bottom:e.P.convert(t.bottom||[0,0]),"bottom-left":e.P.convert(t["bottom-left"]||[0,0]),"bottom-right":e.P.convert(t["bottom-right"]||[0,0]),left:e.P.convert(t.left||[0,0]),right:e.P.convert(t.right||[0,0])}}return Po(new e.P(0,0))}const Co=i;t.AJAXError=e.cG,t.EXTENT=e.a6,t.Event=e.n,t.Evented=e.E,t.LngLat=e.W,t.MercatorCoordinate=e.a7,t.Point=e.P,t.addProtocol=e.cH,t.config=e.c,t.removeProtocol=e.cI,t.AttributionControl=to,t.BoxZoomHandler=dr,t.CanvasSource=nt,t.CooperativeGesturesHandler=Wr,t.DoubleClickZoomHandler=Nr,t.DragPanHandler=Vr,t.DragRotateHandler=qr,t.EdgeInsets=Ue,t.FullscreenControl=class extends e.E{constructor(t={}){var i;super(),this._onFullscreenChange=()=>{var t;let e=window.document.fullscreenElement||window.document.webkitFullscreenElement;for(;null===(t=null==e?void 0:e.shadowRoot)||void 0===t?void 0:t.fullscreenElement;)e=e.shadowRoot.fullscreenElement;e===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,this._pseudo=null!==(i=t.pseudo)&&void 0!==i&&i,(null==t?void 0:t.container)&&(t.container instanceof HTMLElement?this._container=t.container:e.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=f.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const t=this._fullscreenButton=f.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);f.create("span","maplibregl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const t=this._getTitle();this._fullscreenButton.setAttribute("aria-label",t),this._fullscreenButton.title=t}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new e.n("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new e.n("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){this._pseudo?this._togglePseudoFullScreen():window.document.exitFullscreen?window.document.exitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._pseudo?this._togglePseudoFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},t.GeoJSONSource=tt,t.GeolocateControl=class extends e.E{constructor(t){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.n("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new e.n("geolocate",t)),this._finish()}},this._updateCamera=t=>{const i=new e.W(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,s=this._map.getBearing(),r=e.e({bearing:s},this.options.fitBoundsOptions),o=G.fromLngLat(i,n);this._map.fitBounds(o,r,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const i=new e.W(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=t.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=t=>{if(this._map){if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&Mo)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new e.n("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._onMoveStart=t=>{if(!this._map)return;const i=(null==t?void 0:t[0])instanceof ResizeObserverEntry;t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new e.n("trackuserlocationend")),this.fire(new e.n("userlocationlostfocus")))},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",(t=>{t.preventDefault()})),this._geolocateButton=f.create("button","maplibregl-ctrl-geolocate",this._container),f.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(!1===t){e.w("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}else{const t=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=t,this._geolocateButton.setAttribute("aria-label",t)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=f.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new wo({element:this._dotElement}),this._circleElement=f.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new wo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",(()=>this.trigger())),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",this._onMoveStart)}},this.options=e.e({},bo,t)}onAdd(t){return this._map=t,this._container=f.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return e._(this,arguments,void 0,(function*(t=!1){if(void 0!==_o&&!t)return _o;if(void 0===window.navigator.permissions)return _o=!!window.navigator.geolocation,_o;try{const t=yield window.navigator.permissions.query({name:"geolocation"});_o="denied"!==t.state}catch(t){_o=!!window.navigator.geolocation}return _o}))}().then((t=>this._finishSetupUI(t))),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("movestart",this._onMoveStart),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,xo=0,Mo=!1}_isOutOfMapMaxBounds(t){const e=this._map.getMaxBounds(),i=t.coords;return e&&(i.longitude<e.getWest()||i.longitude>e.getEast()||i.latitude<e.getSouth()||i.latitude>e.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const t=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&t))return;const e=this._map.project(t),i=this._map.unproject([e.x+100,e.y]),n=t.distanceTo(i)/100,s=2*this._accuracy/n;this._circleElement.style.width=`${s.toFixed(2)}px`,this._circleElement.style.height=`${s.toFixed(2)}px`}trigger(){if(!this._setup)return e.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.n("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":xo--,Mo=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new e.n("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.n("trackuserlocationstart")),this.fire(new e.n("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let t;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),xo++,xo>1?(t={maximumAge:6e5,timeout:0},Mo=!0):(t=this.options.positionOptions,Mo=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,t)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},t.GlobeControl=class{constructor(){this._toggleProjection=()=>{var t;const e=null===(t=this._map.getProjection())||void 0===t?void 0:t.type;this._map.setProjection("mercator"!==e&&e?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var t;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(t=this._map.getProjection())||void 0===t?void 0:t.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(t){return this._map=t,this._container=f.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=f.create("button","maplibregl-ctrl-globe",this._container),f.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._map.on("projectiontransition",this._updateGlobeIcon),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateGlobeIcon),this._map.off("projectiontransition",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},t.Hash=Js,t.ImageSource=et,t.KeyboardHandler=Or,t.LngLatBounds=G,t.LogoControl=eo,t.Map=fo,t.MapLibreMap=fo,t.MapMouseEvent=ar,t.MapTouchEvent=hr,t.MapWheelEvent=lr,t.Marker=wo,t.NavigationControl=class{constructor(t){this._updateZoomButtons=()=>{const t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom();this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(t,e)=>{const i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=e.e({},po,t),this._container=f.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),f.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),f.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=f.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new mo(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){const i=f.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},t.Popup=class extends e.E{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new e.n("close"))),this),this._update=t=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=f.create("div","maplibregl-popup",this._map.getContainer()),this._tip=f.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}let e;if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=go(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),t&&"point"in t&&t.point&&(e=t.point),this._trackPointer&&!e)return;const i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let n=this.options.anchor;const s=Po(this.options.offset);if(!n){const t=this._container.offsetWidth,e=this._container.offsetHeight,r=function(t){var e,i,n,s;return t?{top:null!==(e=t.top)&&void 0!==e?e:0,right:null!==(i=t.right)&&void 0!==i?i:0,bottom:null!==(n=t.bottom)&&void 0!==n?n:0,left:null!==(s=t.left)&&void 0!==s?s:0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);let o;o=i.y+s.bottom.y<e+r.top?["top"]:i.y>this._map.transform.height-e-r.bottom?["bottom"]:[],i.x<t/2+r.left?o.push("left"):i.x>this._map.transform.width-t/2-r.right&&o.push("right"),n=0===o.length?"bottom":o.join("-")}let r=i.add(s[n]);this.options.subpixelPositioning||(r=r.round()),this._container.style.transform=`${vo[n]} translate(${r.x}px,${r.y}px)`,yo(this._container,n,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=e.e(Object.create(Eo),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new e.n("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.W.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){const e=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=t;n=i.firstChild,n;)e.appendChild(n);return this.setDOMContent(e)}getMaxWidth(){var t;return null===(t=this._container)||void 0===t?void 0:t.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=f.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=f.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const t=this._container.querySelector(Ao);t&&t.focus()}},t.RasterDEMTileSource=W,t.RasterTileSource=Z,t.ScaleControl=class{constructor(t){this._onMove=()=>{zo(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,zo(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},So),t)}getDefaultPosition(){return"bottom-left"}onAdd(t){return this._map=t,this._container=f.create("div","maplibregl-ctrl maplibregl-ctrl-scale",t.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._onMove),this._map=void 0}},t.ScrollZoomHandler=Br,t.Style=Oi,t.TerrainControl=class{constructor(t){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=t}onAdd(t){return this._map=t,this._container=f.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=f.create("button","maplibregl-ctrl-terrain",this._container),f.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){this._container.remove(),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},t.TwoFingersTouchPitchHandler=kr,t.TwoFingersTouchRotateHandler=Fr,t.TwoFingersTouchZoomHandler=Cr,t.TwoFingersTouchZoomRotateHandler=Zr,t.VectorTileSource=q,t.VideoSource=it,t.addSourceType=(t,i)=>e._(void 0,void 0,void 0,(function*(){if(rt(t))throw new Error(`A source type called "${t}" already exists.`);((t,e)=>{st[t]=e})(t,i)})),t.clearPrewarmedResources=function(){const t=I;t&&(t.isPreloaded()&&1===t.numActive()?(t.release(C),I=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},t.createTileMesh=li,t.getGlobalDispatcher=j,t.getMaxParallelImageRequests=function(){return e.c.MAX_PARALLEL_IMAGE_REQUESTS},t.getRTLTextPluginStatus=function(){return lt().getRTLTextPluginStatus()},t.getVersion=function(){return Co},t.getWorkerCount=function(){return D.workerCount},t.getWorkerUrl=function(){return e.c.WORKER_URL},t.importScriptInWorkers=function(t){return j().broadcast("IS",t)},t.isTimeFrozen=function(){return h.isFrozen()},t.now=l,t.prewarm=function(){$().acquire(C)},t.restoreNow=function(){h.restoreNow()},t.setMaxParallelImageRequests=function(t){e.c.MAX_PARALLEL_IMAGE_REQUESTS=t},t.setNow=function(t){h.setNow(t)},t.setRTLTextPlugin=function(t,e){return lt().setRTLTextPlugin(t,e)},t.setWorkerCount=function(t){D.workerCount=t},t.setWorkerUrl=function(t){e.c.WORKER_URL=t}})),t}()),s=o.exports,n.MaplibreGL=n.Layer.extend({options:{updateInterval:32,padding:.1,interactive:!1,pane:"tilePane"},initialize:function(t){n.setOptions(this,t),this._throttledUpdate=n.Util.throttle(this._update,this.options.updateInterval,this)},onAdd:function(t){this._container||this._initContainer();var e=this.getPaneName();t.getPane(e).appendChild(this._container),this._initGL(),this._offset=this._map.containerPointToLayerPoint([0,0]),t.options.zoomAnimation&&n.DomEvent.on(t._proxy,n.DomUtil.TRANSITION_END,this._transitionEnd,this)},onRemove:function(t){this._map._proxy&&this._map.options.zoomAnimation&&n.DomEvent.off(this._map._proxy,n.DomUtil.TRANSITION_END,this._transitionEnd,this);var e=this.getPaneName();t.getPane(e).removeChild(this._container),this._glMap.remove(),this._glMap=null},getEvents:function(){return{move:this._throttledUpdate,zoomanim:this._animateZoom,zoom:this._pinchZoom,zoomstart:this._zoomStart,zoomend:this._zoomEnd,resize:this._resize}},getAttribution:function(){if(this.options.attributionControl)return this.options.attributionControl.customAttribution;var t=this._glMap;if(t&&!1!==this.options.attributionControl){var e=t.getStyle();if(e&&e.sources)return Object.keys(e.sources).map((function(e){var i=t.getSource(e);return i&&"string"==typeof i.attribution?i.attribution.trim():null})).filter(Boolean).join(", ")}return""},getMaplibreMap:function(){return this._glMap},getCanvas:function(){return this._glMap.getCanvas()},getSize:function(){return this._map.getSize().multiplyBy(1+2*this.options.padding)},getBounds:function(){var t=this.getSize().multiplyBy(.5),e=this._map.latLngToContainerPoint(this._map.getCenter());return n.latLngBounds(this._map.containerPointToLatLng(e.subtract(t)),this._map.containerPointToLatLng(e.add(t)))},getContainer:function(){return this._container},getPaneName:function(){return this._map.getPane(this.options.pane)?this.options.pane:"tilePane"},_roundPoint:function(t){return{x:Math.round(t.x),y:Math.round(t.y)}},_initContainer:function(){var t=this._container=n.DomUtil.create("div","leaflet-gl-layer");this._resizeContainer();var e=this._map.getSize().multiplyBy(this.options.padding),i=this._map.containerPointToLayerPoint([0,0]).subtract(e);n.DomUtil.setPosition(t,this._roundPoint(i))},_resizeContainer:function(){var t=this.getSize();this._container.style.width=t.x+"px",this._container.style.height=t.y+"px"},_initGL:function(){var t=this._map.getCenter(),e=n.extend({},this.options,{container:this._container,center:[t.lng,t.lat],zoom:this._map.getZoom()-1,attributionControl:!1});this._glMap=new s.Map(e);var i=this._map,r=this.getAttribution(),o=this.getAttribution.bind(this);this._glMap.on("load",(function(){i&&i.attributionControl&&(i.attributionControl.removeAttribution(r),i.attributionControl.addAttribution(o()))}));var a=Object.getPrototypeOf(this._glMap.transform),h=Object.getOwnPropertyDescriptor(a,"latRange");(!h||h.set||h.writable)&&(this._glMap.transform.latRange=null);var l=Object.getOwnPropertyDescriptor(a,"maxValidLatitude");(!l||l.set||l.writable)&&(this._glMap.transform.maxValidLatitude=1/0),this._glMap.transform._helper&&this._glMap.transform._helper._latRange&&(this._glMap.transform._helper._latRange=[-1/0,1/0]),this._transformGL(this._glMap),this._glMap._actualCanvas=this._glMap._canvas.canvas?this._glMap._canvas.canvas:this._glMap._canvas;var c=this._glMap._actualCanvas;n.DomUtil.addClass(c,"leaflet-image-layer"),n.DomUtil.addClass(c,"leaflet-zoom-animated"),this.options.interactive&&n.DomUtil.addClass(c,"leaflet-interactive"),this.options.className&&n.DomUtil.addClass(c,this.options.className)},_update:function(){if(this._map&&(this._offset=this._map.containerPointToLayerPoint([0,0]),!this._zooming)){var t=this._container,e=this._glMap,i=this._map.getSize().multiplyBy(this.options.padding),s=this._map.containerPointToLayerPoint([0,0]).subtract(i);n.DomUtil.setPosition(t,this._roundPoint(s)),this._transformGL(e)}},_transformGL:function(t){var e=this._map.getCenter(),i=t._getTransformForUpdate();i.setCenter?(i.setCenter(s.LngLat.convert([e.lng,e.lat])),i.setZoom(this._map.getZoom()-1),t.transform.apply(i)):((i=t.transform).center=s.LngLat.convert([e.lng,e.lat]),i.zoom=this._map.getZoom()-1),t._fireMoveEvents()},_pinchZoom:function(){this._glMap.jumpTo({zoom:this._map.getZoom()-1,center:this._map.getCenter()})},_animateZoom:function(t){var e=this._map.getZoomScale(t.zoom),i=this._map.getSize().multiplyBy(this.options.padding*e),s=this.getSize()._divideBy(2),r=this._map.project(t.center,t.zoom)._subtract(s)._add(this._map._getMapPanePos().add(i))._round(),o=this._map.project(this._map.getBounds().getNorthWest(),t.zoom)._subtract(r);n.DomUtil.setTransform(this._glMap._actualCanvas,o.subtract(this._offset),e)},_zoomStart:function(){this._zooming=!0},_zoomEnd:function(){var t=this._map.getZoomScale(this._map.getZoom());n.DomUtil.setTransform(this._glMap._actualCanvas,null,t),this._zooming=!1,this._update()},_transitionEnd:function(){n.Util.requestAnimFrame((function(){var t=this._map.getZoom(),e=this._map.getCenter(),i=this._map.latLngToContainerPoint(this._map.getBounds().getNorthWest());this._resizeContainer(),n.DomUtil.setTransform(this._glMap._actualCanvas,i,1),this._glMap.once("moveend",n.Util.bind((function(){this._zoomEnd()}),this)),this._glMap.jumpTo({center:e,zoom:t-1})}),this)},_resize:function(t){this._transitionEnd(t)}}),void(n.maplibreGL=function(t){return new n.MaplibreGL(t)})));var a=Object.freeze({__proto__:null});export{a as l}