@webquark/browser 0.0.0-stage → 1.1.0-dev.10

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 (802) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +12 -2
  3. package/dist/cjs/Leaflet.GoogleMutant-i4bYl6qy.js +768 -0
  4. package/dist/cjs/action.props-N0urQtdP.js +35 -0
  5. package/dist/cjs/chevron-up-D4t2OSHA.js +30 -0
  6. package/dist/cjs/collection-identity-CV5HLD9Z.js +141 -0
  7. package/dist/cjs/data-table-cell-8uUCk2Qz.js +51 -0
  8. package/dist/cjs/dom-Dk77oFF6.js +247 -0
  9. package/dist/cjs/field-CsrQGhG-.js +14 -0
  10. package/dist/cjs/form-control-validity-D1ukC0_e.js +49 -0
  11. package/dist/cjs/form-field-adapter-D0CJ6poh.js +51 -0
  12. package/dist/cjs/form-field-state-P63wN30v.js +51 -0
  13. package/dist/cjs/form-submit-action-C6c4aq6C.js +227 -0
  14. package/dist/cjs/image-crop-BZD5Cxd7.js +53 -0
  15. package/dist/cjs/index-DWXhKHCB.js +1869 -0
  16. package/dist/cjs/index.cjs.js +34 -0
  17. package/dist/cjs/leaflet-maplibre-gl-JIaCQ-7v.js +1025 -0
  18. package/dist/cjs/leaflet-src-mrRg-Srs.js +14551 -0
  19. package/dist/cjs/loader.cjs.js +12 -0
  20. package/dist/cjs/map.types-BWymIRql.js +24 -0
  21. package/dist/cjs/q-accordion.cjs.entry.js +18 -0
  22. package/dist/cjs/q-alert.cjs.entry.js +52 -0
  23. package/dist/cjs/q-avatar.cjs.entry.js +101 -0
  24. package/dist/cjs/q-banner.cjs.entry.js +19 -0
  25. package/dist/cjs/q-button_2.cjs.entry.js +462 -0
  26. package/dist/cjs/q-card.cjs.entry.js +88 -0
  27. package/dist/cjs/q-carousel.cjs.entry.js +718 -0
  28. package/dist/cjs/q-chip.cjs.entry.js +124 -0
  29. package/dist/cjs/q-conversation-bubble.cjs.entry.js +70 -0
  30. package/dist/cjs/q-data-table.cjs.entry.js +611 -0
  31. package/dist/cjs/q-dialog.cjs.entry.js +271 -0
  32. package/dist/cjs/q-dropdown.cjs.entry.js +699 -0
  33. package/dist/cjs/q-form.cjs.entry.js +1002 -0
  34. package/dist/cjs/q-grid.cjs.entry.js +24 -0
  35. package/dist/cjs/q-icon.cjs.entry.js +439 -0
  36. package/dist/cjs/q-image-comparison.cjs.entry.js +201 -0
  37. package/dist/cjs/q-inline.cjs.entry.js +22 -0
  38. package/dist/cjs/q-input_2.cjs.entry.js +438 -0
  39. package/dist/cjs/q-link.cjs.entry.js +80 -0
  40. package/dist/cjs/q-map.cjs.entry.js +3509 -0
  41. package/dist/cjs/q-media.cjs.entry.js +21 -0
  42. package/dist/cjs/q-navbar.cjs.entry.js +415 -0
  43. package/dist/cjs/q-pagination.cjs.entry.js +68 -0
  44. package/dist/cjs/q-panel.cjs.entry.js +76 -0
  45. package/dist/cjs/q-quantity-selector.cjs.entry.js +204 -0
  46. package/dist/cjs/q-radio-group.cjs.entry.js +261 -0
  47. package/dist/cjs/q-reel.cjs.entry.js +170 -0
  48. package/dist/cjs/q-scrollable.cjs.entry.js +449 -0
  49. package/dist/cjs/q-section.cjs.entry.js +20 -0
  50. package/dist/cjs/q-sidepanel.cjs.entry.js +793 -0
  51. package/dist/cjs/q-stack.cjs.entry.js +20 -0
  52. package/dist/cjs/q-step-diagram-item.cjs.entry.js +45 -0
  53. package/dist/cjs/q-step-diagram.cjs.entry.js +56 -0
  54. package/dist/cjs/q-syntax-box.cjs.entry.js +782 -0
  55. package/dist/cjs/q-tabs.cjs.entry.js +155 -0
  56. package/dist/cjs/q-textarea.cjs.entry.js +295 -0
  57. package/dist/cjs/q-thumbnail.cjs.entry.js +51 -0
  58. package/dist/cjs/q-toast.cjs.entry.js +400 -0
  59. package/dist/cjs/q-toggle.cjs.entry.js +233 -0
  60. package/dist/cjs/q-toolbar.cjs.entry.js +33 -0
  61. package/dist/cjs/registry-CzkkkaZO.js +323 -0
  62. package/dist/cjs/toast-controller-CIXagxbV.js +111 -0
  63. package/dist/cjs/tokens-RMRaIOqv.js +957 -0
  64. package/dist/cjs/utils-DGQOjEwT.js +33 -0
  65. package/dist/cjs/webquark.cjs.js +24 -0
  66. package/dist/collection/assets/icons/braces.svg +14 -0
  67. package/dist/collection/assets/icons/check.svg +1 -0
  68. package/dist/collection/assets/icons/chevron-down.svg +1 -0
  69. package/dist/collection/assets/icons/chevron-left.svg +1 -0
  70. package/dist/collection/assets/icons/chevron-right.svg +1 -0
  71. package/dist/collection/assets/icons/chevron-up.svg +1 -0
  72. package/dist/collection/assets/icons/copy.svg +4 -0
  73. package/dist/collection/assets/icons/eye-off.svg +1 -0
  74. package/dist/collection/assets/icons/eye.svg +1 -0
  75. package/dist/collection/assets/icons/minus.svg +1 -0
  76. package/dist/collection/assets/icons/play.svg +1 -0
  77. package/dist/collection/assets/icons/plus.svg +1 -0
  78. package/dist/collection/assets/icons/search.svg +1 -0
  79. package/dist/collection/assets/icons/spinner.svg +1 -0
  80. package/dist/collection/assets/icons/trash-2.svg +1 -0
  81. package/dist/collection/assets/icons/x.svg +1 -0
  82. package/dist/collection/collection-manifest.json +56 -0
  83. package/dist/collection/components/actions/action.props.js +130 -0
  84. package/dist/collection/components/actions/button/button.css +242 -0
  85. package/dist/collection/components/actions/button/button.js +748 -0
  86. package/dist/collection/components/actions/button/button.types.js +1 -0
  87. package/dist/collection/components/actions/button/button.utils.js +9 -0
  88. package/dist/collection/components/actions/button/test/button-slots.cmp.test.js +70 -0
  89. package/dist/collection/components/actions/button/test/button.utils.unit.test.js +44 -0
  90. package/dist/collection/components/actions/link/link.css +102 -0
  91. package/dist/collection/components/actions/link/link.js +316 -0
  92. package/dist/collection/components/actions/link/link.types.js +1 -0
  93. package/dist/collection/components/communication/alert/alert.css +118 -0
  94. package/dist/collection/components/communication/alert/alert.js +208 -0
  95. package/dist/collection/components/communication/alert/alert.types.js +1 -0
  96. package/dist/collection/components/communication/conversation-bubble/conversation-bubble.css +154 -0
  97. package/dist/collection/components/communication/conversation-bubble/conversation-bubble.js +207 -0
  98. package/dist/collection/components/communication/conversation-bubble/conversation-bubble.types.js +1 -0
  99. package/dist/collection/components/communication/toast/internals/icons.js +25 -0
  100. package/dist/collection/components/communication/toast/internals/queue.js +64 -0
  101. package/dist/collection/components/communication/toast/internals/timers.js +75 -0
  102. package/dist/collection/components/communication/toast/test/toast.cmp.test.js +38 -0
  103. package/dist/collection/components/communication/toast/test/toast.unit.test.js +104 -0
  104. package/dist/collection/components/communication/toast/toast-controller.js +105 -0
  105. package/dist/collection/components/communication/toast/toast.css +141 -0
  106. package/dist/collection/components/communication/toast/toast.js +556 -0
  107. package/dist/collection/components/communication/toast/toast.types.js +1 -0
  108. package/dist/collection/components/content/banner/banner.css +1 -0
  109. package/dist/collection/components/content/banner/banner.js +84 -0
  110. package/dist/collection/components/content/banner/banner.types.js +1 -0
  111. package/dist/collection/components/content/card/card.css +105 -0
  112. package/dist/collection/components/content/card/card.js +308 -0
  113. package/dist/collection/components/content/card/card.types.js +1 -0
  114. package/dist/collection/components/content/card/card.utils.js +15 -0
  115. package/dist/collection/components/content/carousel/carousel.css +254 -0
  116. package/dist/collection/components/content/carousel/carousel.js +956 -0
  117. package/dist/collection/components/content/carousel/carousel.types.js +1 -0
  118. package/dist/collection/components/content/carousel/carousel.utils.js +1 -0
  119. package/dist/collection/components/content/carousel/internals/autoplay.js +64 -0
  120. package/dist/collection/components/content/carousel/internals/metrics.js +59 -0
  121. package/dist/collection/components/content/carousel/internals/slide-state.js +50 -0
  122. package/dist/collection/components/content/carousel/test/transitions.cmp.test.js +328 -0
  123. package/dist/collection/components/data-display/accordion/accordion.css +1 -0
  124. package/dist/collection/components/data-display/accordion/accordion.js +54 -0
  125. package/dist/collection/components/data-display/accordion/accordion.types.js +1 -0
  126. package/dist/collection/components/data-display/chip/chip.css +219 -0
  127. package/dist/collection/components/data-display/chip/chip.js +381 -0
  128. package/dist/collection/components/data-display/chip/chip.types.js +1 -0
  129. package/dist/collection/components/data-display/data-table/data-table-cell.js +44 -0
  130. package/dist/collection/components/data-display/data-table/data-table.css +429 -0
  131. package/dist/collection/components/data-display/data-table/data-table.js +862 -0
  132. package/dist/collection/components/data-display/data-table/data-table.types.js +1 -0
  133. package/dist/collection/components/data-display/data-table/internals/data-access.js +43 -0
  134. package/dist/collection/components/data-display/data-table/internals/render-row-actions.js +22 -0
  135. package/dist/collection/components/data-display/data-table/internals/render-sort-indicator.js +5 -0
  136. package/dist/collection/components/data-display/data-table/internals/render-table-body.js +59 -0
  137. package/dist/collection/components/data-display/data-table/internals/render-table-head.js +42 -0
  138. package/dist/collection/components/data-display/data-table/internals/render-toolbar.js +6 -0
  139. package/dist/collection/components/data-display/data-table/internals/row-events.js +27 -0
  140. package/dist/collection/components/data-display/data-table/internals/selection.js +31 -0
  141. package/dist/collection/components/data-display/data-table/internals/sort.js +57 -0
  142. package/dist/collection/components/data-display/data-table/internals/table-model.js +92 -0
  143. package/dist/collection/components/data-display/data-table/test/row-gutter.cmp.test.js +104 -0
  144. package/dist/collection/components/data-display/data-table/test/two-line-rows.cmp.test.js +164 -0
  145. package/dist/collection/components/data-display/map/internals/base-layer.js +140 -0
  146. package/dist/collection/components/data-display/map/internals/bounds.js +66 -0
  147. package/dist/collection/components/data-display/map/internals/buffered-tile-layer.js +128 -0
  148. package/dist/collection/components/data-display/map/internals/cluster-collision.js +73 -0
  149. package/dist/collection/components/data-display/map/internals/google-maps.js +117 -0
  150. package/dist/collection/components/data-display/map/internals/google-mutant.js +51 -0
  151. package/dist/collection/components/data-display/map/internals/maplibre.js +50 -0
  152. package/dist/collection/components/data-display/map/internals/marker-cluster-index.js +136 -0
  153. package/dist/collection/components/data-display/map/internals/marker-controller.js +425 -0
  154. package/dist/collection/components/data-display/map/internals/marker-presentation.js +266 -0
  155. package/dist/collection/components/data-display/map/internals/marker-visibility.js +158 -0
  156. package/dist/collection/components/data-display/map/internals/markers.js +191 -0
  157. package/dist/collection/components/data-display/map/internals/tile-layer-readiness.js +67 -0
  158. package/dist/collection/components/data-display/map/internals/tile-preload-buffer.js +8 -0
  159. package/dist/collection/components/data-display/map/internals/vector-padding.js +8 -0
  160. package/dist/collection/components/data-display/map/map.css +742 -0
  161. package/dist/collection/components/data-display/map/map.js +1595 -0
  162. package/dist/collection/components/data-display/map/map.types.js +12 -0
  163. package/dist/collection/components/data-display/map/test/map.cmp.test.js +961 -0
  164. package/dist/collection/components/data-display/pagination/pagination.css +81 -0
  165. package/dist/collection/components/data-display/pagination/pagination.js +240 -0
  166. package/dist/collection/components/data-display/pagination/test/pagination.cmp.test.js +57 -0
  167. package/dist/collection/components/data-display/syntax-box/internals/clipboard.js +9 -0
  168. package/dist/collection/components/data-display/syntax-box/internals/editor-key-action.js +14 -0
  169. package/dist/collection/components/data-display/syntax-box/internals/formatter.js +156 -0
  170. package/dist/collection/components/data-display/syntax-box/internals/formatter.unit.test.js +71 -0
  171. package/dist/collection/components/data-display/syntax-box/internals/syntax.js +239 -0
  172. package/dist/collection/components/data-display/syntax-box/internals/syntax.unit.test.js +134 -0
  173. package/dist/collection/components/data-display/syntax-box/internals/value-sync.js +10 -0
  174. package/dist/collection/components/data-display/syntax-box/internals/value-sync.unit.test.js +25 -0
  175. package/dist/collection/components/data-display/syntax-box/syntax-box.css +209 -0
  176. package/dist/collection/components/data-display/syntax-box/syntax-box.js +678 -0
  177. package/dist/collection/components/data-display/syntax-box/syntax-box.types.js +1 -0
  178. package/dist/collection/components/data-display/syntax-box/syntax-box.utils.js +1 -0
  179. package/dist/collection/components/data-display/syntax-box/test/format-fixtures.js +20 -0
  180. package/dist/collection/components/data-display/syntax-box/test/syntax-box.cmp.test.js +241 -0
  181. package/dist/collection/components/data-display/syntax-box/test/syntax-fixtures.js +14 -0
  182. package/dist/collection/components/data-display/syntax-box/test/syntax-format.cmp.test.js +157 -0
  183. package/dist/collection/components/indicators/progress/progress.css +223 -0
  184. package/dist/collection/components/indicators/progress/progress.js +275 -0
  185. package/dist/collection/components/indicators/progress/progress.types.js +1 -0
  186. package/dist/collection/components/indicators/step-diagram/step-diagram.css +21 -0
  187. package/dist/collection/components/indicators/step-diagram/step-diagram.js +143 -0
  188. package/dist/collection/components/indicators/step-diagram/step-diagram.types.js +1 -0
  189. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.css +252 -0
  190. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.js +185 -0
  191. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.types.js +1 -0
  192. package/dist/collection/components/indicators/step-diagram-item/step-diagram-item.utils.js +3 -0
  193. package/dist/collection/components/inputs/dropdown/dropdown.css +387 -0
  194. package/dist/collection/components/inputs/dropdown/dropdown.js +1236 -0
  195. package/dist/collection/components/inputs/dropdown/dropdown.types.js +1 -0
  196. package/dist/collection/components/inputs/dropdown/internals/options.js +30 -0
  197. package/dist/collection/components/inputs/dropdown/internals/position.js +35 -0
  198. package/dist/collection/components/inputs/dropdown/test/dropdown.cmp.test.js +62 -0
  199. package/dist/collection/components/inputs/form/form.css +85 -0
  200. package/dist/collection/components/inputs/form/form.js +808 -0
  201. package/dist/collection/components/inputs/form/form.types.js +1 -0
  202. package/dist/collection/components/inputs/form/internals/controls.js +173 -0
  203. package/dist/collection/components/inputs/form/internals/enter-behavior.js +25 -0
  204. package/dist/collection/components/inputs/form/internals/field-state.js +129 -0
  205. package/dist/collection/components/inputs/form/internals/reset.js +50 -0
  206. package/dist/collection/components/inputs/form/internals/submission.js +140 -0
  207. package/dist/collection/components/inputs/form/internals/values.js +199 -0
  208. package/dist/collection/components/inputs/form/internals/values.unit.test.js +59 -0
  209. package/dist/collection/components/inputs/form/test/form-reset-state.cmp.test.js +559 -0
  210. package/dist/collection/components/inputs/form/test/form-submit-transport.cmp.test.js +352 -0
  211. package/dist/collection/components/inputs/form/test/form-submit.cmp.test.js +438 -0
  212. package/dist/collection/components/inputs/form/test/form-values.cmp.test.js +440 -0
  213. package/dist/collection/components/inputs/form/test/form.cmp.test.js +157 -0
  214. package/dist/collection/components/inputs/input/input.css +293 -0
  215. package/dist/collection/components/inputs/input/input.js +907 -0
  216. package/dist/collection/components/inputs/input/input.types.js +1 -0
  217. package/dist/collection/components/inputs/input/input.utils.js +3 -0
  218. package/dist/collection/components/inputs/quantity-selector/internals/number-value.js +64 -0
  219. package/dist/collection/components/inputs/quantity-selector/quantity-selector.css +171 -0
  220. package/dist/collection/components/inputs/quantity-selector/quantity-selector.js +390 -0
  221. package/dist/collection/components/inputs/quantity-selector/quantity-selector.types.js +1 -0
  222. package/dist/collection/components/inputs/radio-group/radio-group.css +224 -0
  223. package/dist/collection/components/inputs/radio-group/radio-group.js +668 -0
  224. package/dist/collection/components/inputs/radio-group/radio-group.types.js +1 -0
  225. package/dist/collection/components/inputs/radio-group/radio-group.utils.js +18 -0
  226. package/dist/collection/components/inputs/textarea/textarea.css +172 -0
  227. package/dist/collection/components/inputs/textarea/textarea.js +799 -0
  228. package/dist/collection/components/inputs/textarea/textarea.types.js +1 -0
  229. package/dist/collection/components/inputs/toggle/toggle.css +252 -0
  230. package/dist/collection/components/inputs/toggle/toggle.js +610 -0
  231. package/dist/collection/components/inputs/toggle/toggle.types.js +1 -0
  232. package/dist/collection/components/inputs/toggle/toggle.utils.js +3 -0
  233. package/dist/collection/components/layout/grid/grid.css +11 -0
  234. package/dist/collection/components/layout/grid/grid.js +152 -0
  235. package/dist/collection/components/layout/inline/inline.css +4 -0
  236. package/dist/collection/components/layout/inline/inline.js +118 -0
  237. package/dist/collection/components/layout/navbar/navbar.css +584 -0
  238. package/dist/collection/components/layout/navbar/navbar.js +848 -0
  239. package/dist/collection/components/layout/navbar/navbar.types.js +1 -0
  240. package/dist/collection/components/layout/navbar/navbar.utils.js +13 -0
  241. package/dist/collection/components/layout/navbar/test/navbar.cmp.test.js +369 -0
  242. package/dist/collection/components/layout/panel/panel.css +114 -0
  243. package/dist/collection/components/layout/panel/panel.js +394 -0
  244. package/dist/collection/components/layout/panel/panel.types.js +1 -0
  245. package/dist/collection/components/layout/scrollable/internals/metrics.js +61 -0
  246. package/dist/collection/components/layout/scrollable/internals/native-scrollbar.js +41 -0
  247. package/dist/collection/components/layout/scrollable/scrollable.css +123 -0
  248. package/dist/collection/components/layout/scrollable/scrollable.js +565 -0
  249. package/dist/collection/components/layout/scrollable/scrollable.types.js +1 -0
  250. package/dist/collection/components/layout/section/section.css +1 -0
  251. package/dist/collection/components/layout/section/section.js +98 -0
  252. package/dist/collection/components/layout/section/section.types.js +1 -0
  253. package/dist/collection/components/layout/sidepanel/internals/drawer.js +98 -0
  254. package/dist/collection/components/layout/sidepanel/internals/groups.js +56 -0
  255. package/dist/collection/components/layout/sidepanel/internals/nav-items.js +30 -0
  256. package/dist/collection/components/layout/sidepanel/sidepanel.css +1035 -0
  257. package/dist/collection/components/layout/sidepanel/sidepanel.js +1001 -0
  258. package/dist/collection/components/layout/sidepanel/sidepanel.types.js +1 -0
  259. package/dist/collection/components/layout/sidepanel/sidepanel.utils.js +17 -0
  260. package/dist/collection/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.js +120 -0
  261. package/dist/collection/components/layout/sidepanel/test/panel-transitions.cmp.test.js +180 -0
  262. package/dist/collection/components/layout/stack/stack.css +4 -0
  263. package/dist/collection/components/layout/stack/stack.js +76 -0
  264. package/dist/collection/components/layout/tabs/tabs.css +248 -0
  265. package/dist/collection/components/layout/tabs/tabs.js +322 -0
  266. package/dist/collection/components/layout/tabs/tabs.types.js +1 -0
  267. package/dist/collection/components/layout/tabs/tabs.utils.js +31 -0
  268. package/dist/collection/components/layout/tabs/test/tabs.cmp.test.js +165 -0
  269. package/dist/collection/components/layout/toolbar/toolbar.css +168 -0
  270. package/dist/collection/components/layout/toolbar/toolbar.js +251 -0
  271. package/dist/collection/components/layout/toolbar/toolbar.types.js +1 -0
  272. package/dist/collection/components/media/avatar/avatar.css +71 -0
  273. package/dist/collection/components/media/avatar/avatar.js +302 -0
  274. package/dist/collection/components/media/avatar/avatar.types.js +1 -0
  275. package/dist/collection/components/media/icon/icon.css +42 -0
  276. package/dist/collection/components/media/icon/icon.js +510 -0
  277. package/dist/collection/components/media/icon/icon.types.js +1 -0
  278. package/dist/collection/components/media/icon/internals/constants.js +3 -0
  279. package/dist/collection/components/media/icon/internals/fetch-icon.js +47 -0
  280. package/dist/collection/components/media/icon/internals/fetch-icon.unit.test.js +51 -0
  281. package/dist/collection/components/media/icon/internals/policy.js +184 -0
  282. package/dist/collection/components/media/icon/internals/policy.unit.test.js +65 -0
  283. package/dist/collection/components/media/icon/internals/registry-lucide.unit.test.js +78 -0
  284. package/dist/collection/components/media/icon/internals/registry.js +122 -0
  285. package/dist/collection/components/media/icon/internals/registry.unit.test.js +42 -0
  286. package/dist/collection/components/media/icon/internals/render-definition.js +24 -0
  287. package/dist/collection/components/media/icon/internals/sanitize-svg.js +86 -0
  288. package/dist/collection/components/media/icon/internals/size.js +12 -0
  289. package/dist/collection/components/media/icon/internals/url.js +52 -0
  290. package/dist/collection/components/media/icon/internals/url.unit.test.js +34 -0
  291. package/dist/collection/components/media/icon/test/icon-fixtures.js +47 -0
  292. package/dist/collection/components/media/icon/test/icon.cmp.test.js +223 -0
  293. package/dist/collection/components/media/image-comparison/image-comparison.css +124 -0
  294. package/dist/collection/components/media/image-comparison/image-comparison.js +468 -0
  295. package/dist/collection/components/media/image-comparison/test/image-comparison.cmp.test.js +234 -0
  296. package/dist/collection/components/media/media/media.css +1 -0
  297. package/dist/collection/components/media/media/media.js +125 -0
  298. package/dist/collection/components/media/media/media.types.js +1 -0
  299. package/dist/collection/components/media/reel/reel.css +193 -0
  300. package/dist/collection/components/media/reel/reel.js +279 -0
  301. package/dist/collection/components/media/reel/reel.types.js +1 -0
  302. package/dist/collection/components/media/thumbnail/thumbnail.css +111 -0
  303. package/dist/collection/components/media/thumbnail/thumbnail.js +184 -0
  304. package/dist/collection/components/media/thumbnail/thumbnail.types.js +1 -0
  305. package/dist/collection/components/overlays/dialog/dialog.css +264 -0
  306. package/dist/collection/components/overlays/dialog/dialog.js +743 -0
  307. package/dist/collection/components/overlays/dialog/dialog.types.js +1 -0
  308. package/dist/collection/components/overlays/dialog/internals/backdrop.js +9 -0
  309. package/dist/collection/components/overlays/dialog/internals/lifecycle.js +53 -0
  310. package/dist/collection/components/overlays/tooltip/internals/aria.js +27 -0
  311. package/dist/collection/components/overlays/tooltip/internals/positioning.js +84 -0
  312. package/dist/collection/components/overlays/tooltip/internals/scroll-listeners.js +18 -0
  313. package/dist/collection/components/overlays/tooltip/tooltip.css +69 -0
  314. package/dist/collection/components/overlays/tooltip/tooltip.js +196 -0
  315. package/dist/collection/components/overlays/tooltip/tooltip.types.js +1 -0
  316. package/dist/collection/components/shared/field.js +8 -0
  317. package/dist/collection/components/shared/test/orientation.cmp.test.js +36 -0
  318. package/dist/collection/index.js +16 -0
  319. package/dist/collection/native-content.css +24 -0
  320. package/dist/collection/theme/test/foundation.cmp.test.js +353 -0
  321. package/dist/collection/theme/test/presets.cmp.test.js +129 -0
  322. package/dist/collection/theme/test/presets.unit.test.js +40 -0
  323. package/dist/collection/theme/tokens.js +960 -0
  324. package/dist/collection/utils/collection-identity.js +136 -0
  325. package/dist/collection/utils/collection-identity.unit.test.js +107 -0
  326. package/dist/collection/utils/dom.js +236 -0
  327. package/dist/collection/utils/form-control-validity.js +44 -0
  328. package/dist/collection/utils/form-field-adapter.js +44 -0
  329. package/dist/collection/utils/form-field-state.js +45 -0
  330. package/dist/collection/utils/form-reset-action.js +60 -0
  331. package/dist/collection/utils/form-submit-action.js +151 -0
  332. package/dist/collection/utils/form-submit-action.unit.test.js +15 -0
  333. package/dist/collection/utils/image-crop.js +47 -0
  334. package/dist/collection/utils/image-crop.unit.test.js +57 -0
  335. package/dist/collection/utils/math.js +19 -0
  336. package/dist/collection/utils/utils.js +28 -0
  337. package/dist/collection/utils/utils.unit.test.js +16 -0
  338. package/dist/components/index.d.ts +35 -0
  339. package/dist/components/index.js +1 -0
  340. package/dist/components/p-6PPZ2sIO.js +1 -0
  341. package/dist/components/p-B4Mg1xEw.js +1 -0
  342. package/dist/components/p-BH4gQWub.js +1 -0
  343. package/dist/components/p-BIIQL66b.js +1 -0
  344. package/dist/components/p-BJiYCN3i.js +1 -0
  345. package/dist/components/p-BOdNg0jc.js +1 -0
  346. package/dist/components/p-BcL0NVv0.js +1 -0
  347. package/dist/components/p-Bj2RJb2E.js +1 -0
  348. package/dist/components/p-BofcK-7Z.js +1 -0
  349. package/dist/components/p-ByfrUWx1.js +1 -0
  350. package/dist/components/p-CGZPmEUB.js +1 -0
  351. package/dist/components/p-CGml_DQ8.js +1 -0
  352. package/dist/components/p-CKuPOxKN.js +1 -0
  353. package/dist/components/p-CN1ut2Lb.js +1 -0
  354. package/dist/components/p-C_RztzNv.js +5 -0
  355. package/dist/components/p-Cg0Mv7Vb.js +1 -0
  356. package/dist/components/p-CoIMrUb3.js +1 -0
  357. package/dist/components/p-CpI3m4_T.js +1 -0
  358. package/dist/components/p-DKrPmn2y.js +13 -0
  359. package/dist/components/p-DQhiqYeq.js +1 -0
  360. package/dist/components/p-DYMWBqU1.js +5 -0
  361. package/dist/components/p-Dfp_If-_.js +1 -0
  362. package/dist/components/p-DlIn_ZWk.js +1 -0
  363. package/dist/components/p-DstNl_WY.js +1 -0
  364. package/dist/components/p-DuX-9GOi.js +1 -0
  365. package/dist/components/p-SzKf4WZF.js +1 -0
  366. package/dist/components/p-ye27qtRo.js +1 -0
  367. package/dist/components/q-accordion.d.ts +11 -0
  368. package/dist/components/q-accordion.js +1 -0
  369. package/dist/components/q-alert.d.ts +11 -0
  370. package/dist/components/q-alert.js +1 -0
  371. package/dist/components/q-avatar.d.ts +11 -0
  372. package/dist/components/q-avatar.js +1 -0
  373. package/dist/components/q-banner.d.ts +11 -0
  374. package/dist/components/q-banner.js +1 -0
  375. package/dist/components/q-button.d.ts +11 -0
  376. package/dist/components/q-button.js +1 -0
  377. package/dist/components/q-card.d.ts +11 -0
  378. package/dist/components/q-card.js +1 -0
  379. package/dist/components/q-carousel.d.ts +11 -0
  380. package/dist/components/q-carousel.js +1 -0
  381. package/dist/components/q-chip.d.ts +11 -0
  382. package/dist/components/q-chip.js +1 -0
  383. package/dist/components/q-conversation-bubble.d.ts +11 -0
  384. package/dist/components/q-conversation-bubble.js +1 -0
  385. package/dist/components/q-data-table.d.ts +11 -0
  386. package/dist/components/q-data-table.js +1 -0
  387. package/dist/components/q-dialog.d.ts +11 -0
  388. package/dist/components/q-dialog.js +1 -0
  389. package/dist/components/q-dropdown.d.ts +11 -0
  390. package/dist/components/q-dropdown.js +1 -0
  391. package/dist/components/q-form.d.ts +11 -0
  392. package/dist/components/q-form.js +1 -0
  393. package/dist/components/q-grid.d.ts +11 -0
  394. package/dist/components/q-grid.js +1 -0
  395. package/dist/components/q-icon.d.ts +11 -0
  396. package/dist/components/q-icon.js +1 -0
  397. package/dist/components/q-image-comparison.d.ts +11 -0
  398. package/dist/components/q-image-comparison.js +1 -0
  399. package/dist/components/q-inline.d.ts +11 -0
  400. package/dist/components/q-inline.js +1 -0
  401. package/dist/components/q-input.d.ts +11 -0
  402. package/dist/components/q-input.js +1 -0
  403. package/dist/components/q-link.d.ts +11 -0
  404. package/dist/components/q-link.js +1 -0
  405. package/dist/components/q-map.d.ts +11 -0
  406. package/dist/components/q-map.js +1 -0
  407. package/dist/components/q-media.d.ts +11 -0
  408. package/dist/components/q-media.js +1 -0
  409. package/dist/components/q-navbar.d.ts +11 -0
  410. package/dist/components/q-navbar.js +1 -0
  411. package/dist/components/q-pagination.d.ts +11 -0
  412. package/dist/components/q-pagination.js +1 -0
  413. package/dist/components/q-panel.d.ts +11 -0
  414. package/dist/components/q-panel.js +1 -0
  415. package/dist/components/q-progress.d.ts +11 -0
  416. package/dist/components/q-progress.js +1 -0
  417. package/dist/components/q-quantity-selector.d.ts +11 -0
  418. package/dist/components/q-quantity-selector.js +1 -0
  419. package/dist/components/q-radio-group.d.ts +11 -0
  420. package/dist/components/q-radio-group.js +1 -0
  421. package/dist/components/q-reel.d.ts +11 -0
  422. package/dist/components/q-reel.js +1 -0
  423. package/dist/components/q-scrollable.d.ts +11 -0
  424. package/dist/components/q-scrollable.js +1 -0
  425. package/dist/components/q-section.d.ts +11 -0
  426. package/dist/components/q-section.js +1 -0
  427. package/dist/components/q-sidepanel.d.ts +11 -0
  428. package/dist/components/q-sidepanel.js +13 -0
  429. package/dist/components/q-stack.d.ts +11 -0
  430. package/dist/components/q-stack.js +1 -0
  431. package/dist/components/q-step-diagram-item.d.ts +11 -0
  432. package/dist/components/q-step-diagram-item.js +1 -0
  433. package/dist/components/q-step-diagram.d.ts +11 -0
  434. package/dist/components/q-step-diagram.js +1 -0
  435. package/dist/components/q-syntax-box.d.ts +11 -0
  436. package/dist/components/q-syntax-box.js +13 -0
  437. package/dist/components/q-tabs.d.ts +11 -0
  438. package/dist/components/q-tabs.js +1 -0
  439. package/dist/components/q-textarea.d.ts +11 -0
  440. package/dist/components/q-textarea.js +1 -0
  441. package/dist/components/q-thumbnail.d.ts +11 -0
  442. package/dist/components/q-thumbnail.js +1 -0
  443. package/dist/components/q-toast.d.ts +11 -0
  444. package/dist/components/q-toast.js +1 -0
  445. package/dist/components/q-toggle.d.ts +11 -0
  446. package/dist/components/q-toggle.js +1 -0
  447. package/dist/components/q-toolbar.d.ts +11 -0
  448. package/dist/components/q-toolbar.js +1 -0
  449. package/dist/components/q-tooltip.d.ts +11 -0
  450. package/dist/components/q-tooltip.js +1 -0
  451. package/dist/esm/Leaflet.GoogleMutant-MpxOb4Jm.js +766 -0
  452. package/dist/esm/action.props-CpnGza8z.js +32 -0
  453. package/dist/esm/chevron-up-DKrPmn2y.js +27 -0
  454. package/dist/esm/collection-identity-CGZPmEUB.js +138 -0
  455. package/dist/esm/data-table-cell-SzKf4WZF.js +46 -0
  456. package/dist/esm/dom-ByfrUWx1.js +238 -0
  457. package/dist/esm/field-zfD6OQ02.js +11 -0
  458. package/dist/esm/form-control-validity-Bj2RJb2E.js +46 -0
  459. package/dist/esm/form-field-adapter-CGml_DQ8.js +46 -0
  460. package/dist/esm/form-field-state-DstNl_WY.js +47 -0
  461. package/dist/esm/form-submit-action-CoEIvDqE.js +213 -0
  462. package/dist/esm/image-crop-BcL0NVv0.js +49 -0
  463. package/dist/esm/index-B5ElFlHv.js +1858 -0
  464. package/dist/esm/index.js +7 -0
  465. package/dist/esm/leaflet-maplibre-gl-BvKlNmWf.js +1020 -0
  466. package/dist/esm/leaflet-src-DYMWBqU1.js +14547 -0
  467. package/dist/esm/loader.js +10 -0
  468. package/dist/esm/map.types-CoIMrUb3.js +14 -0
  469. package/dist/esm/q-accordion.entry.js +16 -0
  470. package/dist/esm/q-alert.entry.js +50 -0
  471. package/dist/esm/q-avatar.entry.js +99 -0
  472. package/dist/esm/q-banner.entry.js +17 -0
  473. package/dist/esm/q-button_2.entry.js +459 -0
  474. package/dist/esm/q-card.entry.js +86 -0
  475. package/dist/esm/q-carousel.entry.js +716 -0
  476. package/dist/esm/q-chip.entry.js +122 -0
  477. package/dist/esm/q-conversation-bubble.entry.js +68 -0
  478. package/dist/esm/q-data-table.entry.js +609 -0
  479. package/dist/esm/q-dialog.entry.js +269 -0
  480. package/dist/esm/q-dropdown.entry.js +697 -0
  481. package/dist/esm/q-form.entry.js +1000 -0
  482. package/dist/esm/q-grid.entry.js +22 -0
  483. package/dist/esm/q-icon.entry.js +437 -0
  484. package/dist/esm/q-image-comparison.entry.js +199 -0
  485. package/dist/esm/q-inline.entry.js +20 -0
  486. package/dist/esm/q-input_2.entry.js +435 -0
  487. package/dist/esm/q-link.entry.js +78 -0
  488. package/dist/esm/q-map.entry.js +3507 -0
  489. package/dist/esm/q-media.entry.js +19 -0
  490. package/dist/esm/q-navbar.entry.js +413 -0
  491. package/dist/esm/q-pagination.entry.js +66 -0
  492. package/dist/esm/q-panel.entry.js +74 -0
  493. package/dist/esm/q-quantity-selector.entry.js +202 -0
  494. package/dist/esm/q-radio-group.entry.js +259 -0
  495. package/dist/esm/q-reel.entry.js +168 -0
  496. package/dist/esm/q-scrollable.entry.js +447 -0
  497. package/dist/esm/q-section.entry.js +18 -0
  498. package/dist/esm/q-sidepanel.entry.js +791 -0
  499. package/dist/esm/q-stack.entry.js +18 -0
  500. package/dist/esm/q-step-diagram-item.entry.js +43 -0
  501. package/dist/esm/q-step-diagram.entry.js +54 -0
  502. package/dist/esm/q-syntax-box.entry.js +780 -0
  503. package/dist/esm/q-tabs.entry.js +153 -0
  504. package/dist/esm/q-textarea.entry.js +293 -0
  505. package/dist/esm/q-thumbnail.entry.js +49 -0
  506. package/dist/esm/q-toast.entry.js +398 -0
  507. package/dist/esm/q-toggle.entry.js +231 -0
  508. package/dist/esm/q-toolbar.entry.js +31 -0
  509. package/dist/esm/registry-CpI3m4_T.js +308 -0
  510. package/dist/esm/toast-controller-BIIQL66b.js +107 -0
  511. package/dist/esm/tokens-B4Mg1xEw.js +953 -0
  512. package/dist/esm/utils-BJiYCN3i.js +30 -0
  513. package/dist/esm/webquark.js +20 -0
  514. package/dist/index.cjs.js +1 -0
  515. package/dist/index.js +1 -0
  516. package/dist/loader/cdn.js +1 -0
  517. package/dist/loader/index.cjs.js +1 -0
  518. package/dist/loader/index.d.ts +24 -0
  519. package/dist/loader/index.es2017.js +1 -0
  520. package/dist/loader/index.js +2 -0
  521. package/dist/types/components/actions/action.props.d.ts +19 -0
  522. package/dist/types/components/actions/button/button.d.ts +87 -0
  523. package/dist/types/components/actions/button/button.types.d.ts +6 -0
  524. package/dist/types/components/actions/button/button.utils.d.ts +8 -0
  525. package/dist/types/components/actions/button/test/button-slots.cmp.test.d.ts +1 -0
  526. package/dist/types/components/actions/button/test/button.utils.unit.test.d.ts +1 -0
  527. package/dist/types/components/actions/link/link.d.ts +43 -0
  528. package/dist/types/components/actions/link/link.types.d.ts +3 -0
  529. package/dist/types/components/communication/alert/alert.d.ts +32 -0
  530. package/dist/types/components/communication/alert/alert.types.d.ts +2 -0
  531. package/dist/types/components/communication/conversation-bubble/conversation-bubble.d.ts +38 -0
  532. package/dist/types/components/communication/conversation-bubble/conversation-bubble.types.d.ts +1 -0
  533. package/dist/types/components/communication/toast/internals/icons.d.ts +2 -0
  534. package/dist/types/components/communication/toast/internals/queue.d.ts +19 -0
  535. package/dist/types/components/communication/toast/internals/timers.d.ts +12 -0
  536. package/dist/types/components/communication/toast/test/toast.cmp.test.d.ts +2 -0
  537. package/dist/types/components/communication/toast/test/toast.unit.test.d.ts +1 -0
  538. package/dist/types/components/communication/toast/toast-controller.d.ts +9 -0
  539. package/dist/types/components/communication/toast/toast.d.ts +44 -0
  540. package/dist/types/components/communication/toast/toast.types.d.ts +30 -0
  541. package/dist/types/components/content/banner/banner.d.ts +12 -0
  542. package/dist/types/components/content/banner/banner.types.d.ts +2 -0
  543. package/dist/types/components/content/card/card.d.ts +35 -0
  544. package/dist/types/components/content/card/card.types.d.ts +1 -0
  545. package/dist/types/components/content/card/card.utils.d.ts +5 -0
  546. package/dist/types/components/content/carousel/carousel.d.ts +123 -0
  547. package/dist/types/components/content/carousel/carousel.types.d.ts +10 -0
  548. package/dist/types/components/content/carousel/carousel.utils.d.ts +1 -0
  549. package/dist/types/components/content/carousel/internals/autoplay.d.ts +22 -0
  550. package/dist/types/components/content/carousel/internals/metrics.d.ts +23 -0
  551. package/dist/types/components/content/carousel/internals/slide-state.d.ts +8 -0
  552. package/dist/types/components/content/carousel/test/transitions.cmp.test.d.ts +1 -0
  553. package/dist/types/components/data-display/accordion/accordion.d.ts +9 -0
  554. package/dist/types/components/data-display/accordion/accordion.types.d.ts +1 -0
  555. package/dist/types/components/data-display/chip/chip.d.ts +55 -0
  556. package/dist/types/components/data-display/chip/chip.types.d.ts +13 -0
  557. package/dist/types/components/data-display/data-table/data-table-cell.d.ts +7 -0
  558. package/dist/types/components/data-display/data-table/data-table.d.ts +95 -0
  559. package/dist/types/components/data-display/data-table/data-table.types.d.ts +56 -0
  560. package/dist/types/components/data-display/data-table/internals/data-access.d.ts +9 -0
  561. package/dist/types/components/data-display/data-table/internals/render-row-actions.d.ts +9 -0
  562. package/dist/types/components/data-display/data-table/internals/render-sort-indicator.d.ts +5 -0
  563. package/dist/types/components/data-display/data-table/internals/render-table-body.d.ts +13 -0
  564. package/dist/types/components/data-display/data-table/internals/render-table-head.d.ts +8 -0
  565. package/dist/types/components/data-display/data-table/internals/render-toolbar.d.ts +9 -0
  566. package/dist/types/components/data-display/data-table/internals/row-events.d.ts +1 -0
  567. package/dist/types/components/data-display/data-table/internals/selection.d.ts +10 -0
  568. package/dist/types/components/data-display/data-table/internals/sort.d.ts +3 -0
  569. package/dist/types/components/data-display/data-table/internals/table-model.d.ts +56 -0
  570. package/dist/types/components/data-display/data-table/test/row-gutter.cmp.test.d.ts +1 -0
  571. package/dist/types/components/data-display/data-table/test/two-line-rows.cmp.test.d.ts +1 -0
  572. package/dist/types/components/data-display/map/internals/base-layer.d.ts +63 -0
  573. package/dist/types/components/data-display/map/internals/bounds.d.ts +23 -0
  574. package/dist/types/components/data-display/map/internals/buffered-tile-layer.d.ts +10 -0
  575. package/dist/types/components/data-display/map/internals/cluster-collision.d.ts +15 -0
  576. package/dist/types/components/data-display/map/internals/google-maps.d.ts +9 -0
  577. package/dist/types/components/data-display/map/internals/google-mutant-module.d.ts +11 -0
  578. package/dist/types/components/data-display/map/internals/google-mutant.d.ts +18 -0
  579. package/dist/types/components/data-display/map/internals/maplibre.d.ts +14 -0
  580. package/dist/types/components/data-display/map/internals/marker-cluster-index.d.ts +36 -0
  581. package/dist/types/components/data-display/map/internals/marker-controller.d.ts +57 -0
  582. package/dist/types/components/data-display/map/internals/marker-presentation.d.ts +8 -0
  583. package/dist/types/components/data-display/map/internals/marker-visibility.d.ts +10 -0
  584. package/dist/types/components/data-display/map/internals/markers.d.ts +4 -0
  585. package/dist/types/components/data-display/map/internals/tile-layer-readiness.d.ts +11 -0
  586. package/dist/types/components/data-display/map/internals/tile-preload-buffer.d.ts +4 -0
  587. package/dist/types/components/data-display/map/internals/vector-padding.d.ts +4 -0
  588. package/dist/types/components/data-display/map/map.d.ts +175 -0
  589. package/dist/types/components/data-display/map/map.types.d.ts +132 -0
  590. package/dist/types/components/data-display/map/test/map.cmp.test.d.ts +1 -0
  591. package/dist/types/components/data-display/pagination/pagination.d.ts +33 -0
  592. package/dist/types/components/data-display/pagination/test/pagination.cmp.test.d.ts +2 -0
  593. package/dist/types/components/data-display/syntax-box/internals/clipboard.d.ts +2 -0
  594. package/dist/types/components/data-display/syntax-box/internals/editor-key-action.d.ts +12 -0
  595. package/dist/types/components/data-display/syntax-box/internals/formatter.d.ts +15 -0
  596. package/dist/types/components/data-display/syntax-box/internals/formatter.unit.test.d.ts +1 -0
  597. package/dist/types/components/data-display/syntax-box/internals/syntax.d.ts +13 -0
  598. package/dist/types/components/data-display/syntax-box/internals/syntax.unit.test.d.ts +1 -0
  599. package/dist/types/components/data-display/syntax-box/internals/value-sync.d.ts +15 -0
  600. package/dist/types/components/data-display/syntax-box/internals/value-sync.unit.test.d.ts +1 -0
  601. package/dist/types/components/data-display/syntax-box/syntax-box.d.ts +72 -0
  602. package/dist/types/components/data-display/syntax-box/syntax-box.types.d.ts +2 -0
  603. package/dist/types/components/data-display/syntax-box/syntax-box.utils.d.ts +1 -0
  604. package/dist/types/components/data-display/syntax-box/test/format-fixtures.d.ts +6 -0
  605. package/dist/types/components/data-display/syntax-box/test/syntax-box.cmp.test.d.ts +1 -0
  606. package/dist/types/components/data-display/syntax-box/test/syntax-fixtures.d.ts +9 -0
  607. package/dist/types/components/data-display/syntax-box/test/syntax-format.cmp.test.d.ts +1 -0
  608. package/dist/types/components/indicators/progress/progress.d.ts +30 -0
  609. package/dist/types/components/indicators/progress/progress.types.d.ts +3 -0
  610. package/dist/types/components/indicators/step-diagram/step-diagram.d.ts +19 -0
  611. package/dist/types/components/indicators/step-diagram/step-diagram.types.d.ts +3 -0
  612. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.d.ts +26 -0
  613. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.types.d.ts +5 -0
  614. package/dist/types/components/indicators/step-diagram-item/step-diagram-item.utils.d.ts +1 -0
  615. package/dist/types/components/inputs/dropdown/dropdown.d.ts +108 -0
  616. package/dist/types/components/inputs/dropdown/dropdown.types.d.ts +9 -0
  617. package/dist/types/components/inputs/dropdown/internals/options.d.ts +6 -0
  618. package/dist/types/components/inputs/dropdown/internals/position.d.ts +26 -0
  619. package/dist/types/components/inputs/dropdown/test/dropdown.cmp.test.d.ts +1 -0
  620. package/dist/types/components/inputs/form/form.d.ts +80 -0
  621. package/dist/types/components/inputs/form/form.types.d.ts +40 -0
  622. package/dist/types/components/inputs/form/internals/controls.d.ts +8 -0
  623. package/dist/types/components/inputs/form/internals/enter-behavior.d.ts +2 -0
  624. package/dist/types/components/inputs/form/internals/field-state.d.ts +19 -0
  625. package/dist/types/components/inputs/form/internals/reset.d.ts +3 -0
  626. package/dist/types/components/inputs/form/internals/submission.d.ts +17 -0
  627. package/dist/types/components/inputs/form/internals/values.d.ts +10 -0
  628. package/dist/types/components/inputs/form/internals/values.unit.test.d.ts +1 -0
  629. package/dist/types/components/inputs/form/test/form-reset-state.cmp.test.d.ts +1 -0
  630. package/dist/types/components/inputs/form/test/form-submit-transport.cmp.test.d.ts +1 -0
  631. package/dist/types/components/inputs/form/test/form-submit.cmp.test.d.ts +1 -0
  632. package/dist/types/components/inputs/form/test/form-values.cmp.test.d.ts +1 -0
  633. package/dist/types/components/inputs/form/test/form.cmp.test.d.ts +4 -0
  634. package/dist/types/components/inputs/input/input.d.ts +89 -0
  635. package/dist/types/components/inputs/input/input.types.d.ts +3 -0
  636. package/dist/types/components/inputs/input/input.utils.d.ts +1 -0
  637. package/dist/types/components/inputs/quantity-selector/internals/number-value.d.ts +13 -0
  638. package/dist/types/components/inputs/quantity-selector/quantity-selector.d.ts +37 -0
  639. package/dist/types/components/inputs/quantity-selector/quantity-selector.types.d.ts +3 -0
  640. package/dist/types/components/inputs/radio-group/radio-group.d.ts +70 -0
  641. package/dist/types/components/inputs/radio-group/radio-group.types.d.ts +12 -0
  642. package/dist/types/components/inputs/radio-group/radio-group.utils.d.ts +2 -0
  643. package/dist/types/components/inputs/textarea/textarea.d.ts +79 -0
  644. package/dist/types/components/inputs/textarea/textarea.types.d.ts +1 -0
  645. package/dist/types/components/inputs/toggle/toggle.d.ts +67 -0
  646. package/dist/types/components/inputs/toggle/toggle.types.d.ts +3 -0
  647. package/dist/types/components/inputs/toggle/toggle.utils.d.ts +1 -0
  648. package/dist/types/components/layout/grid/grid.d.ts +13 -0
  649. package/dist/types/components/layout/inline/inline.d.ts +12 -0
  650. package/dist/types/components/layout/navbar/navbar.d.ts +94 -0
  651. package/dist/types/components/layout/navbar/navbar.types.d.ts +33 -0
  652. package/dist/types/components/layout/navbar/navbar.utils.d.ts +2 -0
  653. package/dist/types/components/layout/navbar/test/navbar.cmp.test.d.ts +1 -0
  654. package/dist/types/components/layout/panel/panel.d.ts +41 -0
  655. package/dist/types/components/layout/panel/panel.types.d.ts +3 -0
  656. package/dist/types/components/layout/scrollable/internals/metrics.d.ts +26 -0
  657. package/dist/types/components/layout/scrollable/internals/native-scrollbar.d.ts +4 -0
  658. package/dist/types/components/layout/scrollable/scrollable.d.ts +67 -0
  659. package/dist/types/components/layout/scrollable/scrollable.types.d.ts +6 -0
  660. package/dist/types/components/layout/section/section.d.ts +13 -0
  661. package/dist/types/components/layout/section/section.types.d.ts +1 -0
  662. package/dist/types/components/layout/sidepanel/internals/drawer.d.ts +2 -0
  663. package/dist/types/components/layout/sidepanel/internals/groups.d.ts +7 -0
  664. package/dist/types/components/layout/sidepanel/internals/nav-items.d.ts +2 -0
  665. package/dist/types/components/layout/sidepanel/sidepanel.d.ts +110 -0
  666. package/dist/types/components/layout/sidepanel/sidepanel.types.d.ts +43 -0
  667. package/dist/types/components/layout/sidepanel/sidepanel.utils.d.ts +2 -0
  668. package/dist/types/components/layout/sidepanel/test/nav-drawer-transitions.cmp.test.d.ts +1 -0
  669. package/dist/types/components/layout/sidepanel/test/panel-transitions.cmp.test.d.ts +1 -0
  670. package/dist/types/components/layout/stack/stack.d.ts +10 -0
  671. package/dist/types/components/layout/tabs/tabs.d.ts +29 -0
  672. package/dist/types/components/layout/tabs/tabs.types.d.ts +14 -0
  673. package/dist/types/components/layout/tabs/tabs.utils.d.ts +4 -0
  674. package/dist/types/components/layout/tabs/test/tabs.cmp.test.d.ts +1 -0
  675. package/dist/types/components/layout/toolbar/toolbar.d.ts +27 -0
  676. package/dist/types/components/layout/toolbar/toolbar.types.d.ts +1 -0
  677. package/dist/types/components/media/avatar/avatar.d.ts +37 -0
  678. package/dist/types/components/media/avatar/avatar.types.d.ts +2 -0
  679. package/dist/types/components/media/icon/icon.d.ts +48 -0
  680. package/dist/types/components/media/icon/icon.types.d.ts +30 -0
  681. package/dist/types/components/media/icon/internals/constants.d.ts +3 -0
  682. package/dist/types/components/media/icon/internals/fetch-icon.d.ts +1 -0
  683. package/dist/types/components/media/icon/internals/fetch-icon.unit.test.d.ts +1 -0
  684. package/dist/types/components/media/icon/internals/policy.d.ts +19 -0
  685. package/dist/types/components/media/icon/internals/policy.unit.test.d.ts +1 -0
  686. package/dist/types/components/media/icon/internals/registry-lucide.unit.test.d.ts +1 -0
  687. package/dist/types/components/media/icon/internals/registry.d.ts +11 -0
  688. package/dist/types/components/media/icon/internals/registry.unit.test.d.ts +1 -0
  689. package/dist/types/components/media/icon/internals/render-definition.d.ts +2 -0
  690. package/dist/types/components/media/icon/internals/sanitize-svg.d.ts +2 -0
  691. package/dist/types/components/media/icon/internals/size.d.ts +2 -0
  692. package/dist/types/components/media/icon/internals/url.d.ts +11 -0
  693. package/dist/types/components/media/icon/internals/url.unit.test.d.ts +1 -0
  694. package/dist/types/components/media/icon/test/icon-fixtures.d.ts +4 -0
  695. package/dist/types/components/media/icon/test/icon.cmp.test.d.ts +1 -0
  696. package/dist/types/components/media/image-comparison/image-comparison.d.ts +63 -0
  697. package/dist/types/components/media/image-comparison/test/image-comparison.cmp.test.d.ts +1 -0
  698. package/dist/types/components/media/media/media.d.ts +13 -0
  699. package/dist/types/components/media/media/media.types.d.ts +2 -0
  700. package/dist/types/components/media/reel/reel.d.ts +34 -0
  701. package/dist/types/components/media/reel/reel.types.d.ts +3 -0
  702. package/dist/types/components/media/thumbnail/thumbnail.d.ts +21 -0
  703. package/dist/types/components/media/thumbnail/thumbnail.types.d.ts +7 -0
  704. package/dist/types/components/overlays/dialog/dialog.d.ts +83 -0
  705. package/dist/types/components/overlays/dialog/dialog.types.d.ts +1 -0
  706. package/dist/types/components/overlays/dialog/internals/backdrop.d.ts +2 -0
  707. package/dist/types/components/overlays/dialog/internals/lifecycle.d.ts +21 -0
  708. package/dist/types/components/overlays/tooltip/internals/aria.d.ts +13 -0
  709. package/dist/types/components/overlays/tooltip/internals/positioning.d.ts +7 -0
  710. package/dist/types/components/overlays/tooltip/internals/scroll-listeners.d.ts +2 -0
  711. package/dist/types/components/overlays/tooltip/tooltip.d.ts +33 -0
  712. package/dist/types/components/overlays/tooltip/tooltip.types.d.ts +1 -0
  713. package/dist/types/components/shared/field.d.ts +3 -0
  714. package/dist/types/components/shared/test/orientation.cmp.test.d.ts +1 -0
  715. package/dist/types/components.d.ts +6047 -0
  716. package/dist/types/declarations.d.ts +14 -0
  717. package/dist/types/index.d.ts +31 -0
  718. package/dist/types/stencil-public-runtime.d.ts +1879 -0
  719. package/dist/types/theme/test/assets.d.ts +4 -0
  720. package/dist/types/theme/test/foundation.cmp.test.d.ts +16 -0
  721. package/dist/types/theme/test/presets.cmp.test.d.ts +7 -0
  722. package/dist/types/theme/test/presets.unit.test.d.ts +1 -0
  723. package/dist/types/theme/tokens.d.ts +141 -0
  724. package/dist/types/utils/collection-identity.d.ts +55 -0
  725. package/dist/types/utils/collection-identity.unit.test.d.ts +1 -0
  726. package/dist/types/utils/dom.d.ts +68 -0
  727. package/dist/types/utils/form-control-validity.d.ts +14 -0
  728. package/dist/types/utils/form-field-adapter.d.ts +17 -0
  729. package/dist/types/utils/form-field-state.d.ts +4 -0
  730. package/dist/types/utils/form-reset-action.d.ts +5 -0
  731. package/dist/types/utils/form-submit-action.d.ts +17 -0
  732. package/dist/types/utils/form-submit-action.unit.test.d.ts +1 -0
  733. package/dist/types/utils/image-crop.d.ts +30 -0
  734. package/dist/types/utils/image-crop.unit.test.d.ts +1 -0
  735. package/dist/types/utils/math.d.ts +10 -0
  736. package/dist/types/utils/utils.d.ts +11 -0
  737. package/dist/types/utils/utils.unit.test.d.ts +1 -0
  738. package/dist/webquark/index.esm.js +1 -0
  739. package/dist/webquark/native-content.css +24 -0
  740. package/dist/webquark/p-023f8437.entry.js +1 -0
  741. package/dist/webquark/p-030ecde3.entry.js +1 -0
  742. package/dist/webquark/p-04c8cb9e.entry.js +1 -0
  743. package/dist/webquark/p-059daa8a.entry.js +1 -0
  744. package/dist/webquark/p-09cca7b9.entry.js +1 -0
  745. package/dist/webquark/p-0aa74ad6.entry.js +1 -0
  746. package/dist/webquark/p-0ae43d6c.entry.js +1 -0
  747. package/dist/webquark/p-0c3aac3f.entry.js +1 -0
  748. package/dist/webquark/p-144ef339.entry.js +1 -0
  749. package/dist/webquark/p-296fbdb1.entry.js +1 -0
  750. package/dist/webquark/p-36118d90.entry.js +1 -0
  751. package/dist/webquark/p-3bc4629c.entry.js +1 -0
  752. package/dist/webquark/p-48fb5228.entry.js +1 -0
  753. package/dist/webquark/p-4d61b70d.entry.js +1 -0
  754. package/dist/webquark/p-5f232b44.entry.js +13 -0
  755. package/dist/webquark/p-64096386.entry.js +1 -0
  756. package/dist/webquark/p-6bfffa79.entry.js +1 -0
  757. package/dist/webquark/p-6e28cfe2.entry.js +1 -0
  758. package/dist/webquark/p-70d9ffde.entry.js +1 -0
  759. package/dist/webquark/p-888e46a8.entry.js +1 -0
  760. package/dist/webquark/p-8ece2c62.entry.js +1 -0
  761. package/dist/webquark/p-90b0858c.entry.js +1 -0
  762. package/dist/webquark/p-91fff6b6.entry.js +1 -0
  763. package/dist/webquark/p-923dac41.entry.js +1 -0
  764. package/dist/webquark/p-97a89cae.entry.js +1 -0
  765. package/dist/webquark/p-99d785ca.entry.js +1 -0
  766. package/dist/webquark/p-9e78b796.entry.js +1 -0
  767. package/dist/webquark/p-9ff7e5a4.entry.js +1 -0
  768. package/dist/webquark/p-B4Mg1xEw.js +1 -0
  769. package/dist/webquark/p-B5ElFlHv.js +3 -0
  770. package/dist/webquark/p-BIIQL66b.js +1 -0
  771. package/dist/webquark/p-BJiYCN3i.js +1 -0
  772. package/dist/webquark/p-BOdNg0jc.js +1 -0
  773. package/dist/webquark/p-BcL0NVv0.js +1 -0
  774. package/dist/webquark/p-Bj2RJb2E.js +1 -0
  775. package/dist/webquark/p-ByfrUWx1.js +1 -0
  776. package/dist/webquark/p-CGZPmEUB.js +1 -0
  777. package/dist/webquark/p-CGml_DQ8.js +1 -0
  778. package/dist/webquark/p-C_RztzNv.js +5 -0
  779. package/dist/webquark/p-CoIMrUb3.js +1 -0
  780. package/dist/webquark/p-CpI3m4_T.js +1 -0
  781. package/dist/webquark/p-DKrPmn2y.js +13 -0
  782. package/dist/webquark/p-DWO-pleQ.js +1 -0
  783. package/dist/webquark/p-DYMWBqU1.js +5 -0
  784. package/dist/webquark/p-Dhsn99q4.js +1 -0
  785. package/dist/webquark/p-DstNl_WY.js +1 -0
  786. package/dist/webquark/p-DuX-9GOi.js +1 -0
  787. package/dist/webquark/p-SzKf4WZF.js +1 -0
  788. package/dist/webquark/p-c523ec6f.entry.js +1 -0
  789. package/dist/webquark/p-d0253d64.entry.js +1 -0
  790. package/dist/webquark/p-d0fbd2b1.entry.js +1 -0
  791. package/dist/webquark/p-dd115868.entry.js +1 -0
  792. package/dist/webquark/p-f1bac94c.entry.js +1 -0
  793. package/dist/webquark/p-f4f97e74.entry.js +1 -0
  794. package/dist/webquark/p-f63b7214.entry.js +1 -0
  795. package/dist/webquark/p-f98f9439.entry.js +1 -0
  796. package/dist/webquark/p-f9ad63ff.entry.js +1 -0
  797. package/dist/webquark/p-fe200f68.entry.js +1 -0
  798. package/dist/webquark/p-fe8c634a.entry.js +13 -0
  799. package/dist/webquark/p-fec6fe0a.entry.js +1 -0
  800. package/dist/webquark/webquark.css +1 -0
  801. package/dist/webquark/webquark.esm.js +1 -0
  802. package/package.json +78 -4
@@ -0,0 +1,5 @@
1
+ import{a as t,L as e}from"./p-DYMWBqU1.js";
2
+ /**
3
+ * MapLibre GL JS
4
+ * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.13.0/LICENSE.txt
5
+ */var i=Object.create,r=Object.defineProperty,n=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,o=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,l=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),h=(t,e,i,o)=>{if(e&&"object"==typeof e||"function"==typeof e)for(var l,h=s(e),u=0,c=h.length;u<c;u++)!a.call(t,l=h[u])&&l!==i&&r(t,l,{get:(t=>e[t]).bind(null,l),enumerable:!(o=n(e,l))||o.enumerable});return t},u=(t,e,n)=>(n=null==t?{}:i(o(t)),h(r(n,"default",{value:t,enumerable:!0}),t)),c="6.13.0";function f(t,e){this.x=t,this.y=e}let p,d;function m(){return p??=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,p}function _(){if(null==d&&(d=!1,m())){let t=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(t){for(let e=0;e<25;e++){let i=4*e;t.fillStyle=`rgb(${i},${i+1},${i+2})`,t.fillRect(e%5,Math.floor(e/5),1,1)}let e=t.getImageData(0,0,5,5).data;for(let t=0;t<100;t++)if(t%4!=3&&e[t]!==t){d=!0;break}}}return d||!1}f.prototype={clone(){return new f(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){let 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){let 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(){let t=this.y;return this.y=this.x,this.x=-t,this},_rotate(t){let e=Math.cos(t),i=Math.sin(t),r=i*this.x+e*this.y;return this.x=e*this.x-i*this.y,this.y=r,this},_rotateAround(t,e){let i=Math.cos(t),r=Math.sin(t),n=e.y+r*(this.x-e.x)+i*(this.y-e.y);return this.x=e.x+i*(this.x-e.x)-r*(this.y-e.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:f},f.convert=function(t){if(t instanceof f)return t;if(Array.isArray(t))return new f(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new f(+t.x,+t.y);throw Error("Expected [x, y] or {x, y} point format")};var g=typeof Float32Array<"u"?Float32Array:Array;function y(){var t=new g(4);return g!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}function v(){var t=new g(9);return g!=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 w(){var t=new g(16);return g!=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}function b(t){var e=new g(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}function x(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 D(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=e[4],a=e[5],l=e[6],h=e[7],u=e[8],c=e[9],f=e[10],p=e[11],d=e[12],m=e[13],_=e[14],g=e[15],y=i*a-r*o,v=i*l-n*o,w=i*h-s*o,b=r*l-n*a,x=r*h-s*a,D=n*h-s*l,M=u*m-c*d,E=u*_-f*d,A=u*g-p*d,F=c*_-f*m,S=c*g-p*m,C=f*g-p*_,z=y*C-v*S+w*F+b*A-x*E+D*M;return z?(t[0]=(a*C-l*S+h*F)*(z=1/z),t[1]=(n*S-r*C-s*F)*z,t[2]=(m*D-_*x+g*b)*z,t[3]=(f*x-c*D-p*b)*z,t[4]=(l*A-o*C-h*E)*z,t[5]=(i*C-n*A+s*E)*z,t[6]=(_*w-d*D-g*v)*z,t[7]=(u*D-f*w+p*v)*z,t[8]=(o*S-a*A+h*M)*z,t[9]=(r*A-i*S-s*M)*z,t[10]=(d*x-m*w+g*y)*z,t[11]=(c*w-u*x-p*y)*z,t[12]=(a*E-o*F-l*M)*z,t[13]=(i*F-r*E+n*M)*z,t[14]=(m*v-d*b-_*y)*z,t[15]=(u*b-c*v+f*y)*z,t):null}function M(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],p=e[10],d=e[11],m=e[12],_=e[13],g=e[14],y=e[15],v=i[0],w=i[1],b=i[2],x=i[3];return t[0]=v*r+w*a+b*c+x*m,t[1]=v*n+w*l+b*f+x*_,t[2]=v*s+w*h+b*p+x*g,t[3]=v*o+w*u+b*d+x*y,t[4]=(v=i[4])*r+(w=i[5])*a+(b=i[6])*c+(x=i[7])*m,t[5]=v*n+w*l+b*f+x*_,t[6]=v*s+w*h+b*p+x*g,t[7]=v*o+w*u+b*d+x*y,t[8]=(v=i[8])*r+(w=i[9])*a+(b=i[10])*c+(x=i[11])*m,t[9]=v*n+w*l+b*f+x*_,t[10]=v*s+w*h+b*p+x*g,t[11]=v*o+w*u+b*d+x*y,t[12]=(v=i[12])*r+(w=i[13])*a+(b=i[14])*c+(x=i[15])*m,t[13]=v*n+w*l+b*f+x*_,t[14]=v*s+w*h+b*p+x*g,t[15]=v*o+w*u+b*d+x*y,t}function E(t,e,i){var r,n,s,o,a,l,h,u,c,f,p,d,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]):(n=e[1],s=e[2],o=e[3],a=e[4],l=e[5],h=e[6],u=e[7],c=e[8],f=e[9],p=e[10],d=e[11],t[0]=r=e[0],t[1]=n,t[2]=s,t[3]=o,t[4]=a,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=f,t[10]=p,t[11]=d,t[12]=r*m+a*_+c*g+e[12],t[13]=n*m+l*_+f*g+e[13],t[14]=s*m+h*_+p*g+e[14],t[15]=o*m+u*_+d*g+e[15]),t}function A(t,e,i){var r=i[0],n=i[1],s=i[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*s,t[9]=e[9]*s,t[10]=e[10]*s,t[11]=e[11]*s,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function F(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[4],o=e[5],a=e[6],l=e[7],h=e[8],u=e[9],c=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]=s*n+h*r,t[5]=o*n+u*r,t[6]=a*n+c*r,t[7]=l*n+f*r,t[8]=h*n-s*r,t[9]=u*n-o*r,t[10]=c*n-a*r,t[11]=f*n-l*r,t}function S(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],h=e[8],u=e[9],c=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]=s*n-h*r,t[1]=o*n-u*r,t[2]=a*n-c*r,t[3]=l*n-f*r,t[8]=s*r+h*n,t[9]=o*r+u*n,t[10]=a*r+c*n,t[11]=l*r+f*n,t}function C(t,e,i){var r=Math.sin(i),n=Math.cos(i),s=e[0],o=e[1],a=e[2],l=e[3],h=e[4],u=e[5],c=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]=s*n+h*r,t[1]=o*n+u*r,t[2]=a*n+c*r,t[3]=l*n+f*r,t[4]=h*n-s*r,t[5]=u*n-o*r,t[6]=c*n-a*r,t[7]=f*n-l*r,t}var z=function(t,e,i,r,n){var s=1/Math.tan(e/2);if(t[0]=s/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=s,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!=n&&n!==1/0){var o=1/(r-n);t[10]=(n+r)*o,t[14]=2*n*r*o}else t[10]=-1,t[14]=-2*r;return t},T=function(t,e,i,r,n,s,o){var a=1/(e-i),l=1/(r-n),h=1/(s-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*l,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*h,t[11]=0,t[12]=(e+i)*a,t[13]=(n+r)*l,t[14]=(o+s)*h,t[15]=1,t};function P(){var t=new g(3);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function I(t){var e=new g(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function k(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function $(t,e,i){var r=new g(3);return r[0]=t,r[1]=e,r[2]=i,r}function j(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function R(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function O(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,r){return t[0]=e[0]+i[0]*r,t[1]=e[1]+i[1]*r,t[2]=e[2]+i[2]*r,t}function L(t,e){var i=e[0],r=e[1],n=e[2],s=i*i+r*r+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function U(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function N(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[0],a=i[1],l=i[2];return t[0]=n*l-s*a,t[1]=s*o-r*l,t[2]=r*a-n*o,t}function G(t,e,i){var r=i[0],n=i[1],s=i[2],o=i[3],a=e[0],l=e[1],h=e[2],u=n*h-s*l,c=s*a-r*h,f=r*l-n*a;return t[0]=a+o*(u+=u)+n*(f+=f)-s*(c+=c),t[1]=l+o*c+s*u-r*f,t[2]=h+o*f+r*c-n*u,t}function q(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[0],s[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),s[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t}function V(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),s[1]=n[1],s[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t}function Z(t,e,i,r){var n=[],s=[];return n[0]=e[0]-i[0],n[1]=e[1]-i[1],n[2]=e[2]-i[2],s[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),s[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),s[2]=n[2],t[0]=s[0]+i[0],t[1]=s[1]+i[1],t[2]=s[2]+i[2],t}var W=R,H=k;function Y(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3];return t[0]=i[0]*r+i[4]*n+i[8]*s+i[12]*o,t[1]=i[1]*r+i[5]*n+i[9]*s+i[13]*o,t[2]=i[2]*r+i[6]*n+i[10]*s+i[14]*o,t[3]=i[3]*r+i[7]*n+i[11]*s+i[15]*o,t}P();function X(){var t=new g(4);return g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function J(t,e,i,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"zyx",s=Math.PI/360;e*=s,r*=s,i*=s;var o=Math.sin(e),a=Math.cos(e),l=Math.sin(i),h=Math.cos(i),u=Math.sin(r),c=Math.cos(r);switch(n){case"xyz":t[0]=o*h*c+a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c-o*l*u;break;case"xzy":t[0]=o*h*c-a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c+o*l*u;break;case"yxz":t[0]=o*h*c+a*l*u,t[1]=a*l*c-o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c+o*l*u;break;case"yzx":t[0]=o*h*c+a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c-o*l*u;break;case"zxy":t[0]=o*h*c-a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u+o*l*c,t[3]=a*h*c-o*l*u;break;case"zyx":t[0]=o*h*c-a*l*u,t[1]=a*l*c+o*h*u,t[2]=a*h*u-o*l*c,t[3]=a*h*c+o*l*u;break;default:throw Error("Unknown angle order "+n)}return t}!function(){var t=new g(4);g!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var K=function(t,e,i,r){var n=new g(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=r,n};function Q(){var t=new g(2);return g!=Float32Array&&(t[0]=0,t[1]=0),t}function tt(t,e){var i=new g(2);return i[0]=t,i[1]=e,i}function et(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}function it(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)}function rt(t){return t[0]=0,t[1]=0,t}P(),$(1,0,0),$(0,1,0),X(),X(),v();var nt=function(t){var e=t[0],i=t[1];return e*e+i*i};Q();const st=8192;function ot(t,e,i){return e*(st/(t.tileSize*2**(i-t.tileID.overscaledZ)))}function at(t){return t instanceof Error?t:Error("string"==typeof t?t:String(t))}function lt(){return new Float64Array(4)}function ht(){return new Float64Array(3)}function ut(){return new Float64Array(16)}function ct(){let t=new Float64Array(16);return x(t),t}function ft(){let t=new Float32Array(16);return x(t),t}function pt(t,e,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];let s=n?"map"===r?-t.bearingInRadians:0:"viewport"===r?t.bearingInRadians:0;if(s){let t=Math.sin(s),e=Math.cos(s);i=[i[0]*e-i[1]*t,i[0]*t+i[1]*e]}return[n?i[0]:ot(e,i[0],t.zoom),n?i[1]:ot(e,i[1],t.zoom)]}function dt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function mt(t,e,i){let r=function(t){var e=t[3],i=t[4],r=t[5],n=t[6],s=t[7],o=t[8];return t[0]*(o*i-r*s)+t[1]*(-o*e+r*n)+t[2]*(s*e-i*n)}([t[0],t[1],t[2],e[0],e[1],e[2],i[0],i[1],i[2]]);if(0===r)return null;let n=N([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),s=N([],[i[0],i[1],i[2]],[t[0],t[1],t[2]]),o=N([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),a=O([],n,-t[3]);return j(a,a,O([],s,-e[3])),j(a,a,O([],o,-i[3])),O(a,a,1/r),a}function _t(t,e,i){let r=e[0]*i[0]+e[1]*i[1]+e[2]*i[2];return 0===r?null:(-(t[0]*i[0]+t[1]*i[1]+t[2]*i[2])-i[3])/r}function gt(t,e,i,r){let n=Math.sqrt(t*t+e*e),s=Math.sqrt(i*i+r*r);t/=n,e/=n,i/=s,r/=s;let o=Math.acos(t*i+e*r);return-e*i+t*r>0?o:-o}function yt(t,e){let i=wt(t,360),r=wt(e,360),n=r-i,s=r>i?n-360:n+360;return Math.abs(n)<Math.abs(s)?n:s}function vt(t,e){let i=wt(t,2*Math.PI),r=wt(e,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))}function wt(t,e){return(t%e+e)%e}function bt(t,e,i,r,n){return xt(r,n,At((t-e)/(i-e),0,1))}function xt(t,e,i){return t*(1-i)+e*i}function Dt(t){let e=1/0,i=1/0,r=-1/0,n=-1/0;for(let s of t)e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y);return[e,i,r,n]}function Mt(t,e,i,r){return function(t,e,i,r){let n=3*t,s=3*(i-t)-n,o=1-n-s,a=3*e,l=3*(r-e)-a,h=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let i=t;for(let r=0;r<8;r++){let r=((o*i+s)*i+n)*i-t;if(Math.abs(r)<e)return((h*i+l)*i+a)*i;let u=(3*o*i+2*s)*i+n;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=t;for(let a=0;a<20;a++){let a=((o*i+s)*i+n)*i;if(Math.abs(a-t)<e)break;t>a?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+a)*i}}(t,e,i,r)}const Et=Mt(.25,.1,.25,1);function At(t,e,i){return Math.min(i,Math.max(e,t))}function Ft(t,e,i){let r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function St(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function Ct(t,e){let i={};for(let r of e)r in t&&(i[r]=t[r]);return i}let zt=1;function Tt(){return zt++}function Pt(t){return 2**t}function It(t){return Math.log(t)/Math.LN2}function kt(t,e,i){if(e<=0)return t;let r=1/e;return void 0===i||Math.abs(i)<1e-10?Math.round(t*r)/r:(i>0?Math.ceil(t*r-1e-9):Math.floor(t*r+1e-10))/r}function $t(t,e){let i={};for(let r in t)i[r]=e.call(this,t[r],r,t);return i}function jt(t,e){let i={};for(let r in t)e.call(this,t[r],r,t)&&(i[r]=t[r]);return i}function Rt(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(!Rt(t[i],e[i]))return!1;return!0}if("object"==typeof t&&t&&null!==e){if("object"!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(!Rt(t[i],e[i]))return!1;return!0}return t===e}function Ot(t){return Array.isArray(t)?t.map(Ot):"object"==typeof t&&t?$t(t,Ot):t}const Bt={};function Lt(t){Bt[t]||(typeof console<"u"&&console.warn(t),Bt[t]=!0)}function Ut(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function Nt(t,e,i,r){let n=e.y-t.y,s=e.x-t.x,o=r.y-i.y,a=r.x-i.x,l=o*s-a*n;if(0===l)return null;let h=(a*(t.y-i.y)-o*(t.x-i.x))/l;return new f(t.x+h*s,t.y+h*n)}function Gt([t,e,i]){return e+=90,e*=Math.PI/180,i*=Math.PI/180,[t*Math.cos(e)*Math.sin(i),t*Math.sin(e)*Math.sin(i),t*Math.cos(i)]}function qt(t){return typeof WorkerGlobalScope<"u"&&void 0!==t&&t instanceof WorkerGlobalScope}let Vt=null;function Zt(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}function Wt(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function Ht(t){return t*Math.PI/180}function Yt(t){return t/Math.PI*180}function Xt(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing}function Jt(t,e,i){let r=tt(e.x-i.x,e.y-i.y),n=tt(t.x-i.x,t.y-i.y);return Yt(Math.atan2(r[0]*n[1]-r[1]*n[0],function(t,e){return t[0]*e[0]+t[1]*e[1]}(r,n)))}function Kt(t,e,i){let r=new Float64Array(4);return J(r,t,e-90,i),r}const Qt=85.051129,te={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ee={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function ie(t,e){return te[e]&&"touches"in t}function re(t,e){if(!ee[e])return!1;let i=t,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function ne(t){return te[t]||ee[t]}const se="AbortError";var oe=class extends Error{constructor(t=se){super(t instanceof Error?t.message:t),this.name=se,t instanceof Error&&t.stack&&(this.stack=t.stack)}};function ae(t){return t instanceof Error&&"AbortError"===t.name}function le(t){if(t.aborted)throw new oe(t.reason)}let he,ue,ce;const fe={frame(t,e,i,r){let n=r||window,s=n.requestAnimationFrame((t=>{o(),e(t)})),{unsubscribe:o}=Wt(t.signal,"abort",(()=>{o(),n.cancelAnimationFrame(s),i(new oe(t.signal.reason))}),!1)},frameAsync(t,e){return new Promise(((i,r)=>{this.frame(t,i,r,e)}))},getImageData(t,e=0){return this.getImageCanvasContext(t).getImageData(-e,-e,t.width+2*e,t.height+2*e)},getImageCanvasContext(t){let e;if(m()&&!_())e=new OffscreenCanvas(t.width,t.height).getContext("2d",{willReadFrequently:!0});else{let i=window.document.createElement("canvas");i.width=t.width,i.height=t.height,e=i.getContext("2d",{willReadFrequently:!0})}if(!e)throw Error("failed to create canvas 2d context");return e.drawImage(t,0,0,t.width,t.height),e},resolveURL:t=>(he||=document.createElement("a"),he.href=t,he.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===ce?!!matchMedia&&(ue??=matchMedia("(prefers-reduced-motion: reduce)"),ue.matches):ce},set prefersReducedMotion(t){ce=t}},pe=new class{constructor(){this._frozenAt=null}getCurrentTime(){return null===this._frozenAt?performance.now():this._frozenAt}setNow(t){this._frozenAt=t}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function de(){return pe.getCurrentTime()}const me=new Set("a.abbr.b.bdi.bdo.br.cite.code.del.div.em.i.img.ins.kbd.li.mark.ol.p.q.s.samp.small.span.strong.sub.sup.time.u.ul.var.wbr".split(".")),_e=new Set(["alt","class","datetime","dir","height","href","hreflang","lang","referrerpolicy","rel","role","src","target","title","translate","type","width"]),ge=new Set(["href","src"]),ye=new Set(["http:","https:","mailto:"]);let ve;function we(){return ve??={getAttribute:Element.prototype.getAttribute,getAttributeNames:Element.prototype.getAttributeNames,querySelectorAll:Element.prototype.querySelectorAll,remove:Element.prototype.remove,removeAttribute:Element.prototype.removeAttribute,localName:Object.getOwnPropertyDescriptor(Element.prototype,"localName").get,namespaceURI:Object.getOwnPropertyDescriptor(Element.prototype,"namespaceURI").get},ve}var be=class t{static{this.docStyle=typeof window<"u"&&window.document?.documentElement.style}static{this.selectProp=!t.docStyle||"userSelect"in t.docStyle?"userSelect":"webkitUserSelect"}static create(t,e,i){let r=window.document.createElement(t);return void 0!==e&&(r.className=e),i&&i.appendChild(r),r}static createNS(t,e){return window.document.createElementNS(t,e)}static disableDrag(){t.docStyle&&t.selectProp&&(t.userSelect=t.docStyle[t.selectProp],t.docStyle[t.selectProp]="none")}static enableDrag(){t.docStyle&&t.selectProp&&(t.docStyle[t.selectProp]=t.userSelect)}static suppressClickInternal(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",t.suppressClickInternal,!0)}static suppressClick(){window.addEventListener("click",t.suppressClickInternal,!0),window.setTimeout((()=>{window.removeEventListener("click",t.suppressClickInternal,!0)}),0)}static getScale(t){let e=t.getBoundingClientRect();return{x:e.width/t.offsetWidth||1,y:e.height/t.offsetHeight||1,boundingClientRect:e}}static getPoint(t,e,i){let r=e.boundingClientRect;return new f((i.clientX-r.left)/e.x-t.clientLeft,(i.clientY-r.top)/e.y-t.clientTop)}static mousePos(e,i){let r=t.getScale(e);return t.getPoint(e,r,i)}static touchPos(e,i){let r=[],n=t.getScale(e);for(let s of i)r.push(t.getPoint(e,n,s));return r}static sanitize(e){let i=(new DOMParser).parseFromString(e,"text/html").body,{querySelectorAll:r,remove:n}=we();for(let e of Array.from(r.call(i,"*")))t.isAllowedElement(e)?t.removeDisallowedAttributes(e):n.call(e);let s=document.createDocumentFragment();return s.append(...i.childNodes),s}static isAllowedElement(t){let{namespaceURI:e,localName:i}=we();return"http://www.w3.org/1999/xhtml"===e.call(t)&&me.has(i.call(t))}static removeDisallowedAttributes(e){let{getAttributeNames:i,getAttribute:r,removeAttribute:n}=we();for(let s of i.call(e))t.isAllowedAttribute(s,r.call(e,s))||n.call(e,s)}static isAllowedAttribute(t,e){if(!_e.has(t)&&!t.startsWith("aria-"))return!1;if(!ge.has(t))return!0;try{return ye.has(new URL(e,"https://maplibre.invalid/").protocol)}catch{return!1}}};const xe={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{}};function De(t){return xe.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const Me="global-dispatcher";var Ee=class extends Error{constructor(t,e,i,r){super(`AJAXError: ${e} (${t}): ${i}`),this.status=t,this.statusText=e,this.url=i,this.body=r}};function Ae(){if(qt(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}const Fe=async function(t,e){if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){let i=De(t.url);if(i){let r=await i(t,e);return r.data||"arrayBuffer"!==t.type?r:St(r,{data:new ArrayBuffer(0)})}if(qt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:Me},e)}if(!(t=>t.startsWith("file:")||Ae()?.startsWith("file:")&&!/^\w+:/.test(t))(t.url)){if(fetch&&Request&&AbortController&&Object.hasOwn(Request.prototype,"signal"))return async function(t,e){let i,r,n=new Request(t.url,{method:t.method||"GET",body:t.body,credentials:t.credentials,headers:t.headers,cache:t.cache,referrer:Ae(),referrerPolicy:t.referrerPolicy,signal:e.signal});"json"===t.type&&!n.headers.has("Accept")&&n.headers.set("Accept","application/json");try{i=await fetch(n)}catch(e){throw ae(e)?e:new Ee(0,at(e).message,t.url,new Blob)}if(!i.ok){let e=await i.blob();throw new Ee(i.status,i.statusText,t.url,e)}r="arrayBuffer"===t.type||"image"===t.type?i.arrayBuffer():"json"===t.type?i.json():i.text();let s=await r;return le(e.signal),{data:s,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(t,e);if(qt(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:Me},e)}return function(t,e){return new Promise(((i,r)=>{let n=new XMLHttpRequest;n.open(t.method||"GET",t.url,!0),("arrayBuffer"===t.type||"image"===t.type)&&(n.responseType="arraybuffer");for(let e in t.headers)n.setRequestHeader(e,t.headers[e]);"json"===t.type&&(n.responseType="text",t.headers?.Accept||n.setRequestHeader("Accept","application/json")),n.withCredentials="include"===t.credentials,n.onerror=()=>{r(Error(n.statusText))},n.onload=()=>{if(!e.signal.aborted)if((n.status>=200&&n.status<300||0===n.status)&&null!==n.response){let e=n.response;if("json"===t.type)try{e=JSON.parse(n.response)}catch(t){return void r(t)}i({data:e,cacheControl:n.getResponseHeader("Cache-Control"),expires:n.getResponseHeader("Expires"),etag:n.getResponseHeader("ETag")})}else{let e=new Blob([n.response],{type:n.getResponseHeader("Content-Type")});r(new Ee(n.status,n.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{n.abort(),r(new oe(e.signal.reason))})),n.send(t.body)}))}(t,e)},Se=(t,e)=>Fe(St(t,{type:"json"}),e),Ce=(t,e)=>Fe(St(t,{type:"arrayBuffer"}),e);function ze(t){if(!t||t.startsWith("data:image/"))return!0;if(t.startsWith("blob:")&&(t=t.slice(5)).startsWith("null"))return!1;if(t.indexOf("://")<=0)return!0;let e=new URL(t),i=window.location;return e.protocol===i.protocol&&e.host===i.host}let Te;(function(t){let e,i,r,n;t.resetRequestQueue=()=>{e=[],i=0,r=0,n={}},t.addThrottleControl=t=>{let e=r++;return n[e]=t,e},t.removeThrottleControl=t=>{delete n[t],a()},t.transformAndGetImage=async function(t,e,i,r,n=!0,s){let o=await t.transformRequest(e,i);return le(r.signal),Te.getImage(o,r,n,s)},t.getImage=(t,i,r=!0,n)=>new Promise(((s,o)=>{t.headers||={},t.headers.accept="image/webp,*/*",St(t,{type:"image"});let l={abortController:i,requestParameters:t,supportImageRefresh:r,imageBitmapOptions:n,state:"queued",onError:t=>{o(t)},onSuccess:t=>{s(t)}};e.push(l),a()}));let s=(t,e)=>"function"==typeof createImageBitmap?(async(t,e)=>{let i=new Blob([new Uint8Array(t)],{type:"image/png"});try{return createImageBitmap(i,e)}catch(t){throw Error(`Could not load image because of ${at(t).message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}})(t,e):(t=>new Promise(((e,i)=>{let r=new Image;r.onload=()=>{e(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame((()=>r.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII="))},r.onerror=()=>i(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."));let n=new Blob([new Uint8Array(t)],{type:"image/png"});r.src=URL.createObjectURL(n)})))(t),o=async t=>{t.state="running";let{requestParameters:e,supportImageRefresh:r,imageBitmapOptions:n,onError:o,onSuccess:h,abortController:u}=t,c=!1===r&&!n&&!qt(self)&&!De(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((t,e)=>t&&"accept"===e),!0));i++;let f=c?l(e,u):Fe(e,u);try{let e=await f;delete t.abortController,t.state="completed",e.data instanceof HTMLImageElement||Zt(e.data)?h(e):h(e.data&&0!==e.data.byteLength?{data:await s(e.data,n),cacheControl:e.cacheControl,expires:e.expires}:{data:null,cacheControl:e.cacheControl,expires:e.expires})}catch(e){delete t.abortController,o(at(e))}finally{i--,a()}},a=()=>{let t=(()=>{for(let t of Object.keys(n))if(n[t]())return!0;return!1})()?xe.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:xe.MAX_PARALLEL_IMAGE_REQUESTS;for(let r=i;r<t&&e.length>0;r++){let t=e.shift();t.abortController.signal.aborted?r--:o(t)}},l=(t,e)=>new Promise(((i,r)=>{let n=new Image,s=t.url,o=t.credentials;o&&"include"===o?n.crossOrigin="use-credentials":(o&&"same-origin"===o||!ze(s))&&(n.crossOrigin="anonymous"),e.signal.addEventListener("abort",(()=>{n.src="",r(new oe(e.signal.reason))})),n.fetchPriority="high",n.onload=()=>{n.onerror=n.onload=null,i({data:n})},n.onerror=()=>{n.onerror=n.onload=null,!e.signal.aborted&&r(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."))},n.src=s}))})(Te||={}),Te.resetRequestQueue();var Pe=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}};function Ie(t,e,i){i[t]?.includes(e)||(i[t]||=[],i[t].push(e))}function ke(t,e,i){if(i?.[t]){let r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}var $e=class{constructor(t,e={}){St(this,e),this.type=t}},je=class extends $e{constructor(t,e={}){super("error",St({error:t},e))}},Re=class{on(t,e){return this._listeners||={},Ie(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return ke(t,e,this._listeners),ke(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||={},Ie(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){let i="string"==typeof t?new $e(t,e||{}):t,r=i.type;if(this.listens(r)){i.target=this;let t=this._listeners?.[r]?.slice()??[];for(let e of t)e.call(this,i);let e=this._oneTimeListeners?.[r]?.slice()??[];for(let t of e)ke(r,t,this._oneTimeListeners),t.call(this,i);let n=this._eventedParent;n&&(St(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(i))}else i instanceof je&&console.error(i.error);return this}listens(t){return!!(this._listeners?.[t]?.length||this._oneTimeListeners?.[t]?.length||this._eventedParent?.listens(t))}setEventedParent(t,e){return this._eventedParent=t,this._eventedParentData=e,this}},Oe=class extends $e{},Be=class extends Oe{},Le=class extends Oe{constructor(t={}){super("style.load",t)}},Ue=class extends Oe{constructor(t,e={}){super(t,e),this.dataType="style"}},Ne=class extends Oe{constructor(t,e={}){super(t,e),this.dataType="source"}},Ge=class extends Oe{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i,r={}){i=i instanceof MouseEvent?i:new MouseEvent(t,i);let n=be.mousePos(e.getCanvas(),i);super(t,St({point:n,lngLat:e.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}},qe=class extends Oe{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){let r="touchend"===t?i.changedTouches:i.touches,n=be.touchPos(e.getCanvasContainer(),r),s=n.map((t=>e.unproject(t))),o=n.reduce(((t,e,i,r)=>t.add(e.div(r.length))),new f(0,0));super(t,{points:n,point:o,lngLats:s,lngLat:e.unproject(o),originalEvent:i}),this._defaultPrevented=!1}},Ve=class extends Oe{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e){super("wheel",{originalEvent:e}),this._defaultPrevented=!1}},Ze=class extends Oe{},We=class extends Oe{constructor(t={}){super("terrain",t)}},He=class extends Oe{constructor(t={}){super("projectiontransition",t)}},Ye=class extends Oe{},Xe=class extends Oe{constructor(t={}){super("styleimagemissing",t)}},Je={$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:{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"},"fill-extrusion-rounded-corner-distance":{type:"number",default:0,minimum:0,units:"meters","property-type":"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","feature"]},"property-type":"data-driven"},"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"},"symbol-height-offset":{type:"number",default:0,units:"meters",requires:[{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-height-anchor":{type:"enum",values:{ground:{},absolute:{}},default:"ground",requires:["symbol-height-offset"],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-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"fill-color":{type:"color",default:"#000000",transition:!0,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,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default: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-layer-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","global-state"]},"property-type":"data-constant"},"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 Ke=Je,Qe=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ti(t,e){let i={};for(let e in t)"ref"!==e&&(i[e]=t[e]);return Qe.forEach((t=>{t in e&&(i[t]=e[t])})),i}function ei(t){t=t.slice();let 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]=ti(t[i],e[t[i].ref]));return t}function ii(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(!ii(t[i],e[i]))return!1;return!0}if("object"==typeof t&&t&&null!==e){if("object"!=typeof e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let i in t)if(!ii(t[i],e[i]))return!1;return!0}return t===e}function ri(t,e){t.push(e)}function ni(t,e,i){ri(i,{command:"addSource",args:[t,e[t]]})}function si(t,e,i){ri(e,{command:"removeSource",args:[t]}),i[t]=!0}function oi(t,e,i,r){si(t,i,r),ni(t,e,i)}function ai(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!ii(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!ii(t[i][r],e[i][r]))return!1;return!0}function li(t,e,i,r,n){ri(e,{command:n,args:[i,r,t[r]]})}function hi(t,e,i,r,n){t||={},e||={};for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(ii(t[s],e[s])||li(e,i,r,s,n));for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&!Object.prototype.hasOwnProperty.call(t,s)&&(ii(t[s],e[s])||li(e,i,r,s,n))}function ui(t){return t.id}function ci(t,e){return t[e.id]=e,t}var fi=class{constructor(t,e,i,r,n="error"){this.message=(t?`${t}: `:"")+i,r&&(this.identifier=r),this.severity=n,null!=e&&e.__line__&&(this.line=e.__line__)}};const pi={kind:"null"},di={kind:"number"},mi={kind:"string"},_i={kind:"boolean"},gi={kind:"color"},yi={kind:"projectionDefinition"},vi={kind:"object"},wi={kind:"value"},bi={kind:"collator"},xi={kind:"formatted"},Di={kind:"padding"},Mi={kind:"colorArray"},Ei={kind:"numberArray"},Ai={kind:"resolvedImage"},Fi={kind:"variableAnchorOffsetCollection"};function Si(t,e){return{kind:"array",itemType:t,N:e}}function Ci(t){if("array"===t.kind){let e=Ci(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const zi=[pi,di,mi,_i,gi,yi,xi,vi,Si(wi),Di,Ei,Mi,Ai,Fi];function Ti(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Ti(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(let t of zi)if(!Ti(t,e))return null}return`Expected ${Ci(t)} but found ${Ci(e)} instead.`}function Pi(t,e){return e.some((e=>e.kind===t.kind))}function Ii(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 ki(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const $i=.96422,ji=.82521,Ri=4/29,Oi=6/29,Bi=3*Oi*Oi,Li=Math.PI/180,Ui=180/Math.PI;function Ni(t){return(t%=360)<0&&(t+=360),t}function Gi([t,e,i,r]){let n,s,o=Vi((.2225045*(t=qi(t))+.7168786*(e=qi(e))+.0606169*(i=qi(i)))/1);t===e&&e===i?n=s=o:(n=Vi((.4360747*t+.3850649*e+.1430804*i)/$i),s=Vi((.0139322*t+.0971045*e+.7141733*i)/ji));let a=116*o-16;return[a<0?0:a,500*(n-o),200*(o-s),r]}function qi(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Vi(t){return t>.008856451679035631?t**(1/3):t/Bi+Ri}function Zi([t,e,i,r]){let n=(t+16)/116,s=isNaN(e)?n:n+e/500,o=isNaN(i)?n:n-i/200;return n=1*Hi(n),s=$i*Hi(s),o=ji*Hi(o),[Wi(3.1338561*s-1.6168667*n-.4906146*o),Wi(-.9787684*s+1.9161415*n+.033454*o),Wi(.0719453*s-.2289914*n+1.4052427*o),r]}function Wi(t){return(t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055)<0?0:t>1?1:t}function Hi(t){return t>Oi?t*t*t:Bi*(t-Ri)}const Yi=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function Xi(t,e){return Yi(t,e)?t[e]:void 0}function Ji(t){return parseInt(t.padEnd(2,t),16)/255}function Ki(t,e){return Qi(e?t/100:t,0,1)}function Qi(t,e,i){return Math.min(Math.max(e,t),i)}function tr(t){return!t.some(Number.isNaN)}const er={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 ir(t,e,i){return t+i*(e-t)}function rr(t,e,i){return t.map(((t,r)=>ir(t,e[r],i)))}var nr=class t{constructor(t,e,i,r=1,n=!0){this.r=t,this.g=e,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[t,e,i,r]))}static{this.black=new t(0,0,0,1)}static{this.white=new t(1,1,1,1)}static{this.transparent=new t(0,0,0,0)}static{this.red=new t(1,0,0,1)}static parse(e){if(e instanceof t)return e;if("string"!=typeof e)return;let i=function(t){if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];let e=Xi(er,t);if(e){let[t,i,r]=e;return[t/255,i/255,r/255,1]}if(t.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(t)){let e=t.length<6?1:2,i=1;return[Ji(t.slice(i,i+=e)),Ji(t.slice(i,i+=e)),Ji(t.slice(i,i+=e)),Ji(t.slice(i,i+e)||"ff")]}if(t.startsWith("rgb")){let e=t.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(e){let[t,i,r,n,s,o,a,l,h,u,c,f]=e,p=[n||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){let t=[r,o,h].join(""),e="%%%"===t?100:""===t?255:0;if(e){let t=[Qi(+i/e,0,1),Qi(+s/e,0,1),Qi(+l/e,0,1),c?Ki(+c,f):1];if(tr(t))return t}}return}}let i=t.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){let[t,e,r,n,s,o,a,l,h]=i,u=[r||" ",s||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){let t=[+e,Qi(+n,0,100),Qi(+o,0,100),l?Ki(+l,h):1];if(tr(t))return function([t,e,i,r]){function n(r){let n=(r+t/30)%12,s=e*Math.min(i,1-i);return i-s*Math.max(-1,Math.min(n-3,9-n,1))}return t=Ni(t),e/=100,i/=100,[n(0),n(8),n(4),r]}(t)}}}(e);return i?new t(...i,!1):void 0}get rgb(){let{r:t,g:e,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[t/n,e/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(t){let[e,i,r,n]=Gi(t),s=Math.sqrt(i*i+r*r);return[Math.round(1e4*s)?Ni(Math.atan2(r,i)*Ui):NaN,s,e,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Gi(this.rgb))}overwriteGetter(t,e){return Object.defineProperty(this,t,{value:e}),e}toString(){let[t,e,i,r]=this.rgb;return`rgba(${[t,e,i].map((t=>Math.round(255*t))).join(",")},${r})`}static interpolate(e,i,r,n="rgb"){switch(n){case"rgb":{let[n,s,o,a]=rr(e.rgb,i.rgb,r);return new t(n,s,o,a,!1)}case"hcl":{let n,s,[o,a,l,h]=e.hcl,[u,c,f,p]=i.hcl;if(isNaN(o)||isNaN(u))isNaN(o)?isNaN(u)?n=NaN:(n=u,(1===l||0===l)&&(s=c)):(n=o,(1===f||0===f)&&(s=a));else{let t=u-o;u>o&&t>180?t-=360:u<o&&o-u>180&&(t+=360),n=o+r*t}let[d,m,_,g]=function([t,e,i,r]){return t=isNaN(t)?0:t*Li,Zi([i,Math.cos(t)*e,Math.sin(t)*e,r])}([n,s??ir(a,c,r),ir(l,f,r),ir(h,p,r)]);return new t(d,m,_,g,!1)}case"lab":{let[n,s,o,a]=Zi(rr(e.lab,i.lab,r));return new t(n,s,o,a,!1)}}}};const sr=["bottom","center","top"];var or=class{constructor(t,e,i,r,n,s){this.text=t,this.image=e,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=s}},ar=class t{constructor(t){this.sections=t}static fromString(e){return new t([new or(e,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(e){return e instanceof t?e:t.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}},lr=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(let t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r){return new t(rr(e.values,i.values,r))}},hr=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("number"==typeof e)return new t([e]);if(Array.isArray(e)){for(let t of e)if("number"!=typeof t)return;return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r){return new t(rr(e.values,i.values,r))}},ur=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){let i=nr.parse(e);return i?new t([i]):void 0}if(!Array.isArray(e))return;let i=[];for(let t of e){if("string"!=typeof t)return;let e=nr.parse(t);if(!e)return;i.push(e)}return new t(i)}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r,n="rgb"){let s=[];if(e.values.length!=i.values.length)throw Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${i.values.length}), cannot interpolate.`);for(let t=0;t<e.values.length;t++)s.push(nr.interpolate(e.values[t],i.values[t],r,n));return new t(s)}},cr=class extends Error{constructor(t,e){super(t),this.name="RuntimeError",this.path=e}toJSON(){return this.message}};const fr=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var pr=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let t=0;t<e.length;t+=2){let i=e[t],r=e[t+1];if("string"!=typeof i||!fr.has(i)||!Array.isArray(r)||2!==r.length||"number"!=typeof r[0]||"number"!=typeof r[1])return}return new t(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,i,r,n){let s=e.values,o=i.values;if(s.length!==o.length)throw new cr(`Cannot interpolate values of different length. from: ${e.toString()}, to: ${i.toString()}`,n);let a=[];for(let t=0;t<s.length;t+=2){if(s[t]!==o[t])throw new cr(`Cannot interpolate values containing mismatched anchors. from[${t}]: ${s[t]}, to[${t}]: ${o[t]}`,n);a.push(s[t]);let[e,i]=s[t+1],[l,h]=o[t+1];a.push([ir(e,l,r),ir(i,h,r)])}return new t(a)}},dr=class t{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(e){return e?new t({name:e,available:!1}):null}},mr=class t{constructor(t,e,i){this.from=t,this.to=e,this.transition=i}toString(){return this.from===this.to&&1===this.transition?this.from:JSON.stringify([this.from,this.to,this.transition])}static interpolate(e,i,r){return new t(e,i,r)}static parse(e){return e instanceof t?e:Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]?new t(e[0],e[1],e[2]):"object"==typeof e&&"string"==typeof e.from&&"string"==typeof e.to&&"number"==typeof e.transition?new t(e.from,e.to,e.transition):"string"==typeof e?new t(e,e,1):void 0}},_r=class{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}};function gr(t,e,i,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,i,r]:[t,e,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function yr(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof mr||t instanceof nr||t instanceof _r||t instanceof ar||t instanceof lr||t instanceof hr||t instanceof ur||t instanceof pr||t instanceof dr)return!0;if(Array.isArray(t)){for(let e of t)if(!yr(e))return!1;return!0}if("object"==typeof t){for(let e in t)if(!yr(t[e]))return!1;return!0}return!1}function vr(t){if(null===t)return pi;if("string"==typeof t)return mi;if("boolean"==typeof t)return _i;if("number"==typeof t)return di;if(t instanceof nr)return gi;if(t instanceof mr)return yi;if(t instanceof _r)return bi;if(t instanceof ar)return xi;if(t instanceof lr)return Di;if(t instanceof hr)return Ei;if(t instanceof ur)return Mi;if(t instanceof pr)return Fi;if(t instanceof dr)return Ai;if(Array.isArray(t)){let e,i=t.length;for(let i of t){let t=vr(i);if(e){if(e===t)continue;e=wi;break}e=t}return Si(e||wi,i)}return vi}function wr(t){let e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof nr||t instanceof mr||t instanceof ar||t instanceof lr||t instanceof hr||t instanceof ur||t instanceof pr||t instanceof dr?t.toString():JSON.stringify(t)}var br=class t{constructor(t,e){this.type=t,this.value=e}static parse(e,i){if(2!==e.length)return i.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!yr(e[1]))return i.error(`invalid value of type "${typeof e[1]}"`);let r=e[1],n=vr(r),s=i.expectedType;return"array"===n.kind&&0===n.N&&s&&"array"===s.kind&&("number"!=typeof s.N||0===s.N)&&(n=s),new t(n,r)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}};const xr=["Unknown","Point","LineString","Polygon"];var Dr=class{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?xr[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=nr.parse(t),this._parseColorCache.set(t,e)),e}};function Mr(t,e,i){let r,n,s=t.length-1,o=0,a=s,l=0;for(;o<=a;)if(l=Math.floor((o+a)/2),r=t[l],n=t[l+1],r<=e){if(l===s||e<n)return l;o=l+1}else{if(!(r>e))throw new cr("Input is not a number.",i);a=l-1}return 0}var Er=class t{constructor(t,e,i,r){this.type=t,this.input=e,this.key=r,this.labels=[],this.outputs=[];for(let[t,e]of i)this.labels.push(t),this.outputs.push(e)}static parse(e,i){if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");let r=i.parse(e[1],1,di);if(!r)return null;let n=[],s=null;i.expectedType&&"value"!==i.expectedType.kind&&(s=i.expectedType);for(let t=1;t<e.length;t+=2){let r=1===t?-1/0:e[t],o=e[t+1],a=t,l=t+1;if("number"!=typeof r)return i.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 i.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);let h=i.parse(o,l,s);if(!h)return null;s||=h.type,n.push([r,h])}return new t(s,r,n,i.key)}evaluate(t){let e=this.labels,i=this.outputs;if(1===e.length)return i[0].evaluate(t);let r=this.input.evaluate(t);if(r<=e[0])return i[0].evaluate(t);let n=e.length;return r>=e[n-1]?i[n-1].evaluate(t):i[Mr(e,r,this.key)].evaluate(t)}eachChild(t){t(this.input);for(let e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}},Ar=class t{constructor(t,e,i,r,n,s){this.type=t,this.operator=e,this.interpolation=i,this.input=r,this.key=s,this.labels=[],this.outputs=[];for(let[t,e]of n)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,i,r){let n=0;if("exponential"===t.name)n=Fr(e,t.base,i,r);else if("linear"===t.name)n=Fr(e,1,i,r);else if("cubic-bezier"===t.name){let s=t.controlPoints;n=function(t,e,i,r){let n=3*t,s=3*(i-t)-n,o=1-n-s,a=3*e,l=3*(r-e)-a,h=1-a-l;return function(t,e=1e-6){if(t<=0)return 0;if(t>=1)return 1;let i=t;for(let r=0;r<8;r++){let r=((o*i+s)*i+n)*i-t;if(Math.abs(r)<e)return((h*i+l)*i+a)*i;let u=(3*o*i+2*s)*i+n;if(Math.abs(u)<1e-6)break;i-=r/u}let r=0,u=1;i=t;for(let a=0;a<20;a++){let a=((o*i+s)*i+n)*i;if(Math.abs(a-t)<e)break;t>a?r=i:u=i,i=.5*(r+u)}return((h*i+l)*i+a)*i}}(s[0],s[1],s[2],s[3])(Fr(e,1,i,r))}return n}static parse(e,i){let[r,n,s,...o]=e;if(!Array.isArray(n)||0===n.length)return i.error("Expected an interpolation type expression.",1);if("linear"===n[0])n={name:"linear"};else if("exponential"===n[0]){let t=n[1];if("number"!=typeof t)return i.error("Exponential interpolation requires a numeric base.",1,1);n={name:"exponential",base:t}}else{if("cubic-bezier"!==n[0])return i.error(`Unknown interpolation type ${String(n[0])}`,1,0);{let t=n.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return i.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);n={name:"cubic-bezier",controlPoints:t}}}if(e.length-1<4)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return i.error("Expected an even number of arguments.");if(s=i.parse(s,2,di),!s)return null;let a=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==Mi?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=gi;for(let t=0;t<o.length;t+=2){let e=o[t],r=o[t+1],n=t+3,s=t+4;if("number"!=typeof e)return i.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',n);if(a.length&&a[a.length-1][0]>=e)return i.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);let h=i.parse(r,s,l);if(!h)return null;l||=h.type,a.push([e,h])}return ki(l,di)||ki(l,yi)||ki(l,gi)||ki(l,Di)||ki(l,Ei)||ki(l,Mi)||ki(l,Fi)||ki(l,Si(di))?new t(l,r,n,s,a,i.key):i.error(`Type ${Ci(l)} is not interpolatable.`)}evaluate(e){let i=this.labels,r=this.outputs;if(1===i.length)return r[0].evaluate(e);let n=this.input.evaluate(e);if(n<=i[0])return r[0].evaluate(e);let s=i.length;if(n>=i[s-1])return r[s-1].evaluate(e);let o=Mr(i,n,this.key),a=t.interpolationFactor(this.interpolation,n,i[o],i[o+1]),l=r[o].evaluate(e),h=r[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return ir(l,h,a);case"color":return nr.interpolate(l,h,a);case"padding":return lr.interpolate(l,h,a);case"colorArray":return ur.interpolate(l,h,a);case"numberArray":return hr.interpolate(l,h,a);case"variableAnchorOffsetCollection":return pr.interpolate(l,h,a,this.key);case"array":return rr(l,h,a);case"projectionDefinition":return mr.interpolate(l,h,a)}case"interpolate-hcl":switch(this.type.kind){case"color":return nr.interpolate(l,h,a,"hcl");case"colorArray":return ur.interpolate(l,h,a,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return nr.interpolate(l,h,a,"lab");case"colorArray":return ur.interpolate(l,h,a,"lab")}}}eachChild(t){t(this.input);for(let e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}};function Fr(t,e,i,r){let n=r-i,s=t-i;return 0===n?0:1===e?s/n:(e**+s-1)/(e**+n-1)}const Sr={color:nr.interpolate,number:ir,padding:lr.interpolate,numberArray:hr.interpolate,colorArray:ur.interpolate,variableAnchorOffsetCollection:pr.interpolate,array:rr};var Cr=class t{constructor(t){this.type=xi,this.sections=t}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[1];if(!Array.isArray(r)&&"object"==typeof r)return i.error("First argument must be an image or text section.");let n=[],s=!1;for(let t=1;t<=e.length-1;++t){let r=e[t];if(s&&"object"==typeof r&&!Array.isArray(r)){s=!1;let t=null;if(r["font-scale"]&&(t=i.parse(r["font-scale"],1,di),!t))return null;let e=null;if(r["text-font"]&&(e=i.parse(r["text-font"],1,Si(mi)),!e))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,gi),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!sr.includes(r["vertical-align"]))return i.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${r["vertical-align"]}' instead.`);if(a=i.parse(r["vertical-align"],1,mi),!a)return null}let l=n[n.length-1];l.scale=t,l.font=e,l.textColor=o,l.verticalAlign=a}else{let r=i.parse(e[t],1,wi);if(!r)return null;let o=r.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return i.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 t(n)}evaluate(t){return new ar(this.sections.map((e=>{let i=e.content.evaluate(t);return vr(i)===Ai?new or("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new or(wr(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(let 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}};function zr(t,e,i=0,r=t.length-1,n=Pr){for(;r>i;){if(r-i>600){let s=r-i+1,o=e-i+1,a=Math.log(s),l=.5*Math.exp(2*a/3),h=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1);zr(t,e,Math.max(i,Math.floor(e-o*l/s+h)),Math.min(r,Math.floor(e+(s-o)*l/s+h)),n)}let s=t[e],o=i,a=r;for(Tr(t,i,e),n(t[r],s)>0&&Tr(t,i,r);o<a;){for(Tr(t,o,a),o++,a--;n(t[o],s)<0;)o++;for(;n(t[a],s)>0;)a--}0===n(t[i],s)?Tr(t,i,a):(a++,Tr(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Tr(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Pr(t,e){return t<e?-1:+(t>e)}function Ir(t,e){if(t.length<=1)return[t];let i,r,n=[];for(let e of t){let t=$r(e);0!==t&&(e.area=Math.abs(t),void 0===r&&(r=t<0),r===t<0?(i&&n.push(i),i=[e]):i.push(e))}if(i&&n.push(i),e>1)for(let t=0;t<n.length;t++)n[t].length<=e||(zr(n[t],e,1,n[t].length-1,kr),n[t]=n[t].slice(0,e));return n}function kr(t,e){return e.area-t.area}function $r(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}const jr={string:mi,number:di,boolean:_i,object:vi};var Rr=class t{constructor(t,e,i){this.type=t,this.args=e,this.key=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r,n=1,s=e[0];if("array"===s){let t,s;if(e.length>2){let r=e[1];if("string"!=typeof r||!(r in jr)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);t=jr[r],n++}else t=wi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return i.error('The length argument to "array" must be a positive integer literal',2);s=e[2],n++}r=Si(t,s)}else{if(!jr[s])throw Error(`Types doesn't contain name = ${s}`);r=jr[s]}let o=[];for(;n<e.length;n++){let t=i.parse(e[n],n,wi);if(!t)return null;o.push(t)}return new t(r,o,i.key)}evaluate(t){for(let e=0;e<this.args.length;e++){let i=this.args[e].evaluate(t);if(!Ti(this.type,vr(i)))return i;if(e===this.args.length-1)throw new cr(`Expected value to be of type ${Ci(this.type)}, but found ${Ci(vr(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Or={"to-boolean":_i,"to-color":gi,"to-number":di,"to-string":mi};var Br=class t{constructor(t,e,i){this.type=t,this.args=e,this.key=i}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=e[0];if(!Or[r])throw Error(`Can't parse ${r} as it is not part of the known types`);if(("to-boolean"===r||"to-string"===r)&&2!==e.length)return i.error("Expected one argument.");let n=Or[r],s=[];for(let t=1;t<e.length;t++){let r=i.parse(e[t],t,wi);if(!r)return null;s.push(r)}return new t(n,s,i.key)}evaluate(t){switch(this.type.kind){case"boolean":return!!this.args[0].evaluate(t);case"color":{let e,i;for(let r of this.args){if(e=r.evaluate(t),i=null,e instanceof nr)return e;if("string"==typeof e){let 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.`:gr(e[0],e[1],e[2],e[3]),!i))return new nr(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new cr(i||`Could not parse color from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"padding":{let e;for(let i of this.args){e=i.evaluate(t);let r=lr.parse(e);if(r)return r}throw new cr(`Could not parse padding from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"numberArray":{let e;for(let i of this.args){e=i.evaluate(t);let r=hr.parse(e);if(r)return r}throw new cr(`Could not parse numberArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"colorArray":{let e;for(let i of this.args){e=i.evaluate(t);let r=ur.parse(e);if(r)return r}throw new cr(`Could not parse colorArray from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"variableAnchorOffsetCollection":{let e;for(let i of this.args){e=i.evaluate(t);let r=pr.parse(e);if(r)return r}throw new cr(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}case"number":{let e=null;for(let i of this.args){if(e=i.evaluate(t),null===e)return 0;let r=Number(e);if(!isNaN(r))return r}throw new cr(`Could not convert ${JSON.stringify(e)} to number.`,this.key)}case"formatted":return ar.fromString(wr(this.args[0].evaluate(t)));case"resolvedImage":return dr.fromString(wr(this.args[0].evaluate(t)));case"projectionDefinition":{let e=this.args[0].evaluate(t);if(mr.parse(e))return e;throw new cr(`Could not parse projectionDefinition from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}default:return wr(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}},Lr=class t{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(let e of this.bindings)t(e[1]);t(this.result)}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);let r=[];for(let t=1;t<e.length-1;t+=2){let n=e[t];if("string"!=typeof n)return i.error(`Expected string, but found ${typeof n} instead.`,t);if(/[^a-zA-Z0-9_]/.test(n))return i.error("Variable names must contain only alphanumeric characters or '_'.",t);let s=i.parse(e[t+1],t+1);if(!s)return null;r.push([n,s])}let n=i.parse(e[e.length-1],e.length-1,i.expectedType,r);return n?new t(r,n):null}outputDefined(){return this.result.outputDefined()}},Ur=class t{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(e,i){if(2!==e.length||"string"!=typeof e[1])return i.error("'var' expression requires exactly one string literal argument.");let r=e[1];return i.scope.has(r)?new t(r,i.scope.get(r)):i.error(`Unknown variable "${r}". Make sure "${r}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}},Nr=class t{constructor(t,e){this.type=t,this.args=e}static parse(e,i){if(e.length<2)return i.error("Expected at least one argument.");let r=null,n=i.expectedType;n&&"value"!==n.kind&&(r=n);let s=[];for(let t of e.slice(1)){let e=i.parse(t,1+s.length,r,void 0,{typeAnnotation:"omit"});if(!e)return null;r||=e.type,s.push(e)}if(!r)throw Error("No output type");return n&&s.some((t=>Ti(n,t.type)))?new t(wi,s):new t(r,s)}evaluate(t){let e,i=null,r=0;for(let n of this.args)if(r++,i=n.evaluate(t),i&&i instanceof dr&&!i.available&&(e||=i.name,i=null,r===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 Gr(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 qr(t,e,i,r){return 0===r.compare(e,i)}function Vr(t,e,i){let r="=="!==t&&"!="!==t;return class n{constructor(t,e,i,r){this.lhs=t,this.rhs=e,this.key=i,this.collator=r,this.type=_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.");let i=t[0],s=e.parse(t[1],1,wi);if(!s)return null;if(!Gr(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Ci(s.type)}'.`);let o=e.parse(t[2],2,wi);if(!o)return null;if(!Gr(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Ci(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Ci(s.type)}' and '${Ci(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Rr(o.type,[s],e.key):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Rr(s.type,[o],e.key)));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error("Cannot use collator to compare non-string types.");if(a=e.parse(t[3],3,bi),!a)return null}return new n(s,o,e.key,a)}evaluate(n){let s=this.lhs.evaluate(n),o=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){let e=vr(s),i=vr(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new cr(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${i.kind}) instead.`,this.key)}if(this.collator&&!r&&this.hasUntypedArgument){let t=vr(s),i=vr(o);if("string"!==t.kind||"string"!==i.kind)return e(n,s,o)}return this.collator?i(n,s,o,this.collator.evaluate(n)):e(n,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}}}const Zr=Vr("==",(function(t,e,i){return e===i}),qr),Wr=Vr("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!qr(0,e,i,r)})),Hr=Vr("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),Yr=Vr(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),Xr=Vr("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),Jr=Vr(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));var Kr=class t{constructor(t,e,i){this.type=bi,this.locale=i,this.caseSensitive=t,this.diacriticSensitive=e}static parse(e,i){if(2!==e.length)return i.error("Expected one argument.");let r=e[1];if("object"!=typeof r||Array.isArray(r))return i.error("Collator options argument must be an object.");let n=i.parse(void 0!==r["case-sensitive"]&&r["case-sensitive"],1,_i);if(!n)return null;let s=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,_i);if(!s)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,mi),!o)?null:new t(n,s,o)}evaluate(t){return new _r(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}};const Qr=8192;function tn(t,e){let i=function(t){return(180+t)/360}(t[0]),r=function(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}(t[1]),n=2**e.z;return[Math.round(i*n*Qr),Math.round(r*n*Qr)]}function en(t,e){let i=2**e.z,r=(t[1]/Qr+e.y)/i;return[rn((t[0]/Qr+e.x)/i),nn(r)]}function rn(t){return 360*t-180}function nn(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function sn(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 on(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function an(t,e,i){return e[1]>t[1]!=i[1]>t[1]&&t[0]<(i[0]-e[0])*(t[1]-e[1])/(i[1]-e[1])+e[0]}function ln(t,e,i){let r=t[0]-e[0],n=t[1]-e[1],s=t[0]-i[0],o=t[1]-i[1];return r*o-s*n==0&&r*s<=0&&n*o<=0}function hn(t,e,i,r){return 0!==function(t,e){return t[0]*e[1]-t[1]*e[0]}([r[0]-i[0],r[1]-i[1]],[e[0]-t[0],e[1]-t[1]])&&!(!mn(t,e,i,r)||!mn(i,r,t,e))}function un(t,e,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(hn(t,e,r[i],r[i+1]))return!0;return!1}function cn(t,e,i=!1){let r=!1;for(let n of e)for(let e=0;e<n.length-1;e++){if(ln(t,n[e],n[e+1]))return i;an(t,n[e],n[e+1])&&(r=!r)}return r}function fn(t,e){for(let i of e)if(cn(t,i))return!0;return!1}function pn(t,e){for(let i of t)if(!cn(i,e))return!1;for(let i=0;i<t.length-1;++i)if(un(t[i],t[i+1],e))return!1;return!0}function dn(t,e){for(let i of e)if(pn(t,i))return!0;return!1}function mn(t,e,i,r){let n=r[0]-i[0],s=r[1]-i[1],o=(t[0]-i[0])*s-n*(t[1]-i[1]),a=(e[0]-i[0])*s-n*(e[1]-i[1]);return o>0&&a<0||o<0&&a>0}function _n(t,e,i){let r=[];for(let n=0;n<t.length;n++){let s=[];for(let r=0;r<t[n].length;r++){let o=tn(t[n][r],i);sn(e,o),s.push(o)}r.push(s)}return r}function gn(t,e,i){let r=[];for(let n=0;n<t.length;n++){let s=_n(t[n],e,i);r.push(s)}return r}function yn(t,e,i,r){if(t[0]<i[0]||t[0]>i[2]){let e=.5*r,n=t[0]-i[0]>e?-r:i[0]-t[0]>e?r:0;0===n&&(n=t[0]-i[2]>e?-r:i[2]-t[0]>e?r:0),t[0]+=n}sn(e,t)}function vn(t,e,i,r){let n=2**r.z*Qr,s=[r.x*Qr,r.y*Qr],o=[];for(let r of t)for(let t of r){let r=[t.x+s[0],t.y+s[1]];yn(r,e,i,n),o.push(r)}return o}function wn(t,e,i,r){let n=2**r.z*Qr,s=[r.x*Qr,r.y*Qr],o=[];for(let i of t){let t=[];for(let r of i){let i=[r.x+s[0],r.y+s[1]];sn(e,i),t.push(i)}o.push(t)}if(e[2]-e[0]<=n/2){!function(t){t[0]=t[1]=1/0,t[2]=t[3]=-1/0}(e);for(let t of o)for(let r of t)yn(r,e,i,n)}return o}var bn=class t{constructor(t,e){this.type=_i,this.geojson=t,this.geometries=e}static parse(e,i){if(2!==e.length)return i.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(yr(e[1])){let i=e[1];if("FeatureCollection"===i.type){let e=[];for(let t of i.features){let{type:i,coordinates:r}=t.geometry;"Polygon"===i&&e.push(r),"MultiPolygon"===i&&e.push(...r)}if(e.length)return new t(i,{type:"MultiPolygon",coordinates:e})}else if("Feature"===i.type){let e=i.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new t(i,i.geometry)}else if("Polygon"===i.type||"MultiPolygon"===i.type)return new t(i,i)}return i.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){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){let s=_n(e.coordinates,r,n),o=vn(t.geometry(),i,r,n);if(!on(i,r))return!1;for(let t of o)if(!cn(t,s))return!1}if("MultiPolygon"===e.type){let s=gn(e.coordinates,r,n),o=vn(t.geometry(),i,r,n);if(!on(i,r))return!1;for(let t of o)if(!fn(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){let i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=t.canonicalID();if("Polygon"===e.type){let s=_n(e.coordinates,r,n),o=wn(t.geometry(),i,r,n);if(!on(i,r))return!1;for(let t of o)if(!pn(t,s))return!1}if("MultiPolygon"===e.type){let s=gn(e.coordinates,r,n),o=wn(t.geometry(),i,r,n);if(!on(i,r))return!1;for(let t of o)if(!dn(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},xn=class{constructor(t=[],e=(t,e)=>t<e?-1:+(t>e)){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;let 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){let{data:e,compare:i}=this,r=e[t];for(;t>0;){let n=t-1>>1,s=e[n];if(i(r,s)>=0)break;e[t]=s,t=n}e[t]=r}_down(t){let{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1),s=r+1;if(s<this.length&&i(e[s],e[r])<0&&(r=s),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}};const Dn=Math.PI/180;var Mn=class{constructor(t){let e=6378.137*Dn*1e3,i=Math.cos(t*Dn),r=1/(1-.0066943799901413165*(1-i*i)),n=Math.sqrt(r);this.kx=e*n*i,this.ky=e*n*r*.9933056200098587}distance(t,e){let i=this.wrap(t[0]-e[0])*this.kx,r=(t[1]-e[1])*this.ky;return Math.sqrt(i*i+r*r)}pointOnLine(t,e){let i,r,n,s,o=1/0;for(let a=0;a<t.length-1;a++){let l=t[a][0],h=t[a][1],u=this.wrap(t[a+1][0]-l)*this.kx,c=(t[a+1][1]-h)*this.ky,f=0;(0!==u||0!==c)&&(f=(this.wrap(e[0]-l)*this.kx*u+(e[1]-h)*this.ky*c)/(u*u+c*c),f>1?(l=t[a+1][0],h=t[a+1][1]):f>0&&(l+=u/this.kx*f,h+=c/this.ky*f)),u=this.wrap(e[0]-l)*this.kx,c=(e[1]-h)*this.ky;let p=u*u+c*c;p<o&&(o=p,i=l,r=h,n=a,s=f)}return{point:[i,r],index:n,t:Math.max(0,Math.min(1,s))}}wrap(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}};function En(t,e){return e[0]-t[0]}function An(t){return t[1]-t[0]+1}function Fn(t,e){return t[1]>=t[0]&&t[1]<e}function Sn(t,e){if(t[0]>t[1])return[null,null];let i=An(t);if(e){if(2===i)return[t,null];let e=Math.floor(i/2);return[[t[0],t[0]+e],[t[0]+e,t[1]]]}if(1===i)return[t,null];let r=Math.floor(i/2)-1;return[[t[0],t[0]+r],[t[0]+r+1,t[1]]]}function Cn(t,e){if(!Fn(e,t.length))return[1/0,1/0,-1/0,-1/0];let i=[1/0,1/0,-1/0,-1/0];for(let r=e[0];r<=e[1];++r)sn(i,t[r]);return i}function zn(t){let e=[1/0,1/0,-1/0,-1/0];for(let i of t)for(let t of i)sn(e,t);return e}function Tn(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Pn(t,e,i){if(!Tn(t)||!Tn(e))return NaN;let r=0,n=0;return t[2]<e[0]&&(r=e[0]-t[2]),t[0]>e[2]&&(r=t[0]-e[2]),t[1]>e[3]&&(n=t[1]-e[3]),t[3]<e[1]&&(n=e[1]-t[3]),i.distance([0,0],[r,n])}function In(t,e,i){let r=i.pointOnLine(e,t);return i.distance(t,r.point)}function kn(t,e,i,r,n){let s=Math.min(In(t,[i,r],n),In(e,[i,r],n)),o=Math.min(In(i,[t,e],n),In(r,[t,e],n));return Math.min(s,o)}function $n(t,e,i,r,n){if(!Fn(e,t.length)||!Fn(r,i.length))return 1/0;let s=1/0;for(let o=e[0];o<e[1];++o){let e=t[o],a=t[o+1];for(let t=r[0];t<r[1];++t){let r=i[t],o=i[t+1];if(hn(e,a,r,o))return 0;s=Math.min(s,kn(e,a,r,o,n))}}return s}function jn(t,e,i,r,n){if(!Fn(e,t.length)||!Fn(r,i.length))return NaN;let s=1/0;for(let o=e[0];o<=e[1];++o)for(let e=r[0];e<=r[1];++e)if(s=Math.min(s,n.distance(t[o],i[e])),0===s)return s;return s}function Rn(t,e,i){if(cn(t,e,!0))return 0;let r=1/0;for(let n of e){let e=n[0],s=n[n.length-1];if(e!==s&&(r=Math.min(r,In(t,[s,e],i)),0===r))return r;let o=i.pointOnLine(n,t);if(r=Math.min(r,i.distance(t,o.point)),0===r)return r}return r}function On(t,e,i,r){if(!Fn(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(cn(t[r],i,!0))return 0;let n=1/0;for(let s=e[0];s<e[1];++s){let e=t[s],o=t[s+1];for(let t of i)for(let i=0,s=t.length,a=s-1;i<s;a=i++){let s=t[a],l=t[i];if(hn(e,o,s,l))return 0;n=Math.min(n,kn(e,o,s,l,r))}}return n}function Bn(t,e){for(let i of t)for(let t of i)if(cn(t,e,!0))return!0;return!1}function Ln(t,e,i,r=1/0){let n=zn(t),s=zn(e);if(r!==1/0&&Pn(n,s,i)>=r)return r;if(on(n,s)){if(Bn(t,e))return 0}else if(Bn(e,t))return 0;let o=1/0;for(let r of t)for(let t=0,n=r.length,s=n-1;t<n;s=t++){let n=r[s],a=r[t];for(let t of e)for(let e=0,r=t.length,s=r-1;e<r;s=e++){let r=t[s],l=t[e];if(hn(n,a,r,l))return 0;o=Math.min(o,kn(n,a,r,l,i))}}return o}function Un(t,e,i,r,n,s){if(!s)return;let o=Pn(Cn(r,s),n,i);o<e&&t.push([o,s,[0,0]])}function Nn(t,e,i,r,n,s,o){if(!s||!o)return;let a=Pn(Cn(r,s),Cn(n,o),i);a<e&&t.push([a,s,o])}function Gn(t,e,i,r,n=1/0){let s=Math.min(r.distance(t[0],i[0][0]),n);if(0===s)return s;let o=new xn([[0,[0,t.length-1],[0,0]]],En),a=zn(i);for(;o.length>0;){let n=o.pop();if(n[0]>=s)continue;let l=n[1],h=e?50:100;if(An(l)<=h){if(!Fn(l,t.length))return NaN;if(e){let e=On(t,l,i,r);if(isNaN(e)||0===e)return e;s=Math.min(s,e)}else for(let e=l[0];e<=l[1];++e){let n=Rn(t[e],i,r);if(s=Math.min(s,n),0===s)return 0}}else{let i=Sn(l,e);Un(o,s,r,t,a,i[0]),Un(o,s,r,t,a,i[1])}}return s}function qn(t,e,i,r,n,s=1/0){let o=Math.min(s,n.distance(t[0],i[0]));if(0===o)return o;let a=new xn([[0,[0,t.length-1],[0,i.length-1]]],En);for(;a.length>0;){let s=a.pop();if(s[0]>=o)continue;let l=s[1],h=s[2],u=e?50:100,c=r?50:100;if(An(l)<=u&&An(h)<=c){if(!Fn(l,t.length)&&Fn(h,i.length))return NaN;let s;if(e&&r)s=$n(t,l,i,h,n),o=Math.min(o,s);else if(e&&!r){let e=t.slice(l[0],l[1]+1);for(let t=h[0];t<=h[1];++t)if(s=In(i[t],e,n),o=Math.min(o,s),0===o)return o}else if(!e&&r){let e=i.slice(h[0],h[1]+1);for(let i=l[0];i<=l[1];++i)if(s=In(t[i],e,n),o=Math.min(o,s),0===o)return o}else s=jn(t,l,i,h,n),o=Math.min(o,s)}else{let s=Sn(l,e),u=Sn(h,r);Nn(a,o,n,t,i,s[0],u[0]),Nn(a,o,n,t,i,s[0],u[1]),Nn(a,o,n,t,i,s[1],u[0]),Nn(a,o,n,t,i,s[1],u[1])}}return o}function Vn(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]}var Zn=class t{constructor(t,e){this.type=di,this.geojson=t,this.geometries=e}static parse(e,i){if(2!==e.length)return i.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(yr(e[1])){let i=e[1];if("FeatureCollection"===i.type)return new t(i,i.features.map((t=>Vn(t.geometry))).flat());if("Feature"===i.type)return new t(i,Vn(i.geometry));if("type"in i&&"coordinates"in i)return new t(i,Vn(i))}return i.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){let i=t.geometry(),r=i.flat().map((e=>en([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let n=new Mn(r[0][1]),s=1/0;for(let t of e){switch(t.type){case"Point":s=Math.min(s,qn(r,!1,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,qn(r,!1,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Gn(r,!1,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){let i=t.geometry(),r=i.flat().map((e=>en([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let n=new Mn(r[0][1]),s=1/0;for(let t of e){switch(t.type){case"Point":s=Math.min(s,qn(r,!0,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,qn(r,!0,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Gn(r,!0,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries);if("Polygon"===t.geometryType())return function(t,e){let i=t.geometry();if(0===i.length||0===i[0].length)return NaN;let r=Ir(i,0).map((e=>e.map((e=>e.map((e=>en([e.x,e.y],t.canonical))))))),n=new Mn(r[0][0][0][1]),s=1/0;for(let t of e)for(let e of r){switch(t.type){case"Point":s=Math.min(s,Gn([t.coordinates],!1,e,n,s));break;case"LineString":s=Math.min(s,Gn(t.coordinates,!0,e,n,s));break;case"Polygon":s=Math.min(s,Ln(e,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},Wn=class t{constructor(t){this.key=t,this.type=wi}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);let r=e[1];return null==r?i.error("Global state property must be defined."):"string"==typeof r?new t(r):i.error(`Global state property must be string, but found ${typeof e[1]} instead.`)}evaluate(t){let e=t.globals?.globalState;return e&&0!==Object.keys(e).length?Xi(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}};const Hn={"==":Zr,"!=":Wr,">":Yr,"<":Hr,">=":Jr,"<=":Xr,array:Rr,at:class t{constructor(t,e,i,r){this.type=t,this.index=e,this.input=i,this.key=r}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,di),n=i.parse(e[2],2,Si(i.expectedType||wi));return r&&n?new t(n.type.itemType,r,n,i.key):null}evaluate(t){let e=this.index.evaluate(t),i=this.input.evaluate(t);if(e<0)throw new cr(`Array index out of bounds: ${e} < 0.`,this.key);if(e>=i.length)throw new cr(`Array index out of bounds: ${e} > ${i.length-1}.`,this.key);if(e!==Math.floor(e))throw new cr(`Array index must be an integer, but found ${e} instead.`,this.key);return i[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}},boolean:Rr,case:class t{constructor(t,e,i){this.type=t,this.branches=e,this.otherwise=i}static parse(e,i){if(e.length<4)return i.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return i.error("Expected an odd number of arguments.");let r;i.expectedType&&"value"!==i.expectedType.kind&&(r=i.expectedType);let n=[];for(let t=1;t<e.length-1;t+=2){let s=i.parse(e[t],t,_i);if(!s)return null;let o=i.parse(e[t+1],t+1,r);if(!o)return null;n.push([s,o]),r||=o.type}let s=i.parse(e[e.length-1],e.length-1,r);if(!s)return null;if(!r)throw Error("Can't infer output type");return new t(r,n,s)}evaluate(t){for(let[e,i]of this.branches)if(e.evaluate(t))return i.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(let[e,i]of this.branches)t(e),t(i);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}},coalesce:Nr,collator:Kr,format:Cr,image:class t{constructor(t){this.type=Ai,this.input=t}static parse(e,i){if(2!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,mi);return r?new t(r):i.error("No image name provided.")}evaluate(t){let e=this.input.evaluate(t),i=dr.fromString(e);return i&&t.availableImages&&(i.available=t.availableImages.indexOf(e)>-1),i}eachChild(t){t(this.input)}outputDefined(){return!1}},in:class t{constructor(t,e,i){this.needle=t,this.haystack=e,this.key=i,this.type=_i}static parse(e,i){if(3!==e.length)return i.error(`Expected 2 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,wi),n=i.parse(e[2],2,wi);return r&&n?Pi(r.type,[_i,mi,di,pi,wi])?new t(r,n,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(r.type)} instead`):null}evaluate(t){let e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Ii(e,["boolean","string","number","null"]))throw new cr(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(vr(e))} instead.`,this.key);if(!Ii(i,["string","array"]))throw new cr(`Expected second argument to be of type array or string, but found ${Ci(vr(i))} instead.`,this.key);return i.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}},"index-of":class t{constructor(t,e,i,r){this.needle=t,this.haystack=e,this.key=i,this.fromIndex=r,this.type=di}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,wi),n=i.parse(e[2],2,wi);if(!r||!n)return null;if(!Pi(r.type,[_i,mi,di,pi,wi]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(r.type)} instead`);if(4===e.length){let s=i.parse(e[3],3,di);return s?new t(r,n,i.key,s):null}return new t(r,n,i.key)}evaluate(t){let e,i=this.needle.evaluate(t),r=this.haystack.evaluate(t);if(!Ii(i,["boolean","string","number","null"]))throw new cr(`Expected first argument to be of type boolean, string, number or null, but found ${Ci(vr(i))} instead.`,this.key);if(this.fromIndex&&(e=this.fromIndex.evaluate(t)),Ii(r,["string"])){let t=r.indexOf(i,e);return-1===t?-1:[...r.slice(0,t)].length}if(Ii(r,["array"]))return r.indexOf(i,e);throw new cr(`Expected second argument to be of type array or string, but found ${Ci(vr(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:Ar,"interpolate-hcl":Ar,"interpolate-lab":Ar,length:class t{constructor(t,e){this.input=t,this.key=e,this.type=di}static parse(e,i){if(2!==e.length)return i.error(`Expected 1 argument, but found ${e.length-1} instead.`);let r=i.parse(e[1],1);return r?"array"!==r.type.kind&&"string"!==r.type.kind&&"value"!==r.type.kind?i.error(`Expected argument of type string or array, but found ${Ci(r.type)} instead.`):new t(r,i.key):null}evaluate(t){let e=this.input.evaluate(t);if("string"==typeof e)return[...e].length;if(Array.isArray(e))return e.length;throw new cr(`Expected value to be of type string or array, but found ${Ci(vr(e))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:Lr,literal:br,match:class t{constructor(t,e,i,r,n,s){this.inputType=t,this.type=e,this.input=i,this.cases=r,this.outputs=n,this.otherwise=s}static parse(e,i){if(e.length<5)return i.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return i.error("Expected an even number of arguments.");let r,n;i.expectedType&&"value"!==i.expectedType.kind&&(n=i.expectedType);let s={},o=[];for(let t=2;t<e.length-1;t+=2){let a=e[t],l=e[t+1];Array.isArray(a)||(a=[a]);let h=i.concat(t);if(0===a.length)return h.error("Expected at least one branch label.");for(let t of a){if("number"!=typeof t&&"string"!=typeof t)return h.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>2**53-1)return h.error(`Branch labels must be integers no larger than ${2**53-1}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(r){if(h.checkSubtype(r,vr(t)))return null}else r=vr(t);if(void 0!==s[String(t)])return h.error("Branch labels must be unique.");s[String(t)]=o.length}let u=i.parse(l,t,n);if(!u)return null;n||=u.type,o.push(u)}let a=i.parse(e[1],1,wi);if(!a)return null;let l=i.parse(e[e.length-1],e.length-1,n);return!l||"value"!==a.type.kind&&i.concat(1).checkSubtype(r,a.type)?null:new t(r,n,a,s,o,l)}evaluate(t){let e=this.input.evaluate(t);return(vr(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()}},number:Rr,"number-format":class t{constructor(t,e,i,r,n,s){this.type=mi,this.number=t,this.locale=e,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=s}static parse(e,i){if(3!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,di);if(!r)return null;let n=e[2];if("object"!=typeof n||Array.isArray(n))return i.error("NumberFormat options argument must be an object.");let s=null;if(n.locale&&(s=i.parse(n.locale,1,mi),!s))return null;let o=null;if(n.currency&&(o=i.parse(n.currency,1,mi),!o))return null;let a=null;if(n.unit&&(a=i.parse(n.unit,1,mi),!a))return null;if(o&&a)return i.error("NumberFormat options `currency` and `unit` are mutually exclusive");let l=null;if(n["min-fraction-digits"]&&(l=i.parse(n["min-fraction-digits"],1,di),!l))return null;let h=null;return n["max-fraction-digits"]&&(h=i.parse(n["max-fraction-digits"],1,di),!h)?null:new t(r,s,o,a,l,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}},object:Rr,semiliteral:class t{constructor(t){let e=null;for(let i of t){if(e){if(e===i.type)continue;e=wi;break}e=i.type}this.type=Si(e??wi,t.length),this.arr=t}static parse(e,i){if(2!==e.length)return i.error(`'semiliteral' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!yr(e[1]))return i.error(`invalid value of type "${typeof e[1]}"`);let r=e[1],n=vr(r);if("array"===n.kind){let e=r,n=i.concat(1),s=[];for(let t=0;t<e.length;t++){let i=n.parse(e[t],t,wi);if(!i)return null;s.push(i)}return new t(s)}return new br(n,r)}evaluate(t){return this.arr.map((e=>e.evaluate(t)))}eachChild(t){this.arr.forEach(t)}outputDefined(){return this.arr.every((t=>t.outputDefined()))}},slice:class t{constructor(t,e,i,r,n){this.type=t,this.input=e,this.beginIndex=i,this.key=r,this.endIndex=n}static parse(e,i){if(e.length<=2||e.length>=5)return i.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);let r=i.parse(e[1],1,wi),n=i.parse(e[2],2,di);if(!r||!n)return null;if(!Pi(r.type,[Si(wi),mi,wi]))return i.error(`Expected first argument to be of type array or string, but found ${Ci(r.type)} instead`);if(4===e.length){let s=i.parse(e[3],3,di);return s?new t(r.type,r,n,i.key,s):null}return new t(r.type,r,n,i.key)}evaluate(t){let e,i=this.input.evaluate(t),r=this.beginIndex.evaluate(t);if(this.endIndex&&(e=this.endIndex.evaluate(t)),Ii(i,["string"]))return[...i].slice(r,e).join("");if(Ii(i,["array"]))return i.slice(r,e);throw new cr(`Expected first argument to be of type array or string, but found ${Ci(vr(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:Er,string:Rr,"to-boolean":Br,"to-color":Br,"to-number":Br,"to-string":Br,var:Ur,within:bn,distance:Zn,"global-state":Wn};var Yn=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},Xn=class t{constructor(t,e=[]){this.parent=t,this.bindings={};for(let[t,i]of e)this.bindings[t]=i}concat(e){return new t(this,e)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}},Jn=class t{constructor(t,e,i=[],r,n=new Xn,s=[]){this.registry=t,this.path=i,this.key=i.map((t=>`[${t}]`)).join(""),this.scope=n,this.errors=s,this.expectedType=r,this._isConstant=e}parse(t,e,i,r,n={}){return null==e?this._parse(t,n):this.concat(e,i,r)._parse(t,n)}_parse(t,e){(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t)&&(t=["literal",t]);let i=this.key;function r(t,e,r){return"assert"===r?new Rr(e,[t],i):"coerce"===r?new Br(e,[t],i):t}if(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", []].');let i=t[0];if("string"!=typeof i)return this.error(`Expression name must be a string, but found ${typeof i} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;let n=this.registry[i];if(n){let i=n.parse(t,this);if(!i)return null;if(this.expectedType){let t=this.expectedType,n=i.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==n.kind){if("projectionDefinition"===t.kind&&["string","array","value"].includes(n.kind)||["color","formatted","resolvedImage"].includes(t.kind)&&["value","string"].includes(n.kind)||["padding","numberArray"].includes(t.kind)&&["value","number","array"].includes(n.kind)||"colorArray"===t.kind&&["value","string","array"].includes(n.kind)||"variableAnchorOffsetCollection"===t.kind&&["value","array"].includes(n.kind))i=r(i,t,e.typeAnnotation||"coerce");else if(this.checkSubtype(t,n))return null}else i=r(i,t,e.typeAnnotation||"assert")}if(!(i instanceof br)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let e=new Dr;try{i=new br(i.type,i.evaluate(e))}catch(t){return this.error(t.message),null}}return i}return this.error(`Unknown expression "${i}". 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(e,i,r){let n="number"==typeof e?this.path.concat(e):this.path,s=r?this.scope.concat(r):this.scope;return new t(this.registry,this._isConstant,n,i||null,s,this.errors)}error(t,...e){let i=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new Yn(i,t))}checkSubtype(t,e){let i=Ti(t,e);return i&&this.error(i),i}},Kn=class t{constructor(t,e,i,r,n){this.name=t,this.type=e,this._evaluate=i,this.args=r,this.key=n}evaluate(t){return this._evaluate(t,this.args,this.key)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}static parse(e,i){let r=e[0],n=t.definitions[r];if(!n)return i.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0);let s=Array.isArray(n)?n[0]:n.type,o=Array.isArray(n)?[[n[1],n[2]]]:n.overloads,a=o.filter((([t])=>!Array.isArray(t)||t.length===e.length-1)),l=null;for(let[n,o]of a){l=new Jn(i.registry,rs,i.path,null,i.scope);let a=[],h=!1;for(let t=1;t<e.length;t++){let i=e[t],r=Array.isArray(n)?n[t-1]:n.type,s=l.parse(i,1+a.length,r);if(!s){h=!0;break}a.push(s)}if(!h){if(Array.isArray(n)&&n.length!==a.length){l.error(`Expected ${n.length} arguments, but found ${a.length} instead.`);continue}for(let t=0;t<a.length;t++){let e=Array.isArray(n)?n[t]:n.type,i=a[t];l.concat(t+1).checkSubtype(e,i.type)}if(0===l.errors.length)return new t(r,s,o,a,i.key)}}if(1===a.length)i.errors.push(...l.errors);else{let t=(a.length?a:o).map((([t])=>function(t){return Array.isArray(t)?`(${t.map(Ci).join(", ")})`:`(${Ci(t.type)}...)`}(t))).join(" | "),r=[];for(let t=1;t<e.length;t++){let n=i.parse(e[t],1+r.length);if(!n)return null;r.push(Ci(n.type))}i.error(`Expected arguments of type ${t}, but found (${r.join(", ")}) instead.`)}return null}static register(e,i){t.definitions=i;for(let r in i)e[r]=t}};function Qn(t,[e,i,r,n],s){e=e.evaluate(t),i=i.evaluate(t),r=r.evaluate(t);let o=n?n.evaluate(t):1,a=gr(e,i,r,o);if(a)throw new cr(a,s);return new nr(e/255,i/255,r/255,o,!1)}function ts(t,e){return t in e&&void 0!==e[t]}function es(t,e){let i=e[t];return void 0===i?null:i}function is(t){return{type:t}}function rs(t){if(t instanceof Ur)return rs(t.boundExpression);if(t instanceof Kn&&"error"===t.name||t instanceof Kr||t instanceof bn||t instanceof Zn||t instanceof Wn)return!1;let e=t instanceof Br||t instanceof Rr,i=!0;return t.eachChild((t=>{i&&=e?rs(t):t instanceof br})),!!i&&ns(t)&&os(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function ns(t){if(t instanceof Kn&&("get"===t.name&&1===t.args.length||"feature-state"===t.name||"has"===t.name&&1===t.args.length||"properties"===t.name||"geometry-type"===t.name||"id"===t.name||/^filter-/.test(t.name))||t instanceof bn||t instanceof Zn)return!1;let e=!0;return t.eachChild((t=>{e&&!ns(t)&&(e=!1)})),e}function ss(t){if(t instanceof Kn&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!ss(t)&&(e=!1)})),e}function os(t,e){if(t instanceof Kn&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!os(t,e)&&(i=!1)})),i}function as(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function ls(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function hs(t){return!!t.expression&&t.expression.interpolated}Kn.register(Hn,{error:[{kind:"error"},[mi],(t,[e],i)=>{throw new cr(e.evaluate(t),i)}],typeof:[mi,[wi],(t,[e])=>Ci(vr(e.evaluate(t)))],"to-rgba":[Si(di,4),[gi],(t,[e])=>{let[i,r,n,s]=e.evaluate(t).rgb;return[255*i,255*r,255*n,s]}],rgb:[gi,[di,di,di],Qn],rgba:[gi,[di,di,di,di],Qn],has:{type:_i,overloads:[[[mi],(t,[e])=>ts(e.evaluate(t),t.properties())],[[mi,vi],(t,[e,i])=>ts(e.evaluate(t),i.evaluate(t))]]},get:{type:wi,overloads:[[[mi],(t,[e])=>es(e.evaluate(t),t.properties())],[[mi,vi],(t,[e,i])=>es(e.evaluate(t),i.evaluate(t))]]},"feature-state":[wi,[mi],(t,[e])=>es(e.evaluate(t),t.featureState||{})],properties:[vi,[],t=>t.properties()],"geometry-type":[mi,[],t=>t.geometryType()],id:[wi,[],t=>t.id()],zoom:[di,[],t=>t.globals.zoom],"heatmap-density":[di,[],t=>t.globals.heatmapDensity||0],elevation:[di,[],t=>t.globals.elevation||0],"line-progress":[di,[],t=>t.globals.lineProgress||0],accumulated:[wi,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[di,is(di),(t,e)=>{let i=0;for(let r of e)i+=r.evaluate(t);return i}],"*":[di,is(di),(t,e)=>{let i=1;for(let r of e)i*=r.evaluate(t);return i}],"-":{type:di,overloads:[[[di,di],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[di],(t,[e])=>-e.evaluate(t)]]},"/":[di,[di,di],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[di,[di,di],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[di,[],()=>Math.LN2],pi:[di,[],()=>Math.PI],e:[di,[],()=>Math.E],"^":[di,[di,di],(t,[e,i])=>e.evaluate(t)**+i.evaluate(t)],sqrt:[di,[di],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[di,[di],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[di,[di],(t,[e])=>Math.log(e.evaluate(t))],log2:[di,[di],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[di,[di],(t,[e])=>Math.sin(e.evaluate(t))],cos:[di,[di],(t,[e])=>Math.cos(e.evaluate(t))],tan:[di,[di],(t,[e])=>Math.tan(e.evaluate(t))],asin:[di,[di],(t,[e])=>Math.asin(e.evaluate(t))],acos:[di,[di],(t,[e])=>Math.acos(e.evaluate(t))],atan:[di,[di],(t,[e])=>Math.atan(e.evaluate(t))],min:[di,is(di),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[di,is(di),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[di,[di],(t,[e])=>Math.abs(e.evaluate(t))],round:[di,[di],(t,[e])=>{let i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[di,[di],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[di,[di],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[_i,[mi,wi],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[_i,[wi],(t,[e])=>t.id()===e.value],"filter-type-==":[_i,[mi],(t,[e])=>t.geometryType()===e.value],"filter-<":[_i,[mi,wi],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[_i,[wi],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[_i,[mi,wi],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[_i,[wi],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[_i,[mi,wi],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[_i,[wi],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[_i,[mi,wi],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[_i,[wi],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[_i,[wi],(t,[e])=>{let i=e.value,r=t.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[_i,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[_i,[Si(mi)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[_i,[Si(wi)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[_i,[mi,Si(wi)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[_i,[mi,Si(wi)],(t,[e,i])=>function(t,e,i,r){for(;i<=r;){let n=i+r>>1;if(e[n]===t)return!0;e[n]>t?r=n-1:i=n+1}return!1}(t.properties()[e.value],i.value,0,i.value.length-1)],all:{type:_i,overloads:[[[_i,_i],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[is(_i),(t,e)=>{for(let i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:_i,overloads:[[[_i,_i],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[is(_i),(t,e)=>{for(let i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[_i,[_i],(t,[e])=>!e.evaluate(t)],"is-supported-script":[_i,[mi],(t,[e])=>{let i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[mi,[mi],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[mi,[mi],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[mi,is(wi),(t,e)=>e.map((e=>wr(e.evaluate(t)))).join("")],split:[Si(mi),[mi,mi],(t,[e,i])=>e.evaluate(t).split(i.evaluate(t))],join:[mi,[Si(mi),mi],(t,[e,i])=>e.evaluate(t).join(i.evaluate(t))],"resolved-locale":[mi,[bi],(t,[e])=>e.evaluate(t).resolvedLocale()]});const us=/^(.*)-transition$/;function cs(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function fs(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function ps(t){return"object"==typeof t&&!!t&&!Array.isArray(t)&&vr(t)===vi}function ds(t){return t}function ms(t,e){let i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),n=t.type||(hs(e)?"exponential":"interval"),s=function(t){switch(t.type){case"color":return nr.parse;case"padding":return lr.parse;case"numberArray":return hr.parse;case"colorArray":return ur.parse;default:return null}}(e);if(s&&((t=cs({},t)).stops&&(t.stops=t.stops.map((t=>[t[0],s(t[1])]))),t.default=s(t.default?t.default:e.default)),t.colorSpace&&!function(t){return"rgb"===t||"hcl"===t||"lab"===t}(t.colorSpace))throw Error(`Unknown color space: "${t.colorSpace}"`);let o,a,l=function(t){switch(t){case"exponential":return vs;case"interval":return ys;case"categorical":return gs;case"identity":return ws;default:throw Error(`Unknown function type "${t}"`)}}(n);if("categorical"===n){o=Object.create(null);for(let e of t.stops)o[e[0]]=e[1];a=typeof t.stops[0][0]}if(i){let i={},r=[];for(let e=0;e<t.stops.length;e++){let n=t.stops[e],s=n[0].zoom;void 0===i[s]&&(i[s]={zoom:s,type:t.type,property:t.property,default:t.default,stops:[]},r.push(s)),i[s].stops.push([n[0].value,n[1]])}let n=[];for(let t of r)n.push([i[t].zoom,ms(i[t],e)]);let s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:Ar.interpolationFactor.bind(void 0,s),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>vs({stops:n,base:t.base},e,i).evaluate(i,r)}}if(r){let i="exponential"===n?{name:"exponential",base:void 0===t.base?1:t.base}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Ar.interpolationFactor.bind(void 0,i),zoomStops:t.stops.map((t=>t[0])),evaluate:({zoom:i})=>l(t,e,i,o,a)}}return{kind:"source",evaluate(i,r){let n=r&&r.properties?r.properties[t.property]:void 0;return void 0===n?_s(t.default,e.default):l(t,e,n,o,a)}}}function _s(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function gs(t,e,i,r,n){return _s(typeof i===n?r[i]:void 0,t.default,e.default)}function ys(t,e,i){if("number"!==fs(i))return _s(t.default,e.default);let r=t.stops.length;if(1===r||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[r-1][0])return t.stops[r-1][1];let n=Mr(t.stops.map((t=>t[0])),i,"");return t.stops[n][1]}function vs(t,e,i){let r=void 0===t.base?1:t.base;if("number"!==fs(i))return _s(t.default,e.default);let n=t.stops.length;if(1===n||i<=t.stops[0][0])return t.stops[0][1];if(i>=t.stops[n-1][0])return t.stops[n-1][1];let s=Mr(t.stops.map((t=>t[0])),i,""),o=function(t,e,i,r){let n=r-i,s=t-i;return 0===n?0:1===e?s/n:(e**+s-1)/(e**+n-1)}(i,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],l=t.stops[s+1][1],h=Sr[e.type]||ds;return"function"==typeof a.evaluate?{evaluate(...e){let i=a.evaluate.apply(void 0,e),r=l.evaluate.apply(void 0,e);if(void 0!==i&&void 0!==r)return h(i,r,o,t.colorSpace)}}:h(a,l,o,t.colorSpace)}function ws(t,e,i){switch(e.type){case"color":i=nr.parse(i);break;case"formatted":i=ar.fromString(i.toString());break;case"resolvedImage":i=dr.fromString(i.toString());break;case"padding":i=lr.parse(i);break;case"colorArray":i=ur.parse(i);break;case"numberArray":i=hr.parse(i);break;default:fs(i)!==e.type&&("enum"!==e.type||!e.values[i])&&(i=void 0)}return _s(i,t.default,e.default)}function bs(t){return{result:"success",value:t}}function xs(t){return{result:"error",value:t}}var Ds=class{constructor(t,e,i,r){this.expression=t,this._warningHistory={},this._evaluator=new Dr,this._defaultValue=i?ks(i):null,this._enumValues=i&&"enum"===i.type?i.values:null,this._globalState=r,this._rootKey=e}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=$s(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s,this.expression.evaluate(this._evaluator)}evaluate(t,e,i,r,n,s){this._globalState&&(t=$s(t,this._globalState)),this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=s||null;try{let 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 cr(`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){let e=t instanceof cr?t.path:"",i=`${e}|${t.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Ms(this._rootKey,e,t.message,this._defaultValue))),this._defaultValue}}};function Ms(t,e,i,r){return`${t}${e}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function Es(t){if(!t)throw Error('rootKey must identify the location of the expression in the style JSON, e.g. "layers[3].paint.line-width".')}function As(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Hn}function Fs(t,e,i,r){Es(e);let n=new Jn(Hn,rs,[],i?function(t){let e={color:gi,string:mi,number:di,enum:mi,boolean:_i,formatted:xi,padding:Di,numberArray:Ei,colorArray:Mi,projectionDefinition:yi,resolvedImage:Ai,variableAnchorOffsetCollection:Fi};return"array"===t.type?Si(e[t.value]||wi,t.length):e[t.type]}(i):void 0),s=n.parse(t,void 0,void 0,void 0,i&&"string"===i.type?{typeAnnotation:"coerce"}:void 0);return s?bs(new Ds(s,e,i,r)):xs(n.errors)}var Ss=class{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!ss(e.expression),this.globalStateRefs=Is(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=$s(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=$s(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}},Cs=class{constructor(t,e,i,r,n){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!ss(e.expression),this.globalStateRefs=Is(e.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=$s(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=$s(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}interpolationFactor(t,e,i){return this.interpolationType?Ar.interpolationFactor(this.interpolationType,t,e,i):0}};function zs(t,e,i,r){let n=Fs(t,e,i,r);if("error"===n.result)return n;let s=n.value.expression,o=ns(s);if(!o&&!as(i))return xs([new Yn("","data expressions not supported")]);let a=os(s,["zoom"]);if(!a&&!ls(i))return xs([new Yn("","zoom expressions not supported")]);let l=Ps(s);return l||a?l instanceof Yn?xs([l]):l instanceof Ar&&!hs(i)?xs([new Yn("",'"interpolate" expressions cannot be used with this property')]):bs(l?new Cs(o?"camera":"composite",n.value,l.labels,l instanceof Ar?l.interpolation:void 0,r):new Ss(o?"constant":"source",n.value,r)):xs([new Yn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}var Ts=class t{constructor(t,e,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,Es(e),this._parameters=t,this._specification=i,this._rootKey=e,this._defaultValue=ks(i),this._warningHistory={};let r=ms(this._parameters,this._specification);this.kind=r.kind,this.interpolationFactor=r.interpolationFactor,this.zoomStops=r.zoomStops,this.interpolationType=r.interpolationType,this._innerEvaluate=r.evaluate}evaluate(t,e){try{return this._innerEvaluate(t,e)}catch(t){let e=t instanceof Error?t.message:String(t),i=`|${e}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Ms(this._rootKey,"",e,this._defaultValue))),this._defaultValue}}static deserialize(e){return new t(e._parameters,e._rootKey,e._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification,_rootKey:t._rootKey}}};function Ps(t){let e=null;if(t instanceof Lr)e=Ps(t.result);else if(t instanceof Nr){for(let i of t.args)if(e=Ps(i),e)break}else(t instanceof Er||t instanceof Ar)&&t.input instanceof Kn&&"zoom"===t.input.name&&(e=t);return e instanceof Yn||t.eachChild((t=>{let i=Ps(t);i instanceof Yn?e=i:!e&&i?e=new Yn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new Yn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Is(t,e=new Set){return t instanceof Wn&&e.add(t.key),t.eachChild((t=>{Is(t,e)})),e}function ks(t){if("color"===t.type&&ps(t.default))return new nr(0,0,0,0);switch(t.type){case"color":return nr.parse(t.default)||null;case"padding":return lr.parse(t.default)||null;case"numberArray":return hr.parse(t.default)||null;case"colorArray":return ur.parse(t.default)||null;case"variableAnchorOffsetCollection":return pr.parse(t.default)||null;case"projectionDefinition":return mr.parse(t.default)||null;default:return void 0===t.default?null:t.default}}function $s(t,e){let{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a}=t??{};return{zoom:i,heatmapDensity:r,elevation:n,lineProgress:s,isSupportedScript:o,accumulated:a,globalState:e}}function js(t){if("boolean"==typeof t)return"neutral";if(!Array.isArray(t)||0===t.length)return"legacy";switch(t[0]){case"has":return t.length<2||"$id"===t[1]||"$type"===t[1]?"legacy":2===t.length?"neutral":"expression";case"in":return t.length>=3&&("string"!=typeof t[1]||Array.isArray(t[2]))?"expression":"legacy";case"!in":case"!has":case"none":return"legacy";case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==t.length||Array.isArray(t[1])||Array.isArray(t[2])?"expression":"legacy";case"any":case"all":return function(t){let e=!1;for(let i of t){let t=js(i);if("expression"===t)return"expression";"legacy"===t&&(e=!0)}return e?"legacy":"neutral"}(t.slice(1));default:return"expression"}}function Rs(t){return"legacy"!==js(t)}function Os(t){return"$type"===t?["geometry-type"]:"$id"===t?["id"]:["get",t]}function Bs(t){if(("<"===t[0]||"<="===t[0]||">"===t[0]||">="===t[0])&&"$type"===t[1])return`"$type" cannot be use with operator "${t[0]}"`;let e=function(t){switch(t[0]){case"==":case"!=":case"<":case"<=":case">":case">=":return 3!==t.length||"string"!=typeof t[1]?null:[t[0],Os(t[1]),t[2]];case"in":case"!in":{if(t.length<2||"string"!=typeof t[1])return null;let e=["in",Os(t[1]),["literal",t.slice(2)]];return"!in"===t[0]?["!",e]:e}case"has":case"!has":{if(2!==t.length||"string"!=typeof t[1]||"$type"===t[1]||"$id"===t[1])return null;let e=["has",t[1]];return"!has"===t[0]?["!",e]:e}default:return null}}(t);return e?`Mixing deprecated filter syntax with expression syntax is not supported. Replace ${JSON.stringify(t)} with ${JSON.stringify(e)}.`:`Mixing deprecated filter syntax with expression syntax is not supported. Convert ${JSON.stringify(t)} to expression syntax.`}function Ls(t,e,i){let r=i[t];return Array.isArray(r)?Rs(r)?Us(r,e.concat(t)):{path:e.concat(t),legacyFilter:r}:null}function Us(t,e=[]){if(!Array.isArray(t)||t.length<1)return null;switch(t[0]){case"all":case"any":case"none":for(let i=1;i<t.length;i++){let r=Ls(i,e,t);if(r)return r}break;case"!":{let i=Ls(1,e,t);if(i)return i;break}case"case":for(let i=1;i<t.length-1;i+=2){let r=Ls(i,e,t);if(r)return r}}return null}const Ns={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Gs(t,e,i){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Rs(t)?function(t,e){let i=Us(t);if(!i||typeof console>"u")return;let r=i.path.map((t=>`[${t}]`)).join("");console.warn(`${e}${r}: ${Bs(i.legacyFilter)}`)}(t,e):t=Zs(t);let r=Fs(t,e,Ns,i);if("error"===r.result)throw Error(r.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return{filter:(t,e,i)=>r.value.evaluate(t,e,{},i),needGeometry:Vs(t),getGlobalStateRefs:()=>Is(r.value.expression)}}function qs(t,e){return t<e?-1:+(t>e)}function Vs(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(Vs(t[e]))return!0;return!1}function Zs(t){if(!t)return!0;let e=t[0];return t.length<=1?"any"!==e:"=="===e?Ws(t[1],t[2],"=="):"!="===e?Xs(Ws(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?Ws(t[1],t[2],e):"any"===e?function(t){return["any"].concat(t.map(Zs))}(t.slice(1)):"all"===e?["all"].concat(t.slice(1).map(Zs)):"none"===e?["all"].concat(t.slice(1).map(Zs).map(Xs)):"in"===e?Hs(t[1],t.slice(2)):"!in"===e?Xs(Hs(t[1],t.slice(2))):"has"===e?Ys(t[1]):"!has"!==e||Xs(Ys(t[1]))}function Ws(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 Hs(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(qs)]]:["filter-in-small",t,["literal",e]]}}function Ys(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function Xs(t){return["!",t]}function Js(t){let e=t.value;return e?[new fi(t.key,e,"constants have been deprecated as of v8")]:[]}function Ks(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function Qs(t){if(Array.isArray(t))return t.map(Qs);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let i in t)e[i]=Qs(t[i]);return e}return Ks(t)}function to(t){let e=t.key,i=t.value,r=t.valueSpec||{},n=t.objectElementValidators||{},s=t.style,o=t.styleSpec,a=t.validateSpec,l=[],h=fs(i);if("object"!==h)return[new fi(e,i,`object expected, ${h} found`)];for(let t in i){let h,u=t.split(".")[0],c=Xi(r,u)||r["*"];if(Xi(n,u))h=n[u];else if(Xi(r,u)){if(void 0===i[t])continue;h=a}else if(n["*"])h=n["*"];else{if(!r["*"]){l.push(new fi(e,i[t],`unknown property "${t}"`));continue}h=a}l=l.concat(h({key:(e&&`${e}.`)+t,value:i[t],valueSpec:c,style:s,styleSpec:o,object:i,objectKey:t,validateSpec:a},i))}for(let t in r)n[t]||r[t].required&&void 0===r[t].default&&void 0===i[t]&&l.push(new fi(e,i,`missing required property "${t}"`));return l}function eo(t){let e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==fs(e))return[new fi(s,e,`array expected, ${fs(e)} found`)];if(i.length&&e.length!==i.length)return[new fi(s,e,`array length ${i.length} expected, length ${e.length} found`)];let a={type:i.value,values:i.values};n.$version<7&&(a.function=i.function),"object"===fs(i.value)&&(a=i.value);let l=[];for(let i=0;i<e.length;i++)l=l.concat(o({array:e,arrayIndex:i,value:e[i],valueSpec:a,validateSpec:t.validateSpec,style:r,styleSpec:n,key:`${s}[${i}]`}));return l}function io(t){let e=t.key,i=t.value,r=t.valueSpec,n=fs(i);return"number"===n&&i!=i&&(n="NaN"),"number"===n?"minimum"in r&&i<r.minimum?[new fi(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new fi(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new fi(e,i,`number expected, ${n} found`)]}function ro(t){let e,i,r,n=t.valueSpec,s=Ks(t.value.type),o={},a="categorical"!==s&&void 0===t.value.property,l=!a,h="array"===fs(t.value.stops)&&"array"===fs(t.value.stops[0])&&"object"===fs(t.value.stops[0][0]),u=to({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"===s)return[new fi(t.key,t.value,'identity function may not have a "stops" property')];let e=[],i=t.value;return e=e.concat(eo({key:t.key,value:i,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:c})),"array"===fs(i)&&0===i.length&&e.push(new fi(t.key,i,"array must have at least one stop")),e},default:function(t){return t.validateSpec({key:t.key,value:t.value,valueSpec:n,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec})}}});return"identity"===s&&a&&u.push(new fi(t.key,t.value,'missing required property "property"')),"identity"!==s&&!t.value.stops&&u.push(new fi(t.key,t.value,'missing required property "stops"')),"exponential"===s&&t.valueSpec.expression&&!hs(t.valueSpec)&&u.push(new fi(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!as(t.valueSpec)?u.push(new fi(t.key,t.value,"property functions not supported")):a&&!ls(t.valueSpec)&&u.push(new fi(t.key,t.value,"zoom functions not supported"))),("categorical"===s||h)&&void 0===t.value.property&&u.push(new fi(t.key,t.value,'"property" property is required')),u;function c(t){let e=[],s=t.value,a=t.key;if("array"!==fs(s))return[new fi(a,s,`array expected, ${fs(s)} found`)];if(2!==s.length)return[new fi(a,s,`array length 2 expected, length ${s.length} found`)];if(h){if("object"!==fs(s[0]))return[new fi(a,s,`object expected, ${fs(s[0])} found`)];if(void 0===s[0].zoom)return[new fi(a,s,"object stop key must have zoom")];if(void 0===s[0].value)return[new fi(a,s,"object stop key must have value")];if(r&&r>Ks(s[0].zoom))return[new fi(a,s[0].zoom,"stop zoom values must appear in ascending order")];Ks(s[0].zoom)!==r&&(r=Ks(s[0].zoom),i=void 0,o={}),e=e.concat(to({key:`${a}[0]`,value:s[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:io,value:f}}))}else e=e.concat(f({key:`${a}[0]`,value:s[0]},s));return As(Qs(s[1]))?e.concat([new fi(`${a}[1]`,s[1],"expressions are not allowed in function stops.")]):e.concat(t.validateSpec({key:`${a}[1]`,value:s[1],valueSpec:n,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec}))}function f(t,r){let a=fs(t.value),l=Ks(t.value),h=null===t.value?r:t.value;if(e){if(a!==e)return[new fi(t.key,h,`${a} stop domain type must match previous stop domain type ${e}`)]}else e=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new fi(t.key,h,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==s){let e=`number expected, ${a} found`;return as(n)&&void 0===s&&(e+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new fi(t.key,h,e)]}return"categorical"!==s||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==s&&"number"===a&&void 0!==i&&l<i?[new fi(t.key,h,"stop domain values must appear in ascending order")]:(i=l,"categorical"===s&&l in o?[new fi(t.key,h,"stop domain values must be unique")]:(o[l]=!0,[])):[new fi(t.key,h,`integer expected, found ${l}`)]}}function no(t){let e=("property"===t.expressionContext?zs:Fs)(Qs(t.value),t.key,t.valueSpec);if("error"===e.result)return e.value.map((e=>new fi(`${t.key}${e.key}`,t.value,e.message)));let i=e.value.expression||e.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!i.outputDefined())return[new fi(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&&!ss(i))return[new fi(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!ss(i))return[new fi(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!os(i,["zoom","feature-state"]))return[new fi(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!ns(i))return[new fi(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function so(t){let e=t.key,i=t.value,r=fs(i);return"string"===r?nr.parse(String(i))?[]:[new fi(e,i,`color expected, "${i}" found`)]:[new fi(e,i,`color expected, ${r} found`)]}function oo(t){let e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(Ks(i))&&n.push(new fi(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(Ks(i))&&n.push(new fi(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function ao(t,e){let i=t;for(let t of e)i=i[t];return i}function lo(t,e){let i=Us(e);return i?[new fi(`${t.key}${i.path.map((t=>`[${t}]`)).join("")}`,ao(t.value,i.path),Bs(i.legacyFilter),null,"warning")]:[]}function ho(t){let e=Qs(t.value);return Rs(e)?[...lo(t,e),...no(cs({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:uo(t)}function uo(t){let e=t.value,i=t.key;if("array"!==fs(e))return[new fi(i,e,`array expected, ${fs(e)} found`)];let r,n=t.styleSpec,s=[];if(e.length<1)return[new fi(i,e,"filter array must have at least 1 element")];switch(s=s.concat(oo({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator})),Ks(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===Ks(e[1])&&s.push(new fi(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new fi(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=fs(e[1]),"string"!==r&&s.push(new fi(`${i}[1]`,e[1],`string expected, ${r} found`)));for(let t=2;t<e.length;t++)r=fs(e[t]),"$type"===Ks(e[1])?s=s.concat(oo({key:`${i}[${t}]`,value:e[t],valueSpec:n.geometry_type})):"string"!==r&&"number"!==r&&"boolean"!==r&&s.push(new fi(`${i}[${t}]`,e[t],`string, number, or boolean expected, ${r} found`));break;case"any":case"all":case"none":for(let r=1;r<e.length;r++)s=s.concat(uo({key:`${i}[${r}]`,value:e[r],styleSpec:t.styleSpec}));break;case"has":case"!has":r=fs(e[1]),2===e.length?"string"!==r&&s.push(new fi(`${i}[1]`,e[1],`string expected, ${r} found`)):s.push(new fi(i,e,`filter array for "${e[0]}" operator must have 2 elements`))}return s}function co(t,e){let i=t.key,r=t.validateSpec,n=t.style,s=t.styleSpec,o=t.value,a=t.objectKey,l=s[`${e}_${t.layerType}`];if(!l)return[];let h=a.match(us);if("paint"===e&&h&&l[h[1]]&&l[h[1]].transition)return r({key:i,value:o,valueSpec:s.transition,style:n,styleSpec:s});let u,c=t.valueSpec||l[a];if(!c)return[new fi(i,o,`unknown property "${a}"`)];if("string"===fs(o)&&as(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new fi(i,o,`"${a}" does not support interpolation syntax\nUse an identity property function instead: \`{ "type": "identity", "property": ${JSON.stringify(u[1])} }\`.`)];let f=[];return"symbol"===t.layerType&&"text-font"===a&&ps(Qs(o))&&"identity"===Ks(o.type)&&f.push(new fi(i,o,'"text-font" does not support identity functions')),f.concat(r({key:t.key,value:o,valueSpec:c,style:n,styleSpec:s,expressionContext:"property",propertyType:e,propertyKey:a}))}function fo(t){return co(t,"paint")}function po(t){return co(t,"layout")}function mo(t){let e=[],i=t.value,r=t.key,n=t.style,s=t.styleSpec;if("object"!==fs(i))return[new fi(r,i,`object expected, ${fs(i)} found`)];!i.type&&!i.ref&&e.push(new fi(r,i,'either "type" or "ref" is required'));let o=Ks(i.type),a=Ks(i.ref);if(i.id){let s=Ks(i.id);for(let o=0;o<t.arrayIndex;o++){let t=n.layers[o];Ks(t.id)===s&&e.push(new fi(r,i.id,`duplicate layer id "${i.id}", previously used at line ${t.id.__line__}`))}}if("ref"in i){let t;["type","source","source-layer","filter","layout"].forEach((t=>{t in i&&e.push(new fi(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{Ks(e.id)===a&&(t=e)})),t?t.ref?e.push(new fi(r,i.ref,"ref cannot reference another ref layer")):o=Ks(t.type):e.push(new fi(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==o)if(i.source){let t=n.sources&&n.sources[i.source],s=t&&Ks(t.type);t?"vector"===s&&"raster"===o?e.push(new fi(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?e.push(new fi(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new fi(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==s||i["source-layer"]?"raster-dem"===s&&"hillshade"!==o&&"color-relief"!==o?e.push(new fi(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"===o&&i.paint&&i.paint["line-gradient"]&&("geojson"!==s||!t.lineMetrics)&&e.push(new fi(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new fi(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new fi(r,i.source,`source "${i.source}" not found`))}else e.push(new fi(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&e.push(new fi(r,i.paint,`layer "${i.id}" redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".`)),e=e.concat(to({key:r,value:i,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":()=>[],type:()=>t.validateSpec({key:`${r}.type`,value:i.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,object:i,objectKey:"type"}),filter:ho,layout:t=>to({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>po(cs({layerType:o},t))}}),paint:t=>to({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>fo(cs({layerType:o},t))}})}})),e}function _o(t){let e=t.value,i=t.key,r=fs(e);return"string"===r?[]:[new fi(i,e,`string expected, ${r} found`)]}const go={promoteId:function({key:t,value:e}){if("string"===fs(e))return _o({key:t,value:e});{let i=[];for(let r in e)i.push(..._o({key:`${t}.${r}`,value:e[r]}));return i}}};function yo(t){let e=t.value,i=t.key,r=t.styleSpec,n=t.style,s=t.validateSpec;if(!e.type)return[new fi(i,e,'"type" is required')];let o,a=Ks(e.type);switch(a){case"vector":case"raster":return o=to({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:go,validateSpec:s}),o;case"raster-dem":return o=function(t){let e=t.sourceName??"",i=t.value,r=t.styleSpec,n=r.source_raster_dem,s=t.style,o=[],a=fs(i);if(void 0===i)return o;if("object"!==a)return o.push(new fi("source_raster_dem",i,`object expected, ${a} found`)),o;let l="custom"===Ks(i.encoding),h=["redFactor","greenFactor","blueFactor","baseShift"],u=t.value.encoding?`"${t.value.encoding}"`:"Default";for(let a in i)!l&&h.includes(a)?o.push(new fi(a,i[a],`In "${e}": "${a}" is only valid when "encoding" is set to "custom". ${u} encoding found`)):n[a]?o=o.concat(t.validateSpec({key:a,value:i[a],valueSpec:n[a],validateSpec:t.validateSpec,style:s,styleSpec:r})):o.push(new fi(a,i[a],`unknown property "${a}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:s}),o;case"geojson":if(o=to({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:s,objectElementValidators:go}),e.cluster)for(let t in e.clusterProperties){let[r,n]=e.clusterProperties[t],s="string"==typeof r?[r,["accumulated"],["get",t]]:r;o.push(...no({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),o.push(...no({key:`${i}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return o;case"video":return to({key:i,value:e,valueSpec:r.source_video,style:n,validateSpec:s,styleSpec:r});case"image":return to({key:i,value:e,valueSpec:r.source_image,style:n,validateSpec:s,styleSpec:r});case"canvas":return[new fi(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return oo({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function vo(t){let e=t.value,i=t.styleSpec,r=i.light,n=t.style,s=[],o=fs(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new fi("light",e,`object expected, ${o} found`)]),s;for(let o in e){let a=o.match(us);s=s.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:o,value:e[o],valueSpec:i.transition,validateSpec:t.validateSpec,style:n,styleSpec:i}):r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new fi(o,e[o],`unknown property "${o}"`)])}return s}function wo(t){let e=t.value,i=t.styleSpec,r=i.sky,n=t.style,s=fs(e);if(void 0===e)return[];if("object"!==s)return[new fi("sky",e,`object expected, ${s} found`)];let o=[];for(let s in e){let a=s.match(us);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?t.validateSpec({key:s,value:e[s],valueSpec:i.transition,style:n,styleSpec:i}):r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:n,styleSpec:i}):[new fi(s,e[s],`unknown property "${s}"`)])}return o}function bo(t){let e=t.value,i=t.styleSpec,r=i.terrain,n=t.style,s=[],o=fs(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new fi("terrain",e,`object expected, ${o} found`)]),s;for(let o in e)s=s.concat(r[o]?t.validateSpec({key:o,value:e[o],valueSpec:r[o],validateSpec:t.validateSpec,style:n,styleSpec:i}):[new fi(o,e[o],`unknown property "${o}"`)]);return s}function xo(t){let e=[],i=t.value,r=t.key;if(Array.isArray(i)){let n=[],s=[];for(let o in i)i[o].id&&n.includes(i[o].id)&&e.push(new fi(r,i,`all the sprites' ids must be unique, but ${i[o].id} is duplicated`)),n.push(i[o].id),i[o].url&&s.includes(i[o].url)&&e.push(new fi(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),s.push(i[o].url),e=e.concat(to({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return _o({key:r,value:i})}function Do(t){return!!t&&t.constructor===Object}function Mo(t){return Do(t.value)?[]:[new fi(t.key,t.value,`object expected, ${fs(t.value)} found`)]}const Eo=1114111,Ao=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function Fo(t,e){if("string"!==fs(e))return[];let i=`${e}`,r=()=>[new fi(t,e,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],n=i.match(Ao);if(!n)return r();let[,s,o,a]=n;if(void 0!==a)return a.length>6?r():[];let l=parseInt(s,16),h=void 0===o?l:parseInt(o,16);return l>Eo||h>Eo?[new fi(t,e,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>h?[new fi(t,e,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function So(t){let e=t.key??"font-faces",i=t.value,r=t.validateSpec,n=t.styleSpec??Je,s=t.style;if(!Do(i))return[new fi(e,i,`object expected, ${fs(i)} found`)];let o=[];for(let t in i){let a=i[t],l=fs(a);if("string"===l)o.push(..._o({key:`${e}.${t}`,value:a}));else if("array"===l){let i={url:{type:"string",required:!0},"unicode-range":{type:"array",value:"string"}};for(let[l,h]of a.entries()){let a=`${e}.${t}[${l}]`;o.push(...to({key:a,value:h,valueSpec:i,styleSpec:n,style:s,validateSpec:r}));let u=Do(h)?h["unicode-range"]:void 0;if("array"===fs(u))for(let[t,e]of u.entries())o.push(...Fo(`${a}.unicode-range[${t}]`,e))}}else o.push(new fi(`${e}.${t}`,a,`string or array expected, ${l} found`))}return o}const Co={"*":()=>[],array:eo,boolean:function(t){let e=t.value,i=t.key,r=fs(e);return"boolean"===r?[]:[new fi(i,e,`boolean expected, ${r} found`)]},number:io,color:so,constants:Js,enum:oo,filter:ho,function:ro,layer:mo,object:to,source:yo,light:vo,sky:wo,terrain:bo,projection:function(t){let e=t.value,i=t.styleSpec,r=i.projection,n=t.style,s=fs(e);if(void 0===e)return[];if("object"!==s)return[new fi("projection",e,`object expected, ${s} found`)];let o=[];for(let s in e)o=o.concat(r[s]?t.validateSpec({key:s,value:e[s],valueSpec:r[s],style:n,styleSpec:i}):[new fi(s,e[s],`unknown property "${s}"`)]);return o},projectionDefinition:function(t){let e=t.key,i=t.value;i=i instanceof String?i.valueOf():i;let r=fs(i);return"array"!==r||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(r)?[]:[new fi(e,i,`projection expected, invalid type "${r}" found`)]:[new fi(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:_o,formatted:function(t){return 0===_o(t).length?[]:no(t)},resolvedImage:function(t){return 0===_o(t).length?[]:no(t)},padding:function(t){let e=t.key,i=t.value;if("array"===fs(i)){if(i.length<1||i.length>4)return[new fi(e,i,`padding requires 1 to 4 values; ${i.length} values found`)];let r={type:"number"},n=[];for(let s=0;s<i.length;s++)n=n.concat(t.validateSpec({key:`${e}[${s}]`,value:i[s],validateSpec:t.validateSpec,valueSpec:r}));return n}return io({key:e,value:i,valueSpec:{}})},numberArray:function(t){let e=t.key,i=t.value;if("array"===fs(i)){let r={type:"number"};if(i.length<1)return[new fi(e,i,"array length at least 1 expected, length 0 found")];let n=[];for(let s=0;s<i.length;s++)n=n.concat(t.validateSpec({key:`${e}[${s}]`,value:i[s],validateSpec:t.validateSpec,valueSpec:r}));return n}return io({key:e,value:i,valueSpec:{}})},colorArray:function(t){let e=t.key,i=t.value;if("array"===fs(i)){if(i.length<1)return[new fi(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<i.length;r++)t=t.concat(so({key:`${e}[${r}]`,value:i[r]}));return t}return so({key:e,value:i})},variableAnchorOffsetCollection:function(t){let e=t.key,i=t.value,r=fs(i),n=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new fi(e,i,"variableAnchorOffsetCollection requires a non-empty array of even length")];let s=[];for(let r=0;r<i.length;r+=2)s=s.concat(oo({key:`${e}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),s=s.concat(eo({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return s},sprite:xo,state:Mo,fontFaces:So};function zo(t){let e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=zo,i.expression&&ps(Ks(e))?ro(t):i.expression&&As(Qs(e))?no(t):i.type&&Co[i.type]?Co[i.type](t):to(cs({},t,{valueSpec:i.type?r[i.type]:i}))}function To(t){let e=t.value,i=t.key,r=_o(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new fi(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new fi(i,e,'"glyphs" url must include a "{range}" token'))),r}function Po(t,e=Ke){let i=[];return i=i.concat(zo({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:zo,objectElementValidators:{glyphs:To,"*":()=>[]}})),t.constants&&(i=i.concat(Js({key:"constants",value:t.constants}))),ko(i)}function Io(t){return function(e){return t(Object.assign({},e,{validateSpec:zo}))}}function ko(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function $o(t){return function(...e){return ko(t.apply(this,e))}}Po.source=$o(Io(yo)),Po.sprite=$o(Io(xo)),Po.glyphs=$o(Io(To)),Po.fontFaces=$o(Io(So)),Po.light=$o(Io(vo)),Po.sky=$o(Io(wo)),Po.terrain=$o(Io(bo)),Po.state=$o(Io(Mo)),Po.layer=$o(Io(mo)),Po.filter=$o(Io(ho)),Po.paintProperty=$o(Io(fo)),Po.layoutProperty=$o(Io(po));const jo={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var Ro=class{constructor(t,e,i){this._rootKey=e,this._globalState=i,this.setValue(t)}evaluate(){return this._literalValue??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);let e=Fs(t,this._rootKey,jo,this._globalState);if("error"===e.result)throw this._literalValue="visible",this._compiledValue=void 0,Error(e.value.map((t=>`${t.key}: ${t.message}`)).join(", "));this._literalValue=void 0,this._compiledValue=e.value,this._globalStateRefs=Is(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};const Oo=Po,Bo=new Set(Object.keys(Ke).filter((t=>t.startsWith("source_"))).map((t=>t.slice(7).replaceAll("_","-"))));function Lo(t,e){let i=function(t){return Object.entries(t.sources??{}).filter((([,t])=>!Bo.has(t.type))).map((([t])=>`sources.${t}`))}(e);return Uo(t,Oo(e).filter((({message:t})=>!i.some((e=>t.startsWith(`${e}:`)||t.startsWith(`${e}.`))))))}function Uo(t,e){let i=!1;for(let r of e)"warning"!==r.severity?(t.fire(new je(Error(r.message))),i=!0):Lt(r.message);return i}function No(t,e,i,r){return!1!==r?.validate&&Uo(t,e({styleSpec:Ke,...i}))}var Go=class t{constructor(t,e,i){let r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;let n=new Int32Array(this.arrayBuffer);t=n[0],this.d=(e=n[1])+2*(i=n[2]);for(let t=0;t<this.d*this.d;t++){let e=n[3+t],i=n[3+t+1];r.push(e===i?null:n.subarray(e,i))}let s=n[3+r.length+1];this.keys=n.subarray(n[3+r.length],s),this.bboxes=n.subarray(s),this.insert=this._insertReadonly}else{this.d=e+2*i;for(let t=0;t<this.d*this.d;t++)r.push([]);this.keys=[],this.bboxes=[]}this.n=e,this.extent=t,this.padding=i,this.scale=e/t,this.uid=0;let n=i/e*t;this.min=-n,this.max=t+n}insert(t,e,i,r,n){this._forEachCell(e,i,r,n,this._insertCell,this.uid++,void 0,void 0),this.keys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}_insertReadonly(){throw Error("Cannot insert into a GridIndex created from an ArrayBuffer.")}_insertCell(t,e,i,r,n,s){this.cells[n].push(s)}query(t,e,i,r,n){let s=this.min,o=this.max;if(t<=s&&e<=s&&o<=i&&o<=r&&!n)return[...this.keys];{let s=[];return this._forEachCell(t,e,i,r,this._queryCell,s,{},n),s}}_queryCell(t,e,i,r,n,s,o,a){let l=this.cells[n];if(null!==l){let n=this.keys,h=this.bboxes;for(let u of l)if(void 0===o[u]){let l=4*u;(a?a(h[l+0],h[l+1],h[l+2],h[l+3]):t<=h[l+2]&&e<=h[l+3]&&i>=h[l+0]&&r>=h[l+1])?(o[u]=!0,s.push(n[u])):o[u]=!1}}}_forEachCell(t,e,i,r,n,s,o,a){let l=this._convertToCellCoord(t),h=this._convertToCellCoord(e),u=this._convertToCellCoord(i),c=this._convertToCellCoord(r);for(let f=l;f<=u;f++)for(let l=h;l<=c;l++){let h=this.d*l+f;if((!a||a(this._convertFromCellCoord(f),this._convertFromCellCoord(l),this._convertFromCellCoord(f+1),this._convertFromCellCoord(l+1)))&&n.call(this,t,e,i,r,h,s,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;let t=this.cells,e=3+this.cells.length+1+1,i=0;for(let t of this.cells)i+=t.length;let r=new Int32Array(e+i+this.keys.length+this.bboxes.length);r[0]=this.extent,r[1]=this.n,r[2]=this.padding;let n=e;for(let e=0;e<t.length;e++){let i=t[e];r[3+e]=n,r.set(i,n),n+=i.length}return r[3+t.length]=n,r.set(this.keys,n),n+=this.keys.length,r[3+t.length+1]=n,r.set(this.bboxes,n),n+=this.bboxes.length,r.buffer}static serialize(t,e){let i=t.toArrayBuffer();return e&&e.push(i),{buffer:i}}static deserialize(e){return new t(e.buffer)}};const qo={};function Vo(t,e,i={}){if(qo[t])throw Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),qo[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Vo("Object",Object),Vo("Set",Set),Vo("TransferableGridIndex",Go),Vo("Color",nr),Vo("Error",Error),Vo("AJAXError",Ee),Vo("ResolvedImage",dr),Vo("StylePropertyFunction",Ts),Vo("StyleExpression",Ds,{omit:["_evaluator"]}),Vo("ZoomDependentExpression",Cs),Vo("ZoomConstantExpression",Ss),Vo("CompoundExpression",Kn,{omit:["_evaluate"]});for(let t in Hn)Hn[t]._classRegistryKey||Vo(`Expression_${t}`,Hn[t]);function Zo(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||"ArrayBuffer"===t.constructor?.name)}function Wo(t){return t.$name||t.constructor._classRegistryKey}function Ho(t){return!function(t){if("object"!=typeof t||!t)return!1;let e=Wo(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||Zo(t)||Zt(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function Yo(t,e){if(Ho(t))return(Zo(t)||Zt(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)){let i=[];for(let r of t)i.push(Yo(r,e));return i}if("object"!=typeof t)throw Error("can't serialize object of type "+typeof t);let i=Wo(t);if(!i)throw Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!qo[i])throw Error(`${i} is not registered.`);let{klass:r}=qo[i],n=r.serialize?r.serialize(t,e):{};if(r.serialize){if(n===e?.[e.length-1])throw Error("statically serialized object won't survive transfer of $name property")}else{for(let r in t){if(!t.hasOwnProperty(r)||qo[i].omit.includes(r))continue;let s=t[r];void 0!==s&&(n[r]=qo[i].shallow.includes(r)?s:Yo(s,e))}t instanceof Error&&(n.message=t.message)}if(n.$name)throw Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function Xo(t){if(Ho(t))return t;if(Array.isArray(t))return t.map(Xo);if("object"!=typeof t)throw Error("can't deserialize object of type "+typeof t);let e=Wo(t)||"Object";if(!qo[e])throw Error(`can't deserialize unregistered class ${e}`);let{klass:i}=qo[e];if(!i)throw Error(`can't deserialize unregistered class ${e}`);if(i.deserialize)return i.deserialize(t);let r=Object.create(i.prototype);for(let i of Object.keys(t)){if("$name"===i)continue;let n=t[i];r[i]=qo[e].shallow.includes(i)?n:Xo(n)}return r}var Jo=class{constructor(){this.first=!0}update(t,e){let 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))}},Ko=class{constructor(t,e){this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new Jo,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Jo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){let 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}}},Qo=class{constructor(t,e,i,r){this.property=t,this.value=e,this.expression=function(t,e,i,r){if(ps(t))return new Ts(t,e,i);if(As(t)){let n=zs(t,e,i,r);if("error"===n.result)throw Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return n.value}{let e=t;return"color"===i.type&&"string"==typeof t?e=nr.parse(t):"padding"!==i.type||"number"!=typeof t&&!Array.isArray(t)?"numberArray"!==i.type||"number"!=typeof t&&!Array.isArray(t)?"colorArray"!==i.type||"string"!=typeof t&&!Array.isArray(t)?"variableAnchorOffsetCollection"===i.type&&Array.isArray(t)?e=pr.parse(t):"projectionDefinition"===i.type&&"string"==typeof t&&(e=mr.parse(t)):e=ur.parse(t):e=hr.parse(t):e=lr.parse(t),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>e}}}(void 0===e?t.specification.default:e,i,t.specification,r)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}readsGlobalState(t){let e=this.getGlobalStateRefs();return t.some((t=>e.has(t)))}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}},ta=class{constructor(t,e,i){this.property=t,this.value=new Qo(t,void 0,e,i)}transitioned(t,e){return e.value===this.value?e:new ia(this.property,this.value,e,St({},t.transition,this.transition),t.now)}untransitioned(){return new ia(this.property,this.value,null,{},0)}},ea=class{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues),this._globalState=i,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasProperty(t){return t in this._properties.defaultTransitionablePropertyValues}getValue(t){return Ot(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new ta(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new Qo(this._values[t].property,null===e?void 0:Ot(e),this._propertyRootKey(t),this._globalState)}setValues(t){for(let e in t){let i=t[e];e.endsWith("-transition")?this.setTransition(e.slice(0,-11),i):Rt(this._values[e].value.value,i)||this.setValue(e,i)}}getTransition(t){return Ot(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new ta(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=Ot(e)||void 0}retainPriorGlobalState(t,e,i){for(let r of Object.keys(i._values))for(let n=i._values[r];n;n=n.prior){let{value:i}=n;i.property.specification.transition&&!i.isDataDriven()&&i.expression._globalState===this._globalState&&i.readsGlobalState(t)&&(n.value=new Qo(i.property,i.value,this._propertyRootKey(r),e))}}applyGlobalStateChange(t,e,i,r){this.retainPriorGlobalState(t,e,i);let n=!1;for(let e of Object.keys(this._values)){let{value:i}=this._values[e];i.readsGlobalState(t)&&(this.setValue(e,i.value),n=!0)}return n?this.transitioned(r,i):i}serialize(){let t={};for(let e of Object.keys(this._values)){let i=this.getValue(e);void 0!==i&&(t[e]=i);let r=this.getTransition(e);void 0!==r&&(t[`${e}-transition`]=r)}return t}transitioned(t,e){let i=new ra(this._properties);for(let r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(t,e._values[r]);return i}untransitioned(){let t=new ra(this._properties);for(let e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}},ia=class{constructor(t,e,i,r,n){this.property=t,this.value=e,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,t.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(t,e,i){let r=t.now||0,n=this.value.possiblyEvaluate(t,e,i),s=this.prior;if(!s)return n;if(r>this.end||this.value.isDataDriven())return this.prior=null,n;if(r<this.begin)return s.possiblyEvaluate(t,e,i);{let o=(r-this.begin)/(this.end-this.begin);return this.property.interpolate(s.possiblyEvaluate(t,e,i),n,function(t){if(t<=0)return 0;if(t>=1)return 1;let e=t*t,i=e*t;return 4*(t<.5?i:3*(t-e)+i-.75)}(o))}}},ra=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){let r=new oa(this._properties);for(let n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}hasTransition(){for(let t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}},na=class{constructor(t,e,i){this._properties=t,this._values=Object.create(t.defaultPropertyValues),this._globalState=i,this._rootKey=e}_propertyRootKey(t){return`${this._rootKey}.${String(t)}`}hasValue(t){return void 0!==this._values[t].value}hasProperty(t){return t in this._properties.defaultPropertyValues}getValue(t){return Ot(this._values[t].value)}setValue(t,e){this._values[t]=new Qo(this._values[t].property,null===e?void 0:Ot(e),this._propertyRootKey(t),this._globalState)}serialize(){let t={};for(let e of Object.keys(this._values)){let i=this.getValue(e);void 0!==i&&(t[e]=i)}return t}possiblyEvaluate(t,e,i){let r=new oa(this._properties);for(let n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}},sa=class{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,r){return this.property.evaluate(this.value,this.parameters,t,e,i,r)}},oa=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function aa(t){if(Array.isArray(t))return t.length;let e=t?.values;return Array.isArray(e)?e.length:void 0}function la(t,e){let i=aa(t),r=aa(e);return void 0!==i&&void 0!==r&&i!==r}var ha=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e){if(t.isDataDriven())throw Error("Value should not be data driven");return t.expression.evaluate(e)}interpolate(t,e,i){if(la(t,e))return Lt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=Sr[this.specification.type];return r?r(t,e,i):t}},ua=class{constructor(t,e,i){this.specification=t,this.name=e,this.overrides=i}possiblyEvaluate(t,e,i,r){return new sa(this,"constant"===t.expression.kind||"camera"===t.expression.kind?{kind:"constant",value:t.expression.evaluate(e,null,{},i,r)}: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 sa(this,{kind:"constant",value:void 0},t.parameters);if(la(t.value.value,e.value.value))return Lt(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=Sr[this.specification.type];if(r){let n=r(t.value.value,e.value.value,i);return new sa(this,{kind:"constant",value:n},t.parameters)}return t}evaluate(t,e,i,r,n,s){return"constant"===t.kind?t.value:t.evaluate(e,i,r,n,s)}},ca=class extends ua{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new sa(this,{kind:"constant",value:void 0},e);if("constant"===t.expression.kind){let n=t.expression.evaluate(e,null,{},i,r),s="resolvedImage"===t.property.specification.type&&"string"!=typeof n?n.name:n,o=this._calculate(s,s,s,e);return new sa(this,{kind:"constant",value:o},e)}if("camera"===t.expression.kind){let 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 sa(this,{kind:"constant",value:i},e)}return new sa(this,t.expression,e)}evaluate(t,e,i,r,n,s){if("source"===t.kind){let o=t.evaluate(e,i,r,n,s);return this._calculate(o,o,o,e)}return"composite"===t.kind?this._calculate(t.evaluate({zoom:Math.floor(e.zoom)-1},i,r),t.evaluate({zoom:Math.floor(e.zoom)},i,r),t.evaluate({zoom:Math.floor(e.zoom)+1},i,r),e):t.value}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}},fa=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,i,r){if(void 0!==t.value){if("constant"===t.expression.kind){let n=t.expression.evaluate(e,null,{},i,r);return this._calculate(n,n,n,e)}return this._calculate(t.expression.evaluate(new Ko(Math.floor(e.zoom-1),e)),t.expression.evaluate(new Ko(Math.floor(e.zoom),e)),t.expression.evaluate(new Ko(Math.floor(e.zoom+1),e)),e)}}_calculate(t,e,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:t,to:e}:{from:i,to:e}}interpolate(t){return t}},pa=class{constructor(t,e){this.specification=t,this.name=e}possiblyEvaluate(t,e,i,r){return!!t.expression.evaluate(e,null,{},i,r)}interpolate(){return!1}},da=class{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(let e in t){let i=t[e];i.specification.overridable&&this.overridableProperties.push(e);let r=this.defaultPropertyValues[e]=new Qo(i,void 0,i.name,void 0),n=this.defaultTransitionablePropertyValues[e]=new ta(i,i.name,void 0);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}};Vo("DataDrivenProperty",ua),Vo("DataConstantProperty",ha),Vo("CrossFadedDataDrivenProperty",ca),Vo("CrossFadedProperty",fa),Vo("ColorRampProperty",pa);const ma=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",_a=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var ga=class extends Re{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,i){return new Ro(t,e,i)}(this.visibility,`layers[${this.id}].layout.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=Gs(t.filter,`layers[${this.id}].filter`,i)),e.layout&&(this._unevaluatedLayout=new na(e.layout,`layers[${this.id}].layout`,i)),e.paint)){this._transitionablePaint=new ea(e.paint,`layers[${this.id}].paint`,i);for(let e in t.paint)this.setPaintProperty(e,t.paint[e],{validate:!1});for(let e in t.layout)this.setLayoutProperty(e,t.layout[e],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new oa(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=Gs(t,`layers[${this.id}].filter`,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(t){if("visibility"===t)return this.visibility;if(this._transitionablePaint?.hasProperty(t))throw Error(t+ma);if(!this._unevaluatedLayout)throw Error(`Cannot get layout property "${t}" on layer type "${this.type}" which has no layout properties.`);return this._unevaluatedLayout.getValue(t)}getLayoutAffectingGlobalStateRefs(){let t=new Set;for(let e of this._visibilityExpression.getGlobalStateRefs())t.add(e);if(this._unevaluatedLayout)for(let e in this._unevaluatedLayout._values){let i=this._unevaluatedLayout._values[e];for(let e of i.getGlobalStateRefs())t.add(e)}for(let e of this._featureFilter.getGlobalStateRefs())t.add(e);return t}getPaintAffectingGlobalStateRefs(){let t=new globalThis.Map;if(this._transitionablePaint)for(let e in this._transitionablePaint._values){let i=this._transitionablePaint._values[e].value;for(let r of i.getGlobalStateRefs()){let n=t.get(r)??[];n.push({name:e,value:i.value}),t.set(r,n)}}return t}getVisibilityAffectingGlobalStateRefs(){return this._visibilityExpression.getGlobalStateRefs()}setLayoutProperty(t,e,i={}){if("visibility"===t)return this.visibility=e,this._visibilityExpression.setValue(e),void this.recalculateVisibility();this._transitionablePaint?.hasProperty(t)?this.fire(new je(Error(t+ma))):null!=e&&this._validate(Oo.layoutProperty,`layers.${this.id}.layout.${t}`,t,e,i)||this._unevaluatedLayout.setValue(t,e)}getPaintProperty(t){if(t.endsWith("-transition")){let e=t.slice(0,-11);if("visibility"===e||this._unevaluatedLayout?.hasProperty(e))throw Error(t+_a);return this._transitionablePaint.getTransition(e)}if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(t+_a);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))return this.fire(new je(Error(t+_a))),!1;if(null!=e&&this._validate(Oo.paintProperty,`layers.${this.id}.paint.${t}`,t,e,i))return!1;if(t.endsWith("-transition"))return this._transitionablePaint.setTransition(t.slice(0,-11),e||void 0),!1;{let i=this._transitionablePaint._values[t],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),s=i.value;this._transitionablePaint.setValue(t,e),this._handleSpecialPaintPropertyUpdate(t);let o=this._transitionablePaint._values[t].value;return o.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(t,s,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)}retainPriorGlobalState(t,e){this._transitionablePaint?.retainPriorGlobalState(t,e,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(){let t={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:this._unevaluatedLayout?.serialize(),paint:this._transitionablePaint?.serialize()};return this.visibility&&(t.layout||={},t.layout.visibility=this.visibility),jt(t,((t,e)=>!(void 0===t||"layout"===e&&!Object.keys(t).length||"paint"===e&&!Object.keys(t).length)))}_validate(t,e,i,r,n={}){return No(this,t,{key:e,layerType:this.type,objectKey:i,value:r},n)}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(let t in this.paint._values){let e=this.paint.get(t);if(e instanceof sa&&as(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}};let ya;var va={get paint(){return ya||=new da({"raster-opacity":new ha(Ke.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new ha(Ke.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new ha(Ke.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new ha(Ke.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new ha(Ke.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new ha(Ke.paint_raster["raster-contrast"],"raster-contrast"),resampling:new ha(Ke.paint_raster.resampling,"resampling"),"raster-resampling":new ha(Ke.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new ha(Ke.paint_raster["raster-fade-duration"],"raster-fade-duration")})}};const wa=t=>"raster"===t.type;var ba=class extends ga{constructor(t,e){super(t,va,e)}};const xa={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var Da=class{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}},Ma=class{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){let 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);let e=this.uint8;this._refreshViews(),e&&this.uint8.set(e)}}_refreshViews(){throw Error("_refreshViews() must be implemented by each concrete StructArray layout")}freeBufferAfterUpload(){this.arrayBuffer=new ArrayBuffer(0),this._refreshViews()}};function Ea(t,e=1){let i=0,r=0;return{members:t.map((t=>{let n=function(t){return xa[t].BYTES_PER_ELEMENT}(t.type),s=i=Aa(i,Math.max(e,n)),o=t.components||1;return r=Math.max(r,n),i+=n*o,{name:t.name,type:t.type,components:o,offset:s}})),size:Aa(i,Math.max(r,e)),alignment:e}}function Aa(t,e){return Math.ceil(t/e)*e}var Fa=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.int16[r+0]=e,this.int16[r+1]=i,t}};Fa.prototype.bytesPerElement=4,Vo("StructArrayLayout2i4",Fa);var Sa=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let n=3*t;return this.int16[n+0]=e,this.int16[n+1]=i,this.int16[n+2]=r,t}};Sa.prototype.bytesPerElement=6,Vo("StructArrayLayout3i6",Sa);var Ca=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r){let n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){let s=4*t;return this.int16[s+0]=e,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,t}};Ca.prototype.bytesPerElement=8,Vo("StructArrayLayout4i8",Ca);var za=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){let a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}};za.prototype.bytesPerElement=12,Vo("StructArrayLayout2i4i12",za);var Ta=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.int8=new Int8Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a){let l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,s,o,a)}emplace(t,e,i,r,n,s,o,a,l){let h=5*t,u=10*t;return this.int16[h+0]=e,this.int16[h+1]=i,this.uint8[u+4]=r,this.uint8[u+5]=n,this.uint8[u+6]=s,this.uint8[u+7]=o,this.int8[u+8]=a,this.int8[u+9]=l,t}};Ta.prototype.bytesPerElement=10,Vo("StructArrayLayout2i4ub2b10",Ta);var Pa=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.float32[r+0]=e,this.float32[r+1]=i,t}};Pa.prototype.bytesPerElement=8,Vo("StructArrayLayout2f8",Pa);var Ia=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,h){let u=this.length;return this.resize(u+1),this.emplace(u,t,e,i,r,n,s,o,a,l,h)}emplace(t,e,i,r,n,s,o,a,l,h,u){let c=10*t;return this.uint16[c+0]=e,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=s,this.uint16[c+5]=o,this.uint16[c+6]=a,this.uint16[c+7]=l,this.uint16[c+8]=h,this.uint16[c+9]=u,t}};Ia.prototype.bytesPerElement=20,Vo("StructArrayLayout10ui20",Ia);var ka=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a){let l=this.length;return this.resize(l+1),this.emplace(l,t,e,i,r,n,s,o,a)}emplace(t,e,i,r,n,s,o,a,l){let h=8*t;return this.uint16[h+0]=e,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=n,this.uint16[h+4]=s,this.uint16[h+5]=o,this.uint16[h+6]=a,this.uint16[h+7]=l,t}};ka.prototype.bytesPerElement=16,Vo("StructArrayLayout8ui16",ka);var $a=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s,o,a,l,h,u,c,f){let p=this.length;return this.resize(p+1),this.emplace(p,t,e,i,r,n,s,o,a,l,h,u,c,f)}emplace(t,e,i,r,n,s,o,a,l,h,u,c,f,p){let d=14*t,m=7*t;return this.int16[d+0]=e,this.int16[d+1]=i,this.int16[d+2]=r,this.int16[d+3]=n,this.uint16[d+4]=s,this.uint16[d+5]=o,this.uint16[d+6]=a,this.uint16[d+7]=l,this.int16[d+8]=h,this.int16[d+9]=u,this.int16[d+10]=c,this.int16[d+11]=f,this.float32[m+6]=p,t}};$a.prototype.bytesPerElement=28,Vo("StructArrayLayout4i4ui4i1f28",$a);var ja=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let n=3*t;return this.float32[n+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}};ja.prototype.bytesPerElement=12,Vo("StructArrayLayout3f12",ja);var Ra=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint32[1*t+0]=e,t}};Ra.prototype.bytesPerElement=4,Vo("StructArrayLayout1ul4",Ra);var Oa=class extends Ma{_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,r,n,s,o,a,l){let h=this.length;return this.resize(h+1),this.emplace(h,t,e,i,r,n,s,o,a,l)}emplace(t,e,i,r,n,s,o,a,l,h){let u=10*t,c=5*t;return this.int16[u+0]=e,this.int16[u+1]=i,this.int16[u+2]=r,this.int16[u+3]=n,this.int16[u+4]=s,this.int16[u+5]=o,this.uint32[c+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=h,t}};Oa.prototype.bytesPerElement=20,Vo("StructArrayLayout6i1ul2ui20",Oa);var Ba=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){let a=6*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=s,this.int16[a+5]=o,t}};Ba.prototype.bytesPerElement=12,Vo("StructArrayLayout2i2i2i12",Ba);var La=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n){let s=this.length;return this.resize(s+1),this.emplace(s,t,e,i,r,n)}emplace(t,e,i,r,n,s){let o=4*t,a=8*t;return this.float32[o+0]=e,this.float32[o+1]=i,this.float32[o+2]=r,this.int16[a+6]=n,this.int16[a+7]=s,t}};La.prototype.bytesPerElement=16,Vo("StructArrayLayout2f1f2i16",La);var Ua=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,e,i,r,n,s){let o=this.length;return this.resize(o+1),this.emplace(o,t,e,i,r,n,s)}emplace(t,e,i,r,n,s,o){let a=16*t,l=4*t,h=8*t;return this.uint8[a+0]=e,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[h+6]=s,this.int16[h+7]=o,t}};Ua.prototype.bytesPerElement=16,Vo("StructArrayLayout2ub2f2i16",Ua);var Na=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let n=3*t;return this.uint16[n+0]=e,this.uint16[n+1]=i,this.uint16[n+2]=r,t}};Na.prototype.bytesPerElement=6,Vo("StructArrayLayout3ui6",Na);var Ga=class extends Ma{_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,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g){let y=this.length;return this.resize(y+1),this.emplace(y,t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g)}emplace(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y){let v=26*t,w=13*t,b=52*t;return this.int16[v+0]=e,this.int16[v+1]=i,this.uint16[v+2]=r,this.uint16[v+3]=n,this.uint32[w+2]=s,this.uint32[w+3]=o,this.uint32[w+4]=a,this.uint16[v+10]=l,this.uint16[v+11]=h,this.uint16[v+12]=u,this.float32[w+7]=c,this.float32[w+8]=f,this.uint8[b+36]=p,this.uint8[b+37]=d,this.uint8[b+38]=m,this.uint32[w+10]=_,this.int16[v+22]=g,this.float32[w+12]=y,t}};Ga.prototype.bytesPerElement=52,Vo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",Ga);var qa=class extends Ma{_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,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,D,M,E,A,F,S){let C=this.length;return this.resize(C+1),this.emplace(C,t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,D,M,E,A,F,S)}emplace(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,D,M,E,A,F,S,C){let z=34*t,T=17*t;return this.int16[z+0]=e,this.int16[z+1]=i,this.int16[z+2]=r,this.int16[z+3]=n,this.int16[z+4]=s,this.int16[z+5]=o,this.int16[z+6]=a,this.int16[z+7]=l,this.uint16[z+8]=h,this.uint16[z+9]=u,this.uint16[z+10]=c,this.uint16[z+11]=f,this.uint16[z+12]=p,this.uint16[z+13]=d,this.uint16[z+14]=m,this.uint16[z+15]=_,this.uint16[z+16]=g,this.uint16[z+17]=y,this.uint16[z+18]=v,this.uint16[z+19]=w,this.uint16[z+20]=b,this.uint16[z+21]=x,this.uint16[z+22]=D,this.uint32[T+12]=M,this.float32[T+13]=E,this.float32[T+14]=A,this.uint16[z+30]=F,this.uint16[z+31]=S,this.float32[T+16]=C,t}};qa.prototype.bytesPerElement=68,Vo("StructArrayLayout8i15ui1ul2f2ui1f68",qa);var Va=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.float32[1*t+0]=e,t}};Va.prototype.bytesPerElement=4,Vo("StructArrayLayout1f4",Va);var Za=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let n=3*t;return this.uint16[6*t+0]=e,this.float32[n+1]=i,this.float32[n+2]=r,t}};Za.prototype.bytesPerElement=12,Vo("StructArrayLayout1ui2f12",Za);var Wa=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e,i){let r=this.length;return this.resize(r+1),this.emplace(r,t,e,i)}emplace(t,e,i,r){let n=4*t;return this.uint32[2*t+0]=e,this.uint16[n+2]=i,this.uint16[n+3]=r,t}};Wa.prototype.bytesPerElement=8,Vo("StructArrayLayout1ul2ui8",Wa);var Ha=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,e){let i=this.length;return this.resize(i+1),this.emplace(i,t,e)}emplace(t,e,i){let r=2*t;return this.uint16[r+0]=e,this.uint16[r+1]=i,t}};Ha.prototype.bytesPerElement=4,Vo("StructArrayLayout2ui4",Ha);var Ya=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){let e=this.length;return this.resize(e+1),this.emplace(e,t)}emplace(t,e){return this.uint16[1*t+0]=e,t}};Ya.prototype.bytesPerElement=2,Vo("StructArrayLayout1ui2",Ya);var Xa=class extends Ma{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,e,i,r){let n=this.length;return this.resize(n+1),this.emplace(n,t,e,i,r)}emplace(t,e,i,r,n){let s=4*t;return this.float32[s+0]=e,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,t}};Xa.prototype.bytesPerElement=16,Vo("StructArrayLayout4f16",Xa);var Ja=class extends Da{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 f(this.anchorPointX,this.anchorPointY)}};Ja.prototype.size=20;var Ka=class extends Oa{get(t){return new Ja(this,t)}};Vo("CollisionBoxArray",Ka);var Qa=class extends Da{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]}get heightOffset(){return this._structArray.float32[this._pos4+12]}};Qa.prototype.size=52;var tl=class extends Ga{get(t){return new Qa(this,t)}};Vo("PlacedSymbolArray",tl);var el=class extends Da{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]}get heightOffset(){return this._structArray.float32[this._pos4+16]}};el.prototype.size=68;var il=class extends qa{get(t){return new el(this,t)}};Vo("SymbolInstanceArray",il);var rl=class extends Va{getoffsetX(t){return this.float32[1*t+0]}};Vo("GlyphOffsetArray",rl);var nl=class extends Sa{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}};Vo("SymbolLineVertexArray",nl);var sl=class extends Da{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]}};sl.prototype.size=12;var ol=class extends Za{get(t){return new sl(this,t)}};Vo("TextAnchorOffsetArray",ol);var al=class extends Da{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]}};al.prototype.size=8;var ll=class extends Wa{get(t){return new al(this,t)}};Vo("FeatureIndexArray",ll);var hl=class extends Fa{},ul=class extends Sa{},cl=class extends Ca{},fl=class extends Fa{},pl=class extends Fa{},dl=class extends za{},ml=class extends Ta{},_l=class extends Pa{},gl=class extends Ia{},yl=class extends ka{},vl=class extends $a{},wl=class extends ja{},bl=class extends Ra{},xl=class extends Ba{},Dl=class extends La{},Ml=class extends Ua{},El=class extends Na{},Al=class extends Na{},Fl=class extends Ha{},Sl=class extends Ya{};const Cl=Ea([{name:"a_pos",components:2,type:"Int16"}],4).members;var zl=class t{constructor(t=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=t}prepareSegment(e,i,r,n){let s=this.segments[this.segments.length-1];return e>t.MAX_VERTEX_ARRAY_LENGTH&&Lt(`Max vertices per segment is ${t.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${t.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!s||s.vertexLength+e>t.MAX_VERTEX_ARRAY_LENGTH||s.sortKey!==n?this.createNewSegment(i,r,n):s}createNewSegment(t,e,i){let r={vertexOffset:t.length,primitiveOffset:e.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(t,e,i){return this.prepareSegment(0,t,e,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(let t of this.segments)for(let e in t.vaos)t.vaos[e].destroy()}static simpleSegment(e,i,r,n){return new t([{vertexOffset:e,primitiveOffset:i,vertexLength:r,primitiveLength:n,vaos:{},sortKey:0}])}};function Tl(t,e){return 256*(t=At(Math.floor(t),0,255))+At(Math.floor(e),0,255)}zl.MAX_VERTEX_ARRAY_LENGTH=65535,Vo("SegmentVector",zl);const Pl=Ea([{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"}]),Il=Ea([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var kl=l(((t,e)=>{void 0!==e&&(e.exports=function(t,e){for(var i,r,n=3&t.length,s=t.length-n,o=e,a=3432918353,l=461845907,h=0;h<s;)r=255&t.charCodeAt(h)|(255&t.charCodeAt(++h))<<8|(255&t.charCodeAt(++h))<<16|(255&t.charCodeAt(++h))<<24,++h,o=27492+(65535&(i=5*(65535&(o=(o^=r=(65535&(r=(r=(65535&r)*a+(((r>>>16)*a&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295)<<13|o>>>19))+((5*(o>>>16)&65535)<<16)&4294967295))+((58964+(i>>>16)&65535)<<16);switch(r=0,n){case 3:r^=(255&t.charCodeAt(h+2))<<16;case 2:r^=(255&t.charCodeAt(h+1))<<8;case 1:o^=r=(65535&(r=(r=(65535&(r^=255&t.charCodeAt(h)))*a+(((r>>>16)*a&65535)<<16)&4294967295)<<15|r>>>17))*l+(((r>>>16)*l&65535)<<16)&4294967295}return o^=t.length,o=2246822507*(65535&(o^=o>>>16))+((2246822507*(o>>>16)&65535)<<16)&4294967295,o=3266489909*(65535&(o^=o>>>13))+((3266489909*(o>>>16)&65535)<<16)&4294967295,(o^=o>>>16)>>>0})})),$l=l(((t,e)=>{e.exports=function(t,e){for(var i,r=t.length,n=e^r,s=0;r>=4;)i=1540483477*(65535&(i=255&t.charCodeAt(s)|(255&t.charCodeAt(++s))<<8|(255&t.charCodeAt(++s))<<16|(255&t.charCodeAt(++s))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++s;switch(r){case 3:n^=(255&t.charCodeAt(s+2))<<16;case 2:n^=(255&t.charCodeAt(s+1))<<8;case 1:n=1540483477*(65535&(n^=255&t.charCodeAt(s)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}})),jl=u(l(((t,e)=>{var i=kl(),r=$l();e.exports=i,e.exports.murmur3=i,e.exports.murmur2=r}))()),Rl=class t{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Ol(t)),this.positions.push(e,i,r)}getPositions(t){if(!this.indexed)throw Error("Trying to get index, but feature positions are not indexed");let e=Ol(t),i=0,r=this.ids.length-1;for(;i<r;){let t=i+r>>1;this.ids[t]>=e?r=t:i=t+1}let n=[];for(;this.ids[i]===e;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(t,e){let i=new Float64Array(t.ids),r=new Uint32Array(t.positions);return Bl(i,r,0,i.length-1),e&&e.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){let i=new t;return i.ids=e.ids,i.positions=e.positions,i.indexed=!0,i}};function Ol(t){let e=+t;return!isNaN(e)&&e<=2**53-1?e:(0,jl.default)(String(t))}function Bl(t,e,i,r){for(;i<r;){let n=t[i+r>>1],s=i-1,o=r+1;for(;;){do{s++}while(t[s]<n);do{o--}while(t[o]>n);if(s>=o)break;Ll(t,s,o),Ll(e,3*s,3*o),Ll(e,3*s+1,3*o+1),Ll(e,3*s+2,3*o+2)}o-i<r-o?(Bl(t,e,i,o),i=o+1):(Bl(t,e,o+1,r),r=o)}}function Ll(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}Vo("FeaturePositionMap",Rl);var Ul=class{constructor(t,e){this.gl=t.gl,this.location=e}},Nl=class extends Ul{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},Gl=class extends Ul{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},ql=class extends Ul{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]))}},Vl=class extends Ul{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]))}},Zl=class extends Ul{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]))}},Wl=class extends Ul{constructor(t,e){super(t,e),this.current=nr.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))}},Hl=class extends Ul{constructor(t,e){super(t,e),this.current=[]}set(t){if(t!=this.current){this.current=t;let 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)}}},Yl=class extends Ul{constructor(t,e){super(t,e),this.current=[]}set(t){if(t!=this.current){this.current=t;let e=new Float32Array(t);this.gl.uniform1fv(this.location,e)}}};const Xl=new Float32Array(16);var Jl=class extends Ul{constructor(t,e){super(t,e),this.current=Xl}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}}};function Kl(t){return[Tl(255*t.r,255*t.g),Tl(255*t.b,255*t.a)]}var Ql=class{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 Wl(t,e):new Gl(t,e)}},th=class{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,r){let n=null;"u_pattern_to"===r?n=this.patternTo:"u_pattern_from"===r?n=this.patternFrom:"u_dasharray_to"===r?n=this.dashTo:"u_dasharray_from"===r?n=this.dashFrom:"u_pixel_ratio_to"===r?n=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(n=this.pixelRatioFrom),null!==n&&t.set(n)}getBinding(t,e,i){return i.startsWith("u_pattern")||i.startsWith("u_dasharray_")?new Zl(t,e):new Gl(t,e)}},eh=class{constructor(t,e,i,r){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 r}populatePaintArray(t,e,i){let r=this.paintVertexArray.length,n=this.expression.evaluate(new Ko(0,i),e,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(t),this._setPaintValue(r,t,n)}updatePaintArray(t,e,i,r,n){let s=this.expression.evaluate(new Ko(0,n),i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){let r=Kl(i);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,r[0],r[1])}else{for(let r=t;r<e;r++)this.paintVertexArray.emplace(r,i);this.maxValue=Math.max(this.maxValue,Math.abs(i))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}},ih=class{constructor(t,e,i,r,n,s){this.expression=t,this.uniformNames=e.map((t=>`u_${t}_t`)),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=e.map((t=>({name:`a_${t}`,type:"Float32",components:"color"===i?4:2,offset:0}))),this.paintVertexArray=new s}populatePaintArray(t,e,i){let r=this.expression.evaluate(new Ko(this.zoom,i),e,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new Ko(this.zoom+1,i),e,{},i.canonical,[],i.formattedSection),s=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(s,t,r,n)}updatePaintArray(t,e,i,r,n){let s=this.expression.evaluate(new Ko(this.zoom,n),i,r),o=this.expression.evaluate(new Ko(this.zoom+1,n),i,r);this._setPaintValue(t,e,s,o)}_setPaintValue(t,e,i,r){if("color"===this.type){let n=Kl(i),s=Kl(r);for(let i=t;i<e;i++)this.paintVertexArray.emplace(i,n[0],n[1],s[0],s[1])}else{for(let n=t;n<e;n++)this.paintVertexArray.emplace(n,i,r);this.maxValue=Math.max(this.maxValue,Math.abs(i),Math.abs(r))}}upload(t){this.paintVertexArray?.arrayBuffer.byteLength&&(this.paintVertexBuffer?.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){let i=this.useIntegerZoom?Math.floor(e.zoom):e.zoom,r=At(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Gl(t,e)}},rh=class{constructor(t,e,i,r,n,s){this.expression=t,this.type=e,this.useIntegerZoom=i,this.zoom=r,this.layerId=s,this.zoomInPaintVertexArray=new n,this.zoomOutPaintVertexArray=new n}populatePaintArray(t,e,i){let r=this.zoomInPaintVertexArray.length;this.zoomInPaintVertexArray.resize(t),this.zoomOutPaintVertexArray.resize(t),this._setPaintValues(r,t,this.getPositionIds(e),i)}updatePaintArray(t,e,i,r,n){this._setPaintValues(t,e,this.getPositionIds(i),n)}_setPaintValues(t,e,i,r){let n=this.getPositions(r);if(!n||!i)return;let s=n[i.min],o=n[i.mid],a=n[i.max];if(s&&o&&a)for(let i=t;i<e;i++)this.emplace(this.zoomInPaintVertexArray,i,s,o),this.emplace(this.zoomOutPaintVertexArray,i,a,o)}upload(t){if(this.zoomInPaintVertexArray?.arrayBuffer.byteLength&&this.zoomOutPaintVertexArray?.arrayBuffer.byteLength){let 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()}},nh=class extends rh{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns?.[this.layerId]}getVertexAttributes(){return Pl.members}emplace(t,e,i,r){t.emplace(e,i.tlbr[0],i.tlbr[1],i.tlbr[2],i.tlbr[3],r.tlbr[0],r.tlbr[1],r.tlbr[2],r.tlbr[3],i.pixelRatio,r.pixelRatio)}},sh=class extends rh{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes?.[this.layerId]}getVertexAttributes(){return Il.members}emplace(t,e,i,r){t.emplace(e,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},oh=class{constructor(t,e,i){this.binders={},this._buffers=[];let r=[];for(let n in t.paint._values){if(!i(n))continue;let s=t.paint.get(n);if(!(s instanceof sa&&as(s.property.specification)))continue;let o=lh(n,t.type),a=s.value,l=s.property.specification.type,h=s.property.useIntegerZoom,u=s.property.specification["property-type"],c="cross-faded"===u||"cross-faded-data-driven"===u;if("constant"===a.kind)this.binders[n]=c?new th(a.value,o):new Ql(a.value,o,l),r.push(`/u_${n}`);else if("source"===a.kind||c){let i=hh(n,l,"source");this.binders[n]=c?"line-dasharray"===n?new sh(a,l,h,e,i,t.id):new nh(a,l,h,e,i,t.id):new eh(a,o,l,i),r.push(`/a_${n}`)}else{let t=hh(n,l,"composite");this.binders[n]=new ih(a,o,l,h,e,t),r.push(`/z_${n}`)}}this.cacheKey=r.sort().join("")}getMaxValue(t){let e=this.binders[t];return e instanceof eh||e instanceof ih?e.maxValue:0}populatePaintArrays(t,e,i){for(let r in this.binders){let n=this.binders[r];(n instanceof eh||n instanceof ih||n instanceof rh)&&n.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof th&&r.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof th&&r.setConstantDashPositions(t,e)}}updatePaintArrays(t,e,i,r,n){let s=!1;for(let o of t){let t=e.getPositions(o.id);for(let e of t){let t=i.feature(e.index);for(let i in this.binders){let a=this.binders[i];(a instanceof eh||a instanceof ih||a instanceof rh)&&!0===a.expression.isStateDependent&&(a.expression=r.paint.get(i).value,a.updatePaintArray(e.start,e.end,t,o.state,n),s=!0)}}}return s}defines(){let t=[];for(let e in this.binders){let i=this.binders[e];(i instanceof Ql||i instanceof th)&&t.push(...i.uniformNames.map((t=>`#define HAS_UNIFORM_${t}`)))}return t}getBinderAttributes(){let t=[];for(let e in this.binders){let i=this.binders[e];if(i instanceof eh||i instanceof ih)for(let e of i.paintVertexAttributes)t.push(e.name);else if(i instanceof rh){let e=i.getVertexAttributes();for(let i of e)t.push(i.name)}}return t}getBinderUniforms(){let t=[];for(let e in this.binders){let i=this.binders[e];if(i instanceof Ql||i instanceof th||i instanceof ih)for(let e of i.uniformNames)t.push(e)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t,e){let i=[];for(let r in this.binders){let n=this.binders[r];if(n instanceof Ql||n instanceof th||n instanceof ih)for(let s of n.uniformNames)if(e[s]){let o=n.getBinding(t,e[s],s);i.push({name:s,property:r,binding:o})}}return i}setUniforms(t,e,i,r){for(let{name:t,property:n,binding:s}of e)this.binders[n].setUniform(s,r,i.get(n),t)}updatePaintBuffers(t){this._buffers=[];for(let e in this.binders){let i=this.binders[e];if(t&&i instanceof rh){let e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof eh||i instanceof ih)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let e in this.binders){let i=this.binders[e];(i instanceof eh||i instanceof ih||i instanceof rh)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let e=this.binders[t];(e instanceof eh||e instanceof ih||e instanceof rh)&&e.destroy()}}},ah=class{constructor(t,e,i=()=>!0){this.programConfigurations={};for(let r of t)this.programConfigurations[r.id]=new oh(r,e,i);this.needsUpload=!1,this._featureMap=new Rl,this._bufferOffset=0}populatePaintArrays(t,e,i,r){for(let i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(t,e,r);void 0!==e.id&&this._featureMap.add(e.id,i,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,e,i,r){for(let n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(t,this._featureMap,e,n,r)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(let e in this.programConfigurations)this.programConfigurations[e].upload(t);this.needsUpload=!1}}destroy(){for(let t in this.programConfigurations)this.programConfigurations[t].destroy()}};function lh(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 hh(t,e,i){let r={color:{source:Pa,composite:Xa},number:{source:Va,composite:Pa}};return function(t){return{"line-pattern":{source:gl,composite:gl},"fill-pattern":{source:gl,composite:gl},"fill-extrusion-pattern":{source:gl,composite:gl},"line-dasharray":{source:yl,composite:yl}}[t]}(t)?.[i]||r[e][i]}Vo("ConstantBinder",Ql),Vo("CrossFadedConstantBinder",th),Vo("SourceExpressionBinder",eh),Vo("CrossFadedPatternBinder",nh),Vo("CrossFadedDasharrayBinder",sh),Vo("CompositeExpressionBinder",ih),Vo("ProgramConfiguration",oh,{omit:["_buffers"]}),Vo("ProgramConfigurationSet",ah);const uh=16383,ch=-uh-1;function fh(t){let e=st/t.extent,i=t.loadGeometry();for(let t of i)for(let i of t){let t=Math.round(i.x*e),r=Math.round(i.y*e);i.x=At(t,ch,uh),i.y=At(r,ch,uh),(t<i.x||t>i.x+1||r<i.y||r>i.y+1)&&Lt("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function ph(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?fh(t):[]}}const dh=-32768;function mh(t,e,i,r,n){t.emplaceBack(dh+8*e+r,dh+8*i+n)}var _h=class{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 fl,this.indexArray=new Al,this.segments=new zl,this.programConfigurations=new ah(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){let r=this.layers[0],n=[],s=null,o=!1,a="heatmap"===r.type;if("circle"===r.type){let t=r;s=t.layout.get("circle-sort-key"),o=!s.isConstant(),a||="map"===t.paint.get("circle-pitch-alignment")}let l=a?e.subdivisionGranularity.circle:1,h=new Ko(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:r,index:a,sourceLayerIndex:l}of t){let t=ph(e,u);if(!this.layers[0]._featureFilter.filter(h,t,i))continue;let c=o?s.evaluate(t,{},i):void 0,f={id:r,properties:e.properties,type:e.type,sourceLayerIndex:l,index:a,geometry:u?t.geometry:fh(e),patterns:{},sortKey:c};n.push(f)}o&&n.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of n){let{geometry:n,index:s,sourceLayerIndex:o}=r,a=t[s].feature;this.addFeature(r,n,s,i,l),e.featureIndex.insert(a,n,s,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}addFeatures(t){}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,Cl),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,r,n=1){let s;switch(n){case 1:s=[0,7];break;case 3:s=[0,2,5,7];break;case 5:s=[0,1,3,4,6,7];break;case 7:s=[0,1,2,3,4,5,6,7];break;default:throw Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}let o=s.length;for(let i of e)for(let e of i){let i=e.x,r=e.y;if(i<0||i>=8192||r<0||r>=8192)continue;let n=this.segments.prepareSegment(o*o,this.layoutVertexArray,this.indexArray,t.sortKey),a=n.vertexLength;for(let t=0;t<o;t++)for(let e=0;e<o;e++)mh(this.layoutVertexArray,i,r,s[e],s[t]);for(let t=0;t<o-1;t++)for(let e=0;e<o-1;e++){let i=a+t*o+e,r=a+(t+1)*o+e;this.indexArray.emplaceBack(i,r+1,i+1),this.indexArray.emplaceBack(i,r,r+1)}n.vertexLength+=o*o,n.primitiveLength+=(o-1)*(o-1)*2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:{},canonical:r})}};function gh(t,e){for(let i of t)if(Ah(e,i))return!0;for(let i of e)if(Ah(t,i))return!0;return bh(t,e)}function yh(t,e,i){return!!Ah(t,e)||Dh(e,t,i)}function vh(t,e){if(1===t.length)return Eh(e,t[0]);for(let i of e)for(let e of i)if(Ah(t,e))return!0;for(let i of t)if(Eh(e,i))return!0;for(let i of e)if(bh(t,i))return!0;return!1}function wh(t,e,i){if(t.length>1){if(bh(t,e))return!0;for(let r of e)if(Dh(r,t,i))return!0}for(let r of t)if(Dh(r,e,i))return!0;return!1}function bh(t,e){if(0===t.length||0===e.length)return!1;for(let i=0;i<t.length-1;i++){let r=t[i],n=t[i+1];for(let t=0;t<e.length-1;t++)if(xh(r,n,e[t],e[t+1]))return!0}return!1}function xh(t,e,i,r){return Ut(t,i,r)!==Ut(e,i,r)&&Ut(t,e,i)!==Ut(t,e,r)}function Dh(t,e,i){let r=i*i;if(1===e.length)return t.distSqr(e[0])<r;for(let i=1;i<e.length;i++)if(Mh(t,e[i-1],e[i])<r)return!0;return!1}function Mh(t,e,i){let r=e.distSqr(i);if(0===r)return t.distSqr(e);let n=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/r;return t.distSqr(n<0?e:n>1?i:i.sub(e)._mult(n)._add(e))}function Eh(t,e){let i,r,n,s=!1;for(let o of t){i=o;for(let t=0,o=i.length-1;t<i.length;o=t++)r=i[t],n=i[o],r.y>e.y!=n.y>e.y&&e.x<(n.x-r.x)*(e.y-r.y)/(n.y-r.y)+r.x&&(s=!s)}return s}function Ah(t,e){let i=!1;for(let r=0,n=t.length-1;r<t.length;n=r++){let s=t[r],o=t[n];s.y>e.y!=o.y>e.y&&e.x<(o.x-s.x)*(e.y-s.y)/(o.y-s.y)+s.x&&(i=!i)}return i}function Fh(t,e,i,r,n){for(let s of t)if(e<=s.x&&i<=s.y&&r>=s.x&&n>=s.y)return!0;let s=[new f(e,i),new f(e,n),new f(r,n),new f(r,i)];if(t.length>2)for(let e of s)if(Ah(t,e))return!0;for(let e=0;e<t.length-1;e++)if(Sh(t[e],t[e+1],s))return!0;return!1}function Sh(t,e,i){let r=i[0],n=i[2];if(t.x<r.x&&e.x<r.x||t.x>n.x&&e.x>n.x||t.y<r.y&&e.y<r.y||t.y>n.y&&e.y>n.y)return!1;let s=Ut(t,e,i[0]);return s!==Ut(t,e,i[1])||s!==Ut(t,e,i[2])||s!==Ut(t,e,i[3])}function Ch(t,e,i){let r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function zh(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Th(t,e,i,r,n){if(!e[0]&&!e[1])return t;let s=f.convert(e)._mult(n);"viewport"===i&&s._rotate(-r);let o=[];for(let e of t)o.push(e.sub(s));return o}function Ph(t){let e=[];for(let i=0;i<t.length;i++){let r=t[i],n=e.at(-1);(0===i||n&&!r.equals(n))&&e.push(r)}return e}function Ih({queryGeometry:t,size:e},i){return yh(t,i,e)}function kh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return yh(t,s,e*(i.projectTileCoordinates(s.x,s.y,r,n?.(s.x,s.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function $h({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){let o=i.projectTileCoordinates(s.x,s.y,r,n?.(s.x,s.y)).signedDistanceFromCamera,a=e*(i.cameraToCenterDistance/o);return yh(t,Oh(s,i,r,n),a)}function jh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return yh(t,Oh(s,i,r,n),e)}function Rh({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n,pitchAlignment:s="map",pitchScale:o="map"},a){let l="map"===s?"map"===o?Ih:kh:"map"===o?$h:jh,h={queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n};for(let t of a)for(let e of t)if(l(h,e))return!0;return!1}function Oh(t,e,i,r){let n=e.projectTileCoordinates(t.x,t.y,i,r?.(t.x,t.y)).point;return new f((.5*n.x+.5)*e.width,(.5*-n.y+.5)*e.height)}let Bh,Lh;Vo("CircleBucket",_h,{omit:["layers"]});var Uh={get paint(){return Lh||=new da({"circle-radius":new ua(Ke.paint_circle["circle-radius"],"circle-radius"),"circle-color":new ua(Ke.paint_circle["circle-color"],"circle-color"),"circle-blur":new ua(Ke.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new ua(Ke.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new ha(Ke.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new ha(Ke.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new ha(Ke.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new ha(Ke.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new ua(Ke.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new ua(Ke.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new ua(Ke.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return Bh||=new da({"circle-sort-key":new ua(Ke.layout_circle["circle-sort-key"],"circle-sort-key")})}},Nh=class extends ga{constructor(t,e){super(t,Uh,e)}createBucket(t){return new _h(t)}queryRadius(t){let e=t;return Ch("circle-radius",this,e)+Ch("circle-stroke-width",this,e)+zh(this.paint.get("circle-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){let l,h,u=Th(t,this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),-n.bearingInRadians,s),c=this.paint.get("circle-radius").evaluate(e,i)+this.paint.get("circle-stroke-width").evaluate(e,i),f=this.paint.get("circle-pitch-scale"),p=this.paint.get("circle-pitch-alignment");return"map"===p?(l=u,h=c*s):(l=function(t,e,i,r){return t.map((t=>Oh(t,e,i,r)))}(u,n,o,a),h=c),Rh({queryGeometry:l,size:h,transform:n,unwrappedTileID:o,getElevation:a,pitchAlignment:p,pitchScale:f},r)}},Gh=class extends _h{};let qh;Vo("HeatmapBucket",Gh,{omit:["layers"]});var Vh={get paint(){return qh||=new da({"heatmap-radius":new ua(Ke.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new ua(Ke.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new ha(Ke.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new pa(Ke.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new ha(Ke.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function Zh(t,{width:e,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==e*i*r)throw RangeError(`mismatched image size. expected: ${n.length} but got: ${e*i*r}`)}else n=new Uint8Array(e*i*r);return t.width=e,t.height=i,t.data=n,t}function Wh(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;let n=Zh({},{width:e,height:i},r);Hh(t,n,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,i)},r),t.width=e,t.height=i,t.data=n.data}function Hh(t,e,i,r,n,s){if(0===n.width||0===n.height)return e;if(n.width>t.width||n.height>t.height||i.x>t.width-n.width||i.y>t.height-n.height)throw RangeError("out of range source coordinates for image copy");if(n.width>e.width||n.height>e.height||r.x>e.width-n.width||r.y>e.height-n.height)throw RangeError("out of range destination coordinates for image copy");let o=t.data,a=e.data;if(o===a)throw Error("srcData equals dstData, so image is already copied");for(let l=0;l<n.height;l++){let h=((i.y+l)*t.width+i.x)*s,u=((r.y+l)*e.width+r.x)*s;for(let t=0;t<n.width*s;t++)a[u+t]=o[h+t]}return e}var Yh=class t{constructor(t,e){Zh(this,t,1,e)}resize(t){Wh(this,t,1)}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Hh(t,e,i,r,n,1)}},Xh=class t{constructor(t,e){Zh(this,t,4,e)}resize(t){Wh(this,t,4)}replace(t,e){e?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){Hh(t,e,i,r,n,4)}setPixel(t,e,i){let r=4*(t*this.width+e);this.data[r+0]=Math.round(255*i.r/i.a),this.data[r+1]=Math.round(255*i.g/i.a),this.data[r+2]=Math.round(255*i.b/i.a),this.data[r+3]=Math.round(255*i.a)}};function Jh(t){let e=new Uint8Array(t.length);for(let i=0;i<t.length;i+=4){let r=t[i+3];e[i+0]=Math.round(t[i+0]*r/255),e[i+1]=Math.round(t[i+1]*r/255),e[i+2]=Math.round(t[i+2]*r/255),e[i+3]=r}return e}function Kh(t){let e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new Xh({width:i,height:r});if(!function(t){return Math.log(t)/Math.LN2%1==0}(i))throw Error(`width is not a power of 2 - ${i}`);let s=(r,s,o)=>{e[t.evaluationKey]=o;let a=t.expression.evaluate(e);n.setPixel(r/4/i,s/4,a)};if(t.clips)for(let e=0,n=0;e<r;++e,n+=4*i)for(let r=0,o=0;r<i;r++,o+=4){let a=r/(i-1),{start:l,end:h}=t.clips[e];s(n,o,l*(1-a)+h*a)}else for(let t=0,e=0;t<i;t++,e+=4)s(0,e,t/(i-1));return n}Vo("AlphaImage",Yh),Vo("RGBAImage",Xh);const Qh="big-fb";var tu=class extends ga{createBucket(t){return new Gh(t)}constructor(t,e){super(t,Vh,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=Kh({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbos.has("big-fb")&&this.heatmapFbos.delete(Qh)}queryRadius(t){return Ch("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){return Rh({queryGeometry:t,size:this.paint.get("heatmap-radius").evaluate(e,i)*s,transform:n,unwrappedTileID:o,getElevation:a},r)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&!this.isHidden()}};let eu;var iu={get paint(){return eu||=new da({"hillshade-illumination-direction":new ha(Ke.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new ha(Ke.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new ha(Ke.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new ha(Ke.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new ha(Ke.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new ha(Ke.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new ha(Ke.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new ha(Ke.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new ha(Ke.paint_hillshade.resampling,"resampling")})}},ru=class extends ga{constructor(t,e){super(t,iu,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,r=this.paint.get("hillshade-shadow-color").values,n=Math.max(t.length,e.length,i.length,r.length);t=t.concat(Array(n-t.length).fill(t.at(-1))),e=e.concat(Array(n-e.length).fill(e.at(-1))),i=i.concat(Array(n-i.length).fill(i.at(-1))),r=r.concat(Array(n-r.length).fill(r.at(-1)));let s=e.map(Ht);return{directionRadians:t.map(Ht),altitudeRadians:s,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}};let nu;var su={get paint(){return nu||=new da({"color-relief-opacity":new ha(Ke["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new pa(Ke["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new ha(Ke["paint_color-relief"].resampling,"resampling")})}};function ou(t){return"data"in t}var au=class{constructor(t,e,i,r){this.context=t,this.format=i,this.texture=t.gl.createTexture(),this._ownedHandle=this.texture,this.update(e,r)}update(t,e,i){let{width:r,height:n}=t,s=(this.size?.[0]!==r||this.size[1]!==n)&&!i,{context:o}=this,{gl:a}=o;this.useMipmap=!!e?.useMipmap,s&&this.size&&this.format===a.RGBA&&(a.deleteTexture(this.texture),this.texture=a.createTexture(),this._ownedHandle=this.texture,this.magFilter=void 0,this.minFilter=void 0,this.wrap=void 0),a.bindTexture(a.TEXTURE_2D,this.texture),o.pixelStoreUnpackFlipY.set(!1),o.pixelStoreUnpack.set(1);let l=this.format===a.RGBA&&!1!==e?.premultiply;if(s)if(this.size=[r,n],this.format===a.RGBA&&r>0&&n>0){let e=this.useMipmap?Math.floor(Math.log2(Math.max(r,n)))+1:1;if(a.texStorage2D(a.TEXTURE_2D,e,a.RGBA8,r,n),ou(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:e}=t;l&&e&&(e=Jh(e)),e&&a.texSubImage2D(a.TEXTURE_2D,0,0,0,r,n,a.RGBA,a.UNSIGNED_BYTE,e)}else o.pixelStoreUnpackPremultiplyAlpha.set(l),a.texSubImage2D(a.TEXTURE_2D,0,0,0,a.RGBA,a.UNSIGNED_BYTE,t)}else ou(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._uploadRawData(t,l,r,n,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._uploadDomImage(t,a));else{let{x:e,y:s}=i||{x:0,y:0};ou(t)?(o.pixelStoreUnpackPremultiplyAlpha.set(!1),this._updateRawData(t,l,e,s,r,n,a)):(o.pixelStoreUnpackPremultiplyAlpha.set(l),this._updateDomImage(t,e,s,a))}this.useMipmap&&!(ou(t)&&null===t.data)&&a.generateMipmap(a.TEXTURE_2D),o.pixelStoreUnpackFlipY.setDefault(),o.pixelStoreUnpack.setDefault(),o.pixelStoreUnpackPremultiplyAlpha.setDefault()}_uploadDomImage(t,e){e.texImage2D(e.TEXTURE_2D,0,this.format,this.format,e.UNSIGNED_BYTE,t)}_uploadRawData(t,e,i,r,n){let{data:s}=t;e&&s&&(s=Jh(s)),n.texImage2D(n.TEXTURE_2D,0,this.format,i,r,0,this.format,n.UNSIGNED_BYTE,s)}_updateDomImage(t,e,i,r){r.texSubImage2D(r.TEXTURE_2D,0,e,i,r.RGBA,r.UNSIGNED_BYTE,t)}_updateRawData(t,e,i,r,n,s,o){let{data:a}=t;e&&a&&(a=Jh(a)),o.texSubImage2D(o.TEXTURE_2D,0,i,r,n,s,o.RGBA,o.UNSIGNED_BYTE,a)}bind(t,e,i){let{context:r}=this,{gl:n}=r;this.texture!==this._ownedHandle&&(this.texture=this._ownedHandle),n.bindTexture(n.TEXTURE_2D,this.texture),(i===n.LINEAR_MIPMAP_NEAREST||i===n.LINEAR_MIPMAP_LINEAR)&&!this.useMipmap&&(i=n.LINEAR);let s=i||t;t!==this.magFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,t),this.magFilter=t),s!==this.minFilter&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,s),this.minFilter=s),e!==this.wrap&&(n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,e),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,e),this.wrap=e)}generateMipmap(){if(!this.useMipmap)return;let{gl:t}=this.context;t.bindTexture(t.TEXTURE_2D,this.texture),t.generateMipmap(t.TEXTURE_2D)}destroy(){let{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null,this._ownedHandle=null}},lu=class t{static{this.byteViewCache=new WeakMap}constructor(e,i,r,n=1,s=1,o=1,a=0){if(this.uid=e,i.height!==i.width)throw RangeError("DEM tiles must be square");if(r&&!["mapbox","terrarium","custom"].includes(r))return void Lt(`"${r}" is not a valid encoding type. Valid types include "mapbox", "terrarium" and "custom".`);this.stride=i.height;let l=this.dim=i.height-4;switch(this.data=new Uint32Array(i.data.buffer),t.byteViewCache.set(this,new Uint8Array(this.data.buffer)),r){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=o,this.baseShift=a;break;default:this.redFactor=6553.6,this.greenFactor=25.6,this.blueFactor=.1,this.baseShift=1e4}for(let t=-2;t<l+2;t++){let e=this._idx(0,Math.max(0,Math.min(l-1,t)));(t<0||t>=l)&&this.data.copyWithin(this._idx(0,t),e,e+l),this.data.fill(this.data[e],this._idx(-2,t),this._idx(0,t)),this.data.fill(this.data[e+l-1],this._idx(l,t),this._idx(l+1,t)+1)}let h=this._getByteView();this.min=2**53-1,this.max=-9007199254740991;for(let t=0;t<l;t++)for(let e=0;e<l;e++){let i=4*this._idx(t,e),r=this._unpackAtIndex(h,i);r>this.max&&(this.max=r),r<this.min&&(this.min=r)}}get(t,e){let i=this._getByteView(),r=4*this._idx(t,e);return this._unpackAtIndex(i,r)}sampleBilinear(t,e){let i=Math.floor(t),r=Math.floor(e);if(i<-1||i>=this.dim||r<-1||r>=this.dim)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);let n=this._getByteView(),s=4*((r+2)*this.stride+i+2),o=4*this.stride,a=t-i,l=e-r;return this._unpackAtIndex(n,s)*(1-a)*(1-l)+this._unpackAtIndex(n,s+4)*a*(1-l)+this._unpackAtIndex(n,s+o)*(1-a)*l+this._unpackAtIndex(n,s+o+4)*a*l}getUnpackVector(){return[this.redFactor,this.greenFactor,this.blueFactor,this.baseShift]}_idx(t,e){if(t<-2||t>=this.dim+2||e<-2||e>=this.dim+2)throw RangeError(`Out of range source coordinates for DEM data. x: ${t}, y: ${e}, dim: ${this.dim}`);return(e+2)*this.stride+(t+2)}unpack(t,e,i){return t*this.redFactor+e*this.greenFactor+i*this.blueFactor-this.baseShift}pack(t){return hu(t,this.getUnpackVector())}getPixels(){return new Xh({width:this.stride,height:this.stride},this._getByteView())}backfillBorder(t,e,i){if(this.dim!==t.dim)throw Error("dem dimension mismatch");let r=e*this.dim,n=e*this.dim+this.dim,s=i*this.dim,o=i*this.dim+this.dim;switch(e){case-1:r=n-2;break;case 1:n=r+2}switch(i){case-1:s=o-2;break;case 1:o=s+2}let a=-e*this.dim,l=-i*this.dim;for(let e=s;e<o;e++)for(let i=r;i<n;i++)this.data[this._idx(i,e)]=t.data[this._idx(i+a,e+l)]}_getByteView(){let e=t.byteViewCache.get(this);return e?.buffer!==this.data.buffer&&(e=new Uint8Array(this.data.buffer),t.byteViewCache.set(this,e)),e}_unpackAtIndex(t,e){return this.unpack(t[e],t[e+1],t[e+2])}};function hu(t,e){let i=e[0],r=e[1],n=e[2],s=e[3],o=[i,r,n].filter((t=>0!==t));if(0===o.length)return{r:0,g:0,b:0};let a=Math.min(...o),l=Math.round((t+s)/a),h=t=>0===t?0:Math.floor(l*a/t)%256;return{r:h(i),g:h(r),b:h(n)}}Vo("DEMData",lu);var uu=class extends ga{constructor(t,e){super(t,su,e)}_createColorRamp(t){let e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof Ss&&i._styleExpression.expression instanceof Ar){this.colorRampExpression=i;let t=i._styleExpression.expression;e.elevationStops=t.labels,e.colorStops=[];for(let i of e.elevationStops)e.colorStops.push(t.evaluate({globals:{elevation:i}}))}if(e.elevationStops.length<1&&(e.elevationStops=[0],e.colorStops=[nr.transparent]),e.elevationStops.length<2&&(e.elevationStops.push(e.elevationStops[0]+1),e.colorStops.push(e.colorStops[0])),e.elevationStops.length<=t)return e;let r={elevationStops:[],colorStops:[]},n=(e.elevationStops.length-1)/(t-1);for(let t=0;t<e.elevationStops.length-.5;t+=n)r.elevationStops.push(e.elevationStops[Math.round(t)]),r.colorStops.push(e.colorStops[Math.round(t)]);return Lt(`Too many colors in specification of ${this.id} color-relief layer, may not render properly. Max possible colors: ${t}, provided: ${e.elevationStops.length}`),r}_colorRampChanged(){return this.colorRampExpression!=this._transitionablePaint._values["color-relief-color"].value.expression}getColorRampTextures(t,e,i){if(this.colorRampTextures&&!this._colorRampChanged())return this.colorRampTextures;let r=this._createColorRamp(e),n=new Xh({width:r.colorStops.length,height:1}),s=new Xh({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){let e=hu(r.elevationStops[t],i);s.setPixel(0,t,new nr(e.r/255,e.g/255,e.b/255,1)),n.setPixel(0,t,r.colorStops[t])}return this.colorRampTextures={elevationTexture:new au(t,s,t.gl.RGBA),colorTexture:new au(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const cu=Ea([{name:"a_pos",components:2,type:"Int16"}],4).members;function fu(t,e,i){let r=i.patternDependencies,n=!1;for(let i of e){let e=i.paint.get(`${t}-pattern`);e.isConstant()||(n=!0);let s=e.constantOr(null);s&&(n=!0,r[s.to]=!0,r[s.from]=!0)}return n}function pu(t,e,i,r,n){let{zoom:s}=r,o=n.patternDependencies;for(let r of e){let e=r.paint.get(`${t}-pattern`).value;if("constant"!==e.kind){let t=e.evaluate({zoom:s-1},i,{},n.availableImages),a=e.evaluate({zoom:s},i,{},n.availableImages),l=e.evaluate({zoom:s+1},i,{},n.availableImages);t=t?.name?t.name:t,a=a?.name?a.name:a,l=l?.name?l.name:l,o[t]=!0,o[a]=!0,o[l]=!0,i.patterns[r.id]={min:t,mid:a,max:l}}}return i}const du=new Set;let mu=!1;function _u(t,e,i,r,n){let s=null;if(n===function(t,e,i,r){let n=0;for(let s=e,o=i-r;s<i;s+=r)n+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return n}(t,e,i,r)>0)for(let n=e;n<i;n+=r)s=Xu(n/r|0,t[n],t[n+1],s);else for(let n=i-r;n>=e;n-=r)s=Xu(n/r|0,t[n],t[n+1],s);return s&&Vu(s,s.next)&&(Ju(s),s=s.next),s}function gu(t,e=t){let i,r=e===t,n=t;do{i=!1,n===n.next||0!==du.size&&du.has(n)||!Vu(n,n.next)&&0!==qu(n.prev,n,n.next)?(r||n!==e)&&(n=n.next,i=!r):((r||n===e)&&(e=n.prev),mu=!0,Ju(n),n=n.prev,i=!0)}while(i||n!==e);return e}function yu(t,e,i,r,n){n&&function(t,e,i,r){let n=t,s=0;do{n.z=Lu(n.x,n.y,e,i,r),ku[s++]=n,n=n.next}while(n!==t);!function(t){if(t<=32)for(let e=1;e<t;e++){let t=ku[e],i=t.z,r=e-1;for(;r>=0&&ku[r].z>i;)ku[r+1]=ku[r],r--;ku[r+1]=t}else{ju.length<t&&(ju=new Uint32Array(t),Ru=new Uint32Array(t),$u=Array(t));for(let e=0;e<t;e++)ju[e]=ku[e].z;Bu(t,ku,ju,$u,Ru,0),Bu(t,$u,Ru,ku,ju,8),Bu(t,ku,ju,$u,Ru,16),Bu(t,$u,Ru,ku,ju,24)}}(s);let o=null;for(let t=0;t<s;t++){let e=ku[t];e.prevZ=o,o&&(o.nextZ=e),o=e}o.nextZ=null,ku.fill(null,0,s),$u.fill(null,0,s)}(t,i,r,n);let s=t,o=!1;for(;t.prev!==t.next;){let a=t.prev,l=t.next;if(qu(a,t,l)<0&&(n?wu(t,i,r,n):vu(t)))e.push(a.i,t.i,l.i),Ju(t),t=l,s=l;else if((t=l)===s){if(mu=!1,t=gu(t),mu){s=t;continue}if(!o){s=t=bu(t,e),o=!0;continue}xu(t,e,i,r,n);break}}}function vu(t){let e=t.prev,i=t.next,r=e.x,n=t.x,s=i.x,o=e.y,a=t.y,l=i.y,h=Math.min(r,n,s),u=Math.min(o,a,l),c=Math.max(r,n,s),f=Math.max(o,a,l),p=i.next;for(;p!==e;){if(p.x>=h&&p.x<=c&&p.y>=u&&p.y<=f&&(r!==p.x||o!==p.y)&&Nu(r,o,n,a,s,l,p.x,p.y)&&qu(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function wu(t,e,i,r){let n=t.prev,s=t.next,o=n.x,a=t.x,l=s.x,h=n.y,u=t.y,c=s.y,f=Math.min(o,a,l),p=Math.min(h,u,c),d=Math.max(o,a,l),m=Math.max(h,u,c),_=Lu(f,p,e,i,r),g=Lu(d,m,e,i,r),y=t.prevZ;for(;y&&y.z>=_;){if(y.x>=f&&y.x<=d&&y.y>=p&&y.y<=m&&y!==s&&(o!==y.x||h!==y.y)&&Nu(o,h,a,u,l,c,y.x,y.y)&&qu(y.prev,y,y.next)>=0)return!1;y=y.prevZ}let v=t.nextZ;for(;v&&v.z<=g;){if(v.x>=f&&v.x<=d&&v.y>=p&&v.y<=m&&v!==s&&(o!==v.x||h!==v.y)&&Nu(o,h,a,u,l,c,v.x,v.y)&&qu(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function bu(t,e){let i=t,r=!1;do{let n=i.prev,s=i.next.next;Zu(n,i,i.next,s,!1)&&Hu(n,s)&&Hu(s,n)&&(e.push(n.i,i.i,s.i),Ju(i),Ju(i.next),i=t=s,r=!0),i=i.next}while(i!==t);return r?gu(i):i}function xu(t,e,i,r,n){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Gu(s,t)){let o=Yu(s,t);return s=gu(s,s.next),o=gu(o,o.next),yu(s,e,i,r,n),void yu(o,e,i,r,n)}t=t.next}s=s.next}while(s!==t)}let Du=!1;function Mu(t,e){return t.x-e.x||t.y-e.y||(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)}function Eu(t,e){let i=function(t,e){let i,r=e,n=t.x,s=t.y,o=-1/0;if(Vu(t,r))return r;for(let e=0,a=0;e<Fu;e++,a+=4){if(s<Au[a+1]||s>Au[a+3]||Au[a]>n||Au[a+2]<=o)continue;let l=Tu(e);r=Pu(e);do{if(r.prev.next===r){if(Vu(t,r.next))return r.next;if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){let t=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(t<=n&&t>o&&(o=t,i=r.x<r.next.x?r:r.next,t===n))return i}}r=r.next}while(r!==l)}if(!i)return null;let a=i.x,l=i.y,h=Math.min(s,l),u=Math.max(s,l),c=1/0;for(let e=0,f=0;e<Fu;e++,f+=4){if(Au[f+2]<a||Au[f]>n||Au[f+3]<h||Au[f+1]>u)continue;let p=Tu(e);r=Pu(e);do{if(r.prev.next===r&&n>=r.x&&r.x>=a&&n!==r.x&&Nu(s<l?n:o,s,a,l,s<l?o:n,s,r.x,r.y)){let e=Math.abs(s-r.y)/(n-r.x);(Hu(r,t)||r.y===s&&r.next.y===s&&r.next.x>n)&&(e<c||e===c&&(r.x>i.x||r.x===i.x&&Iu(i,r)))&&(i=r,c=e)}r=r.next}while(r!==p)}return i}(t,e);if(!i)return e;let r=Yu(i,t);return zu(i,r.next.next),gu(r,r.next),gu(i,i.next)}let Au=new Float64Array,Fu=0;const Su=[],Cu=[];function zu(t,e){let i=t;do{let t=Fu++;Su[t]=i;let r=i.x,n=i.y,s=i.x,o=i.y,a=0;do{let e=i.next;i.z=t,e.x<r&&(r=e.x),e.x>s&&(s=e.x),e.y<n&&(n=e.y),e.y>o&&(o=e.y),i=e}while(++a<16&&i!==e);Cu[t]=i;let l=4*t;Au[l]=r,Au[l+1]=n,Au[l+2]=s,Au[l+3]=o}while(i!==e)}function Tu(t){let e=Cu[t];for(;e.prev.next!==e;)e=e.next;return Cu[t]=e,e}function Pu(t){let e=Su[t];for(;e.prev.next!==e;)e=e.next;return Su[t]=e,e}function Iu(t,e){return qu(t.prev,t,e.prev)<0&&qu(e.next,t,t.next)<0}const ku=[];let $u=[],ju=new Uint32Array,Ru=new Uint32Array;const Ou=new Uint32Array(256);function Bu(t,e,i,r,n,s){Ou.fill(0);for(let e=0;e<t;e++)Ou[i[e]>>>s&255]++;let o=0;for(let t=0;t<256;t++){let e=Ou[t];Ou[t]=o,o+=e}for(let o=0;o<t;o++){let t=i[o],a=Ou[t>>>s&255]++;r[a]=e[o],n[a]=t}}function Lu(t,e,i,r,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-r)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Uu(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 Nu(t,e,i,r,n,s,o,a){return(n-o)*(e-a)>=(t-o)*(s-a)&&(t-o)*(r-a)>=(i-o)*(e-a)&&(i-o)*(s-a)>=(n-o)*(r-a)}function Gu(t,e){let i=Vu(t,e)&&qu(t.prev,t,t.next)>0&&qu(e.prev,e,e.next)>0;return t.next.i!==e.i&&(i||Hu(t,e)&&Hu(e,t)&&(0!==qu(t.prev,t,e.prev)||0!==qu(t,e.prev,e)))&&!function(t,e){let i=Math.min(t.x,e.x),r=Math.max(t.x,e.x),n=Math.min(t.y,e.y),s=Math.max(t.y,e.y),o=t;do{let a=o.next;if(o.x>r&&a.x>r||o.x<i&&a.x<i||o.y>s&&a.y>s||o.y<n&&a.y<n)o=a;else{if(o.i!==t.i&&a.i!==t.i&&o.i!==e.i&&a.i!==e.i&&Zu(o,a,t,e))return!0;o=a}}while(o!==t);return!1}(t,e)&&(i||function(t,e){let i=t,r=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do{let t=i.next;i.y>s!=t.y>s&&n<(t.x-i.x)*(s-i.y)/(t.y-i.y)+i.x&&(r=!r),i=t}while(i!==t);return r}(t,e))}function qu(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Vu(t,e){return t.x===e.x&&t.y===e.y}function Zu(t,e,i,r,n=!0){let s=qu(t,e,i),o=qu(t,e,r),a=qu(i,r,t),l=qu(i,r,e);return(s>0&&o<0||s<0&&o>0)&&(a>0&&l<0||a<0&&l>0)||!!n&&!!(0===s&&Wu(t,i,e)||0===o&&Wu(t,r,e)||0===a&&Wu(i,t,r)||0===l&&Wu(i,e,r))}function Wu(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 Hu(t,e){return qu(t.prev,t,t.next)<0?qu(t,e,t.next)>=0&&qu(t,t.prev,e)>=0:qu(t,e,t.prev)<0||qu(t,t.next,e)<0}function Yu(t,e){let i=Ku(t.i,t.x,t.y),r=Ku(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function Xu(t,e,i,r){let n=Ku(t,e,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function Ju(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),Du&&function(t,e){let i=4*t.z;e.x<Au[i]&&(Au[i]=e.x),e.y<Au[i+1]&&(Au[i+1]=e.y),e.x>Au[i+2]&&(Au[i+2]=e.x),e.y>Au[i+3]&&(Au[i+3]=e.y)}(t.prev,t.next)}function Ku(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var Qu=class{constructor(t,e){if(e>t)throw 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)}},tc=class t{constructor(t){this.fill=t.fill,this.line=t.line,this.tile=t.tile,this.stencil=t.stencil,this.circle=t.circle}static{this.noSubdivision=new t({fill:new Qu(0,0),line:new Qu(0,0),tile:new Qu(0,0),stencil:new Qu(0,0),circle:1})}};Vo("SubdivisionGranularityExpression",Qu),Vo("SubdivisionGranularitySetting",tc);const ec=-32768,ic=32767;var rc=class{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=st/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 Error("Vertex coordinates are out of signed 16 bit integer range.");let i=0|Math.round(t),r=0|Math.round(e),n=this._getKey(i,r),s=this._vertexDictionary.get(n);if(void 0!==s)return s;let o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(t,e){if(this._granularity<2)return function(t,e){let i=[];for(let r=0;r<e.length;r+=3){let n=e[r],s=e[r+1],o=e[r+2],a=t[2*n],l=t[2*n+1];(t[2*s]-a)*(t[2*o+1]-l)-(t[2*s+1]-l)*(t[2*o]-a)>0?(i.push(n),i.push(o),i.push(s)):(i.push(n),i.push(s),i.push(o))}return i}(this._vertexBuffer,function(t,e){let i=Array(t.length);for(let r=0;r<t.length;r++)i[r]=e[t[r]];return i}(t,e));let i=[],r=t.length;for(let n=0;n<r;n+=3){let r=[e[t[n+0]],e[t[n+1]],e[t[n+2]]],s=[this._vertexBuffer[2*r[0]+0],this._vertexBuffer[2*r[0]+1],this._vertexBuffer[2*r[1]+0],this._vertexBuffer[2*r[1]+1],this._vertexBuffer[2*r[2]+0],this._vertexBuffer[2*r[2]+1]],o=1/0,a=1/0,l=-1/0,h=-1/0;for(let t=0;t<3;t++){let e=s[2*t],i=s[2*t+1];o=Math.min(o,e),l=Math.max(l,e),a=Math.min(a,i),h=Math.max(h,i)}if(o===l||a===h)continue;let u=Math.floor(o/this._granularityCellSize),c=Math.ceil(l/this._granularityCellSize),f=Math.floor(a/this._granularityCellSize),p=Math.ceil(h/this._granularityCellSize);if(u!==c||f!==p)for(let t=f;t<p;t++){let e=this._scanlineGenerateVertexRingForCellRow(t,s,r);ac(this._vertexBuffer,e,i)}else i.push(...r)}return i}_scanlineGenerateVertexRingForCellRow(t,e,i){let r=t*this._granularityCellSize,n=r+this._granularityCellSize,s=[];for(let t=0;t<3;t++){let o=e[2*t],a=e[2*t+1],l=e[2*(t+1)%6],h=e[(2*(t+1)+1)%6],u=e[2*(t+2)%6],c=e[(2*(t+2)+1)%6],f=l-o,p=h-a,d=0===f,m=0===p,_=(r-a)/p,g=(n-a)/p,y=Math.min(_,g),v=Math.max(_,g);if(!m&&(y>=1||v<=0)||m&&(a<r||a>n)){h>=r&&h<=n&&s.push(i[(t+1)%3]);continue}!m&&y>0&&s.push(this._vertexToIndex(o+f*y,a+p*y));let w=o+f*Math.max(y,0),b=o+f*Math.min(v,1);d||this._generateIntraEdgeVertices(s,o,a,l,h,w,b),!m&&v<1&&s.push(this._vertexToIndex(o+f*v,a+p*v)),(m||h>=r&&h<=n)&&s.push(i[(t+1)%3]),!m&&(h<=r||h>=n)&&this._generateInterEdgeVertices(s,o,a,l,h,u,c,b,r,n)}return s}_generateIntraEdgeVertices(t,e,i,r,n,s,o){let a=r-e,l=n-i,h=0===l,u=h?Math.min(e,r):Math.min(s,o),c=h?Math.max(e,r):Math.max(s,o),f=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(c/this._granularityCellSize)-1;if(h?e<r:s<o)for(let r=f;r<=p;r++){let n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}else for(let r=p;r>=f;r--){let n=r*this._granularityCellSize;t.push(this._vertexToIndex(n,i+l*(n-e)/a))}}_generateInterEdgeVertices(t,e,i,r,n,s,o,a,l,h){let u=n-i,c=s-r,f=o-n,p=(l-n)/f,d=(h-n)/f,m=Math.min(p,d),_=Math.max(p,d),g=r+c*m,y=Math.floor(Math.min(g,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(g,a)/this._granularityCellSize)-1,w=a<g,b=0===f;if(b&&(o===l||o===h))return;if(b||m>=1||_<=0){let t=i-o,r=s+(e-s)*Math.min((l-o)/t,(h-o)/t);y=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,v=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,w=a<r}let x=u>0?h:l;if(w)for(let e=y;e<=v;e++)t.push(this._vertexToIndex(e*this._granularityCellSize,x));else for(let e=v;e>=y;e--)t.push(this._vertexToIndex(e*this._granularityCellSize,x))}_generateOutline(t,e){let i=[],r=0;for(let n of t){let t=this._granularity<2?this._ringPathIndices(n,r,e):this._pointArrayToIndices(sc(n,this._granularity,!0));r+=n.length;let s=[];for(let e=1;e<t.length;e++)s.push(t[e-1]),s.push(t[e]);i.push(s)}return i}_ringPathIndices(t,e,i){let r=i.slice(e,e+t.length);return r.length>=2&&oc(t)&&r.push(r[0]),r}_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(){let t=this._vertexBuffer;for(let e=0;e<t.length;e+=2){let i=t[e+1];-32768===i&&(t[e+1]=-32767),32767===i&&(t[e+1]=32766)}}_generatePoleQuad(t,e,i,r,n,s){r>n==(-32768===s)?(t.push(i),t.push(e),t.push(this._vertexToIndex(r,s)),t.push(this._vertexToIndex(n,s)),t.push(i),t.push(this._vertexToIndex(r,s))):(t.push(e),t.push(i),t.push(this._vertexToIndex(r,s)),t.push(i),t.push(this._vertexToIndex(n,s)),t.push(this._vertexToIndex(r,s)))}_fillPoles(t,e,i){let r=this._vertexBuffer,n=st,s=t.length;for(let o=2;o<s;o+=3){let s=t[o-2],a=t[o-1],l=t[o],h=r[2*s],u=r[2*s+1],c=r[2*a],f=r[2*a+1],p=r[2*l],d=r[2*l+1];e&&(0===u&&0===f&&this._generatePoleQuad(t,s,a,h,c,ec),0===f&&0===d&&this._generatePoleQuad(t,a,l,c,p,ec),0===d&&0===u&&this._generatePoleQuad(t,l,s,p,h,ec)),i&&(u===n&&f===n&&this._generatePoleQuad(t,s,a,h,c,ic),f===n&&d===n&&this._generatePoleQuad(t,a,l,c,p,ic),d===n&&u===n&&this._generatePoleQuad(t,l,s,p,h,ic))}}_initializeVertices(t){let e=[];for(let i=0;i<t.length;i+=2)e.push(this._vertexToIndex(t[i],t[i+1]));return e}subdividePolygonInternal(t,e){if(this._used)throw Error("Subdivision: multiple use not allowed.");this._used=!0;let i,{flattened:r,holeIndices:n}=function(t){let e=[],i=[];for(let r of t)if(0!==r.length){r!==t[0]&&e.push(i.length/2);for(let t of r)i.push(t.x),i.push(t.y)}return{flattened:i,holeIndices:e}}(t),s=this._initializeVertices(r);try{let t=function(t,e,i=2){let r=e&&e.length,n=r?e[0]*i:t.length;du.size&&du.clear();let s=_u(t,0,n,i,!0),o=[];if(!s||s.next===s.prev)return o;let a=0,l=0,h=0;if(r&&(s=function(t,e,i,r){let n=[];for(let i=0,s=e.length;i<s;i++){let o=_u(t,e[i]*r,i<s-1?e[i+1]*r:t.length,r,!1);o===o.next&&du.add(o),n.push(Uu(o))}n.sort(Mu),function(t,e){let i=Math.ceil((t+2*e)/16)+e+2;Au.length<4*i&&(Au=new Float64Array(4*i)),Fu=0}(t.length/r,e.length),zu(i,i),Du=!0;for(let t=0;t<n.length;t++)i=Eu(n[t],i);return Du=!1,gu(i)}(t,e,s,i)),t.length>80*i){a=t[0],l=t[1];let e=a,r=l;for(let s=i;s<n;s+=i){let i=t[s],n=t[s+1];i<a&&(a=i),n<l&&(l=n),i>e&&(e=i),n>r&&(r=n)}h=Math.max(e-a,r-l),h=0===h?0:32767/h}return yu(s,o,a,l,h),o}(r,n);i=this._subdivideTrianglesScanline(t,s)}catch(t){console.error(t)}let o=[];return e&&(o=this._generateOutline(t,s)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),o=o.map((t=>this._removeLinesOutsideTileX(t)))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:o}}_vertexOutsideTileX(t){let e=this._vertexBuffer[2*t];return e<0||e>8192}_removeTrianglesOutsideTileX(t){let e=[];for(let i=0;i<t.length;i+=3)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||this._vertexOutsideTileX(t[i+2])||e.push(t[i],t[i+1],t[i+2]);return e}_removeLinesOutsideTileX(t){let e=[];for(let i=0;i<t.length;i+=2)this._vertexOutsideTileX(t[i])||this._vertexOutsideTileX(t[i+1])||e.push(t[i],t[i+1]);return e}_pointArrayToIndices(t){let e=[];for(let i of t)e.push(this._vertexToIndex(i.x,i.y));return e}};function nc(t,e,i,r=!0){return new rc(i,e).subdividePolygonInternal(t,r)}function sc(t,e,i=!1){if(!t||t.length<1||t.length<2)return[];let r=i&&oc(t);if(e<2)return r?[...t,t[0]]:[...t];let n=Math.floor(st/e),s=[];s.push(new f(t[0].x,t[0].y));let o=t.length,a=r?o:o-1;for(let e=0;e<a;e++){let i=t[e],r=e<o-1?t[e+1]:t[0],a=i.x,l=i.y,h=r.x,u=r.y,c=a!==h,p=l!==u;if(!c&&!p)continue;let d=h-a,m=u-l,_=Math.abs(d),g=Math.abs(m),y=a,v=l;for(;;){let t=d>0?(Math.floor(y/n)+1)*n:(Math.ceil(y/n)-1)*n,e=m>0?(Math.floor(v/n)+1)*n:(Math.ceil(v/n)-1)*n,i=Math.abs(y-t),r=Math.abs(v-e),o=Math.abs(y-h),a=Math.abs(v-u),l=c?i/_:1/0,w=p?r/g:1/0;if((o<=i||!c)&&(a<=r||!p))break;if(l<w&&c||!p){y=t,v+=m*l;let e=new f(y,Math.round(v));(s[s.length-1].x!==e.x||s[s.length-1].y!==e.y)&&s.push(e)}else{y+=d*w,v=e;let t=new f(Math.round(y),v);(s[s.length-1].x!==t.x||s[s.length-1].y!==t.y)&&s.push(t)}}let w=new f(h,u);(s[s.length-1].x!==w.x||s[s.length-1].y!==w.y)&&s.push(w)}return s}function oc(t){return!t[0].equals(t[t.length-1])}function ac(t,e,i){if(0===e.length)throw Error("Subdivision vertex ring is empty.");let r=0,n=t[2*e[0]];for(let i=1;i<e.length;i++){let s=t[2*e[i]];s<n&&(n=s,r=i)}let s=e.length,o=r,a=(o+1)%s;for(;;){let r=o-1>=0?o-1:s-1,n=(a+1)%s,l=t[2*e[r]],h=t[2*e[r]+1],u=t[2*e[n]],c=t[2*e[n]+1],f=t[2*e[o]],p=t[2*e[o]+1],d=t[2*e[a]],m=t[2*e[a]+1],_=!1;if(l<u)_=!0;else if(l>u)_=!1;else{let t=m-p,e=-(d-f),i=p<m?1:-1;((l-f)*t+(h-p)*e)*i>((u-f)*t+(c-p)*e)*i&&(_=!0)}if(_){let t=e[r],n=e[o],l=e[a];t!==n&&t!==l&&n!==l&&i.push(l,n,t),o--,o<0&&(o=s-1)}else{let t=e[n],r=e[o],l=e[a];t!==r&&t!==l&&r!==l&&i.push(l,r,t),a++,a>=s&&(a=0)}if(r===n)break}}function lc(t,e,i,r,n,s,o,a,l){let h=n.length/2,u=o&&a&&l;if(h<zl.MAX_VERTEX_ARRAY_LENGTH){let c,f,p=e.prepareSegment(h,i,r),d=p.vertexLength;for(let t=0;t<s.length;t+=3)r.emplaceBack(d+s[t],d+s[t+1],d+s[t+2]);p.vertexLength+=h,p.primitiveLength+=s.length/3,u&&(f=o.prepareSegment(h,i,a),c=f.vertexLength,f.vertexLength+=h);for(let e=0;e<n.length;e+=2)t(n[e],n[e+1]);if(u)for(let t of l){for(let e=1;e<t.length;e+=2)a.emplaceBack(c+t[e-1],c+t[e]);f.primitiveLength+=t.length/2}}else(function(t,e,i,r,n,s){let o=[];for(let t=0;t<r.length/2;t++)o.push(-1);let a={count:0},l=0,h=t.getOrCreateLatestSegment(e,i),u=h.vertexLength;for(let c=2;c<n.length;c+=3){let f=n[c-2],p=n[c-1],d=n[c],m=o[f]<l,_=o[p]<l,g=o[d]<l;h.vertexLength+(+!!m+ +!!_+ +!!g)>zl.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,m=!0,_=!0,g=!0,u=0);let y=hc(o,r,s,a,f,m,h),v=hc(o,r,s,a,p,_,h),w=hc(o,r,s,a,d,g,h);i.emplaceBack(u+y-l,u+v-l,u+w-l),h.primitiveLength++}})(e,i,r,n,s,t),u&&function(t,e,i,r,n,s){let o=[];for(let t=0;t<r.length/2;t++)o.push(-1);let a={count:0},l=0,h=t.getOrCreateLatestSegment(e,i),u=h.vertexLength;for(let c of n)for(let n=1;n<c.length;n+=2){let f=c[n-1],p=c[n],d=o[f]<l,m=o[p]<l;h.vertexLength+(+!!d+ +!!m)>zl.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,d=!0,m=!0,u=0);let _=hc(o,r,s,a,f,d,h),g=hc(o,r,s,a,p,m,h);i.emplaceBack(u+_-l,u+g-l),h.primitiveLength++}}(o,i,a,n,l,t),e.forceNewSegmentOnNextPrepare(),o?.forceNewSegmentOnNextPrepare()}function hc(t,e,i,r,n,s,o){if(s){let s=r.count;return i(e[2*n],e[2*n+1]),t[n]=r.count,r.count++,o.vertexLength++,s}return t[n]}var uc=class{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.sdfPatterns={},this.patternFeatures=[],this.layoutVertexArray=new pl,this.indexArray=new Al,this.indexArray2=new Fl,this.programConfigurations=new ah(t.layers,t.zoom),this.segments=new zl,this.segments2=new zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=fu("fill",this.layers,e);let r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),s=[],o=new Ko(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of t){let t=ph(l,a);if(!this.layers[0]._featureFilter.filter(o,t,i))continue;let f=n?r.evaluate(t,{},i,e.availableImages):void 0,p={id:h,properties:l.properties,type:l.type,sourceLayerIndex:c,index:u,geometry:a?t.geometry:fh(l),patterns:{},sortKey:f};s.push(p)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of s){let{geometry:n,index:s,sourceLayerIndex:o}=r;if(this.hasDependencies){let t=pu("fill",this.layers,r,{zoom:this.zoom},e);this.patternFeatures.push(t)}else this.addFeature(r,n,s,i,{},e.subdivisionGranularity);e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i})}addFeatures({options:t,canonical:e,patternPositions:i,patternMap:r}){this.detectSdfPatterns(r);for(let r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,e,i,t.subdivisionGranularity)}detectSdfPatterns(t){for(let e of this.patternFeatures)for(let i in e.patterns){let r=e.patterns[i];this.recordSdfPattern(i,t[r.min]),this.recordSdfPattern(i,t[r.mid]),this.recordSdfPattern(i,t[r.max])}for(let e of this.layers){let i=e.paint.get("fill-pattern").constantOr(null);i&&(this.recordSdfPattern(e.id,t[i.from.toString()]),this.recordSdfPattern(e.id,t[i.to.toString()]))}}recordSdfPattern(t,e){if(!e)return;let i=!0===e.sdf,r=this.sdfPatterns[t];void 0===r?this.sdfPatterns[t]=i:r!==i&&Lt(`Style sheet warning: Cannot mix SDF and non-SDF fill patterns in layer "${t}"`)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,cu),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,r,n,s){for(let t of Ir(e,500)){let e=nc(t,r,s.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;lc(((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:n,canonical:r})}};let cc,fc;Vo("FillBucket",uc,{omit:["layers","patternFeatures"]});var pc={get paint(){return fc||=new da({"fill-antialias":new ha(Ke.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new ua(Ke.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new ha(Ke.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new ua(Ke.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new ua(Ke.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new ha(Ke.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new ha(Ke.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new ca(Ke.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return cc||=new da({"fill-sort-key":new ua(Ke.layout_fill["fill-sort-key"],"fill-sort-key")})}},dc=class extends ga{constructor(t,e){super(t,pc,e)}recalculate(t,e){super.recalculate(t,e);let 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 uc(t)}queryRadius(){return zh(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return vh(Th(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}};const mc=Ea([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),_c=Ea([{name:"a_centroid",components:2,type:"Int16"}],4),gc=mc.members;var yc=class t{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(e){let i=new t;return i.extend(e(new f(this.minX,this.minY))),i.extend(e(new f(this.maxX,this.minY))),i.extend(e(new f(this.minX,this.maxY))),i.extend(e(new f(this.maxX,this.maxY))),i}static fromPoints(e){let i=new t;for(let t of e)i.extend(t);return i}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}};const vc=yc.fromPoints([new f(0,0),new f(st,st)]);function wc(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}function bc(t){return t.every((t=>t.x<0))||t.every((t=>t.x>8192))||t.every((t=>t.y<0))||t.every((t=>t.y>8192))}var xc=class{constructor(t,e,i,r,n){for(this.properties=Object.create(null),this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=r,this._values=n;t.pos<e;){let e=t.readVarint();if(8===e)this.id=t.readVarint();else if(18===e){let e=t.readVarint()+t.pos;for(;t.pos<e;){let e=r[t.readVarint()],i=n[t.readVarint()];this.properties[e]=i}}else 24===e?this.type=t.readVarint():(34===e&&(this._geometry=t.pos),t.skip(e))}}loadGeometry(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e,i=t.readVarint()+t.pos,r=[],n=1,s=0,o=0,a=0;for(;t.pos<i;){if(s<=0){let e=t.readVarint();if(n=7&e,s=e>>3,0===s)continue}if(s--,1===n)o+=t.readSVarint(),a+=t.readSVarint(),e&&r.push(e),e=[new f(o,a)];else if(2===n)o+=t.readSVarint(),a+=t.readSVarint(),e&&e.push(new f(o,a));else{if(7!==n)throw Error(`unknown command ${n}`);e&&e.push(e[0].clone())}}return e&&r.push(e),r}bbox(){if(this._geometry<0)throw Error("feature has no geometry");let t=this._pbf;t.pos=this._geometry;let e=t.readVarint()+t.pos,i=1,r=0,n=0,s=0,o=1/0,a=-1/0,l=1/0,h=-1/0;for(;t.pos<e;){if(r<=0){let e=t.readVarint();if(i=7&e,r=e>>3,0===r)continue}if(r--,1===i||2===i)n+=t.readSVarint(),s+=t.readSVarint(),n<o&&(o=n),n>a&&(a=n),s<l&&(l=s),s>h&&(h=s);else if(7!==i)throw Error(`unknown command ${i}`)}return[o,l,a,h]}toGeoJSON(t,e,i){let r,n=this.extent*2**i,s=this.extent*t,o=this.extent*e,a=this.loadGeometry();function l(t){return[360*(t.x+s)/n-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+o)/n)*Math.PI))-90]}function h(t){return t.map(l)}if(1===this.type){let t=[];for(let e of a)t.push(e[0]);let e=h(t);r=1===t.length?{type:"Point",coordinates:e[0]}:{type:"MultiPoint",coordinates:e}}else if(2===this.type){let t=a.map(h);r=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t}}else{if(3!==this.type)throw Error("unknown feature type");{let t=Dc(a),e=[];for(let i of t)e.push(i.map(h));r=1===e.length?{type:"Polygon",coordinates:e[0]}:{type:"MultiPolygon",coordinates:e}}}let u={type:"Feature",geometry:r,properties:this.properties};return null!=this.id&&(u.id=this.id),u}};function Dc(t){let e=t.length;if(e<=1)return[t];let i,r,n=[];for(let s=0;s<e;s++){let e=Mc(t[s]);0!==e&&(void 0===r&&(r=e<0),r===e<0?(i&&n.push(i),i=[t[s]]):i&&i.push(t[s]))}return i&&n.push(i),n}function Mc(t){let e=0;for(let i,r,n=0,s=t.length,o=s-1;n<s;o=n++)i=t[n],r=t[o],e+=(r.x-i.x)*(i.y+r.y);return e}xc.types=["Unknown","Point","LineString","Polygon"];var Ec=class{constructor(t,e){for(this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],void 0===e&&(e=t.length);t.pos<e;){let e=t.readVarint();10===e?this.name=t.readString():18===e?(this._features.push(t.pos),t.skip(e)):26===e?this._keys.push(t.readString()):34===e?this._values.push(Ac(t)):40===e?this.extent=t.readVarint():120===e?this.version=t.readVarint():t.skip(e)}this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw Error("feature index out of bounds");this._pbf.pos=this._features[t];let e=this._pbf.readVarint()+this._pbf.pos;return new xc(this._pbf,e,this.extent,this._keys,this._values)}};function Ac(t){let e=null,i=t.readVarint()+t.pos;for(;t.pos<i;){let i=t.readVarint();e=10===i?t.readString():21===i?t.readFloat():25===i?t.readDouble():32===i?t.readVarint(!0):40===i?t.readVarint():48===i?t.readSVarint():56===i?t.readBoolean():(t.skip(i),null)}if(null==e)throw Error("unknown feature value");return e}var Fc=class{constructor(t,e=t.length){let i=Object.create(null);for(;t.pos<e;){let e=t.readVarint();if(26===e){let e=new Ec(t,t.readVarint()+t.pos);e.length&&(i[e.name]=e)}else t.skip(e)}this.layers=i}};const Sc=6371008.8;var Cc=class t{constructor(t,e){if(isNaN(t)||isNaN(e))throw Error(`Invalid LngLat object: (${t}, ${e})`);if(this.lng=+t,this.lat=+e,this.lat>90||this.lat<-90)throw Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new t(Ft(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){let e=Math.PI/180,i=this.lat*e,r=t.lat*e,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((t.lng-this.lng)*e);return Sc*Math.acos(Math.min(n,1))}static convert(e){if(e instanceof t)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new t(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&e)return new t(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw 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 zc=2*Math.PI*Sc;function Tc(t){return zc*Math.cos(t*Math.PI/180)}function Pc(t){return(180+t)/360}function Ic(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function kc(t,e){return t/Tc(e)}function $c(t){return 360*t-180}function jc(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Rc(t,e){return t*Tc(jc(e))}var Oc=class t{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(e,i=0){let r=Cc.convert(e);return new t(Pc(r.lng),Ic(r.lat),kc(i,r.lat))}toLngLat(){return new Cc($c(this.x),jc(this.y))}toAltitude(){return Rc(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/zc*function(t){return 1/Math.cos(t*Math.PI/180)}(jc(this.y))}};const Bc=89.25;function Lc(t,e,i){let r=1/(1<<i.z);return new Oc(t/st*r+i.x*r,e/st*r+i.y*r)}function Uc(t,e){let i=At(e.lat,-85.051129,Qt);return new f(Pc(e.lng)*t,Ic(i)*t)}function Nc(t,e){return new Oc(e.x/t,e.y/t).toLngLat()}function Gc(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(Ht(90-t.pitch)),Math.tan(Ht(Bc-t.pitch)))}function qc(t,e){let i=t.canonical,r=e/Pt(i.z),n=i.x+2**i.z*t.wrap,s=new Float64Array(16);return x(s),E(s,s,[n*r,i.y*r,0]),A(s,s,[r/st,r/st,1]),s}function Vc(t,e,i,r,n){let s=Oc.fromLngLat(t,e),o=n*kc(1,t.lat),{x:a,y:l,z:h}=Zc(i,r);return new Oc(s.x+o*-a,s.y+o*-l,s.z+o*h)}function Zc(t,e){let i=Ht(t),r=Ht(e),n=Math.cos(-i),s=Math.sin(i);return{x:s*Math.sin(r),y:-s*Math.cos(r),z:n}}function Wc(t,e){return e<=0||!t||0===t.length?t:t.map((t=>function(t,e){if(!t||t.length<3)return t;let i=t[0].x===t[t.length-1].x&&t[0].y===t[t.length-1].y,r=i?t.length-1:t.length;if(r<3)return t;let n=[],s=wc(t[r-1],t[0]);for(let i=0;i<r;i++){let o=t[(i-1+r)%r],a=t[i],l=t[(i+1)%r],h=wc(a,l);s||h?n.push(a.clone()):Xc(n,o,a,l,e),s=h}let o=function(t){let e=[];for(let i of t){let t=i.round(),r=e[e.length-1];(r?.x!==t.x||r?.y!==t.y)&&e.push(t)}for(;e.length>1&&e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y;)e.pop();return e}(n);return o.length<3?t:(i&&o.push(o[0].clone()),o)}(t,e)))}const Hc=Math.cos(35*Math.PI/180);function Yc(t,e){if(!e)return t.unit();let i=t.mag(),r=e.mag();return t.x*e.x+t.y*e.y<Hc*i*r||i>=2*r?t.unit():r>=2*i?e.unit():t.add(e)._unit()}function Xc(t,e,i,r,n){let s=e.sub(i),o=r.sub(i),a=s.mag(),l=o.mag();if(a<1e-6||l<1e-6)return void t.push(i.clone());s._div(a),o._div(l);let h=s.x*o.x+s.y*o.y;if(Math.abs(h)>Math.cos(5*Math.PI/180))return void t.push(i.clone());let u=Math.min(n,.2*a,.2*l),c=i.add(s.mult(u)),f=i.add(o.mult(u)),p=Math.sqrt((1+h)/2),d=i.add(s.add(o)._unit()._mult(u/p)),m=c.sub(d).angleWith(f.sub(d)),_=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/6)-1e-6));for(let e=0;e<=_;e++)t.push(c.rotateAround(e/_*m,d))}const Jc=8192;function Kc(t,e,i,r,n,s,o,a){t.emplaceBack(e,i,2*Math.floor(r*Jc)+o,n*Jc*2,s*Jc*2,Math.round(a))}var Qc=class{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 dl,this.centroidVertexArray=new hl,this.indexArray=new Al,this.programConfigurations=new ah(t.layers,t.zoom),this.segments=new zl,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasDependencies=fu("fill-extrusion",this.layers,e);let r=new Ko(this.zoom),n=this.layers[0],s=n.layout.get("fill-extrusion-rounded-corner-distance"),o=s>0?function(t,e){let i=function(t,e,i){return Lc(4096,4096,i).toLngLat()}(0,0,e);return t*Oc.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<e.z)*st)}(s,i):0,a=n._featureFilter.needGeometry;for(let{feature:s,id:l,index:h,sourceLayerIndex:u}of t){let t=ph(s,a);if(!n._featureFilter.filter(r,t,i))continue;let c={id:l,sourceLayerIndex:u,index:h,geometry:Wc(a?t.geometry:fh(s),o),properties:s.properties,type:s.type,patterns:{}};this.hasDependencies?this.features.push(pu("fill-extrusion",this.layers,c,{zoom:this.zoom},e)):this.addFeature(c,c.geometry,h,i,{},e.subdivisionGranularity),e.featureIndex.insert(s,c.geometry,h,u,this.index,!0)}}addFeatures({options:t,canonical:e,patternPositions:i}){for(let r of this.features){let{geometry:n}=r;this.addFeature(r,n,r.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,gc),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,_c.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,r,n,s){for(let i of Ir(e,500)){let e={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(e,r,t,i,s);let o=this.layoutVertexArray.length-n,a=Math.floor(e.x/e.sampleCount),l=Math.floor(e.y/e.sampleCount);for(let t=0;t<o;t++)this.centroidVertexArray.emplaceBack(a,l)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,canonical:r})}processPolygon(t,e,i,r,n){if(r.length<1||bc(r[0]))return;for(let e of r)0!==e.length&&tf(t,e);let s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(e.z),a="Polygon"===xc.types[i.type];for(let t of r){if(0===t.length||bc(t))continue;let e=sc(t,o,a);this._generateSideFaces(e,s)}if(!a)return;let l=nc(r,e,o,!1),h=this.layoutVertexArray;lc(((t,e)=>{Kc(h,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0,r=this.layers[0].layout.get("fill-extrusion-rounded-corner-distance")>0?function(t){let e=[null];for(let i=1;i<t.length;i++){let r=t[i].sub(t[i-1]),n=!wc(t[i],t[i-1])&&r.mag()>0;e.push(n?r._perp():null)}let i=t.length-1,r=i>1&&t[0].equals(t[i]),n=[null];for(let t=1;t<=i;t++){let s=e[t];if(!s){n.push(null);continue}let o=r&&t===i?e[1]:e[t+1];n.push({start:Yc(s,r&&1===t?e[i]:e[t-1]),end:Yc(s,o)})}return n}(t):null;for(let n=1;n<t.length;n++){let s=t[n],o=t[n-1];if(wc(s,o)||r&&!r[n])continue;e.segment.vertexLength+4>zl.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let a=s.sub(o)._perp()._unit(),{start:l,end:h}=r?r[n]:{start:a,end:a},u=o.dist(s);i+u>32768&&(i=0),Kc(this.layoutVertexArray,s.x,s.y,h.x,h.y,0,0,i),Kc(this.layoutVertexArray,s.x,s.y,h.x,h.y,0,1,i),i+=u,Kc(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,0,i),Kc(this.layoutVertexArray,o.x,o.y,l.x,l.y,0,1,i);let c=e.segment.vertexLength;this.indexArray.emplaceBack(c,c+2,c+1),this.indexArray.emplaceBack(c+1,c+2,c+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}};function tf(t,e){for(let i=0;i<e.length;i++){let r=e[i];(i!==e.length-1||e[0].x!==r.x||e[0].y!==r.y)&&(t.x+=r.x,t.y+=r.y,t.sampleCount++)}}let ef,rf;Vo("FillExtrusionBucket",Qc,{omit:["layers","features"]});var nf={get paint(){return rf||=new da({"fill-extrusion-opacity":new ha(Ke["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new ua(Ke["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new ha(Ke["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new ha(Ke["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new ca(Ke["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new ua(Ke["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new ua(Ke["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new ha(Ke["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return ef||=new da({"fill-extrusion-rounded-corner-distance":new ha(Ke["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},sf=class extends ga{constructor(t,e){super(t,nf,e)}createBucket(t){return new Qc(t)}queryRadius(){return zh(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,pixelPosMatrix:o}){let a=Th(t,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-n.bearingInRadians,s),l=this.paint.get("fill-extrusion-height").evaluate(e,i),h=this.paint.get("fill-extrusion-base").evaluate(e,i),u=hf(a,o,0),c=lf(r,h,l,o);return function(t,e,i){let r=1/0;vh(i,e)&&(r=af(i,e[0]));for(let n=0;n<e.length;n++){let s=e[n],o=t[n];for(let t=0;t<s.length-1;t++){let e=s[t],n=[e,s[t+1],o[t+1],o[t],e];gh(i,n)&&(r=Math.min(r,af(i,n)))}}return r!==1/0&&r}(c[0],c[1],u)}};function of(t,e){return t.x*e.x+t.y*e.y}function af(t,e){if(1===t.length){let i,r=0,n=e[r++];for(;!i||n.equals(i);)if(i=e[r++],!i)return 1/0;for(;r<e.length;r++){let s=e[r],o=t[0],a=i.sub(n),l=s.sub(n),h=o.sub(n),u=of(a,a),c=of(a,l),f=of(l,l),p=of(h,a),d=of(h,l),m=u*f-c*c,_=(f*p-c*d)/m,g=(u*d-c*p)/m,y=n.z*(1-_-g)+i.z*_+s.z*g;if(isFinite(y))return y}return 1/0}{let t=1/0;for(let i of e)t=Math.min(t,i.z);return t}}function lf(t,e,i,r){let n=[],s=[],o=r[8]*e,a=r[9]*e,l=r[10]*e,h=r[11]*e,u=r[8]*i,c=r[9]*i,p=r[10]*i,d=r[11]*i;for(let e of t){let t=[],i=[];for(let n of e){let e=n.x,s=n.y,m=r[0]*e+r[4]*s+r[12],_=r[1]*e+r[5]*s+r[13],g=r[2]*e+r[6]*s+r[14],y=r[3]*e+r[7]*s+r[15],v=g+l,w=y+h,b=m+u,x=_+c,D=g+p,M=y+d,E=new f((m+o)/w,(_+a)/w);E.z=v/w,t.push(E);let A=new f(b/M,x/M);A.z=D/M,i.push(A)}n.push(t),s.push(i)}return[n,s]}function hf(t,e,i){let r=[];for(let n of t){let t=[n.x,n.y,i,1];Y(t,t,e),r.push(new f(t[0]/t[3],t[1]/t[3]))}return r}const uf=Ea([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_offset_normal",components:2,type:"Int8"}],2).members,cf=Ea([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]).members,ff=Math.cos(Math.PI/180*37.5);var pf=class{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(let t of this.layers)this.gradients[t.id]={};this.layoutVertexArray=new ml,this.layoutVertexArray2=new _l,this.indexArray=new Al,this.programConfigurations=new ah(t.layers,t.zoom),this.segments=new zl,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=fu("line",this.layers,e)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),s=[],o=new Ko(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:l,index:h,sourceLayerIndex:u}of t){let t=ph(e,a);if(!this.layers[0]._featureFilter.filter(o,t,i))continue;let c=n?r.evaluate(t,{},i):void 0,f={id:l,properties:e.properties,type:e.type,sourceLayerIndex:u,index:h,geometry:a?t.geometry:fh(e),patterns:{},dashes:{},sortKey:c};s.push(f)}n&&s.sort(((t,e)=>t.sortKey-e.sortKey));for(let r of s){let{geometry:n,index:s,sourceLayerIndex:o}=r;this.hasDependencies?(fu("line",this.layers,e)?pu("line",this.layers,r,{zoom:this.zoom},e):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,e),this.patternFeatures.push(r)):this.addFeature(r,n,s,i,{},{},e.subdivisionGranularity),e.featureIndex.insert(t[s].feature,n,s,o,this.index)}}update(t,e,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,e,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures({options:t,canonical:e,patternPositions:i,dashPositions:r}){for(let n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,e,i,r,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,cf)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,uf),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,"geojsonvt_clip_start")&&Object.hasOwn(t.properties,"geojsonvt_clip_end"))return{start:+t.properties.geojsonvt_clip_start,end:+t.properties.geojsonvt_clip_end}}addFeature(t,e,i,r,n,s,o){let a=this.layers[0].layout,l=a.get("line-join").evaluate(t,{}),h=a.get("line-cap").evaluate(t,{}),u=a.get("line-miter-limit").evaluate(t,{}),c=a.get("line-round-limit").evaluate(t,{});this.lineClips=this.lineFeatureClips(t);for(let i of e)this.addLine(i,t,l,h,u,c,r,o);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,i,{imagePositions:n,dashPositions:s,canonical:r})}addLine(t,e,i,r,n,s,o,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,t=sc(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)}let l="Polygon"===xc.types[e.type],h=t.length;for(;h>=2&&t[h-1].equals(t[h-2]);)h--;let u=0;for(;u<h-1&&t[u].equals(t[u+1]);)u++;if(h-u<(l?3:2))return;"bevel"===i&&(n=1.05);let c,f,p,d,m,_=this.overscaling<=16?15*st/(512*this.overscaling):0,g=this.segments.prepareSegment(10*h,this.layoutVertexArray,this.indexArray);this.e1=this.e2=-1,l&&(c=t[h-2],m=t[u].sub(c)._unit()._perp());for(let e=u;e<h;e++){if(p=e===h-1?l?t[u+1]:void 0:t[e+1],p&&t[e].equals(p))continue;m&&(d=m),c&&(f=c),c=t[e],m=p?p.sub(c)._unit()._perp():d,d||=m;let o=d.add(m);(0!==o.x||0!==o.y)&&o._unit();let a=d.x*m.x+d.y*m.y,y=o.x*m.x+o.y*m.y,v=0===y?1/0:1/y,w=2*Math.sqrt(2-2*y),b=y<ff&&f&&p,x=d.x*m.y-d.y*m.x>0,D=o.mult(Math.min(v,2)),M=At((v-3)/5,0,1);if(b&&e>u){let t=c.dist(f);if(t>2*_){let e=c.sub(c.sub(f)._mult(_/t)._round());this.updateDistance(f,e),this.addCurrentVertex(e,d,0,0,g),f=e}}let E=f&&p,A=E?i:l?"butt":r;if(E&&"round"===A&&(v<s?A="miter":v<=2&&(A="fakeround")),"miter"===A&&v>n&&(A="bevel"),"bevel"===A&&(v>2&&(A="flipbevel"),v<n&&(A="miter")),f&&this.updateDistance(f,c),"miter"===A)o._mult(v),this.addCurrentVertex(c,o,0,0,g,!1,D);else if("flipbevel"===A){if(v>100)o=m.mult(-1);else{let t=v*d.add(m).mag()/d.sub(m).mag();o._perp()._mult(t*(x?-1:1))}this.addCurrentVertex(c,o,0,0,g,!1,D,M),this.addCurrentVertex(c,o.mult(-1),0,0,g,!1,D,M)}else if("bevel"===A||"fakeround"===A){let t=-Math.sqrt(v*v-1),e=x?t:0,i=x?0:t;if(f&&this.addCurrentVertex(c,d,e,i,g,!1,D),"fakeround"===A){let t=Math.round(180*w/Math.PI/20);for(let e=1;e<t;e++){let i=e/t;if(.5!==i){let 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)))}let r=m.sub(d)._mult(i)._add(d)._unit()._mult(x?-1:1);this.addHalfVertex(c,r.x,r.y,x?-D.x:D.x,x?-D.y:D.y,!1,x,g)}}p&&this.addCurrentVertex(c,m,-e,-i,g,!1,D)}else if("butt"===A)this.addCurrentVertex(c,o,0,0,g,!1,D);else if("square"===A){let t=f?1:-1;this.addCurrentVertex(c,o,t,t,g,!1,D)}else"round"===A&&(f&&(this.addCurrentVertex(c,d,0,0,g,!1,D,M),this.addCurrentVertex(c,d,1,1,g,!0,D,M)),p&&(this.addCurrentVertex(c,m,-1,-1,g,!0,D,M),this.addCurrentVertex(c,m,0,0,g,!1,D,M)));if(b&&e<h-1){let t=c.dist(p);if(t>2*_){let e=c.add(p.sub(c)._mult(_/t)._round());this.updateDistance(c,e),this.addCurrentVertex(e,m,0,0,g),c=e}}}}addCurrentVertex(t,e,i,r,n,s=!1,o=e,a=0){let l=e.y*r-e.x,h=-e.y-e.x*r,u=o.x+(e.x-o.x)*a,c=o.y+(e.y-o.y)*a;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,u,c,s,!1,n),this.addHalfVertex(t,l,h,-u,-c,s,!0,n),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,n,s,o,a))}addHalfVertex({x:t,y:e},i,r,n,s,o,a,l){let h=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);this.layoutVertexArray.emplaceBack(+!!o+(t<<1),+!!a+(e<<1),Math.round(63*i)+128,Math.round(63*r)+128,(63&h)<<2,h>>6,Math.round(63*n),Math.round(63*s)),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let u=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,u,this.e2),l.primitiveLength++),a?this.e2=u:this.e1=u}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(let e of t){let t=e.paint.get("line-dasharray");if(t&&!t.isConstant())return!0}return!1}addLineDashDependencies(t,e,i,r){for(let n of t){let t=n.paint.get("line-dasharray");if(!t||"constant"===t.value.kind)continue;let s="round"===n.layout.get("line-cap").evaluate(e,{}),o={dasharray:t.value.evaluate({zoom:i-1},e,{}),round:s},a={dasharray:t.value.evaluate({zoom:i},e,{}),round:s},l={dasharray:t.value.evaluate({zoom:i+1},e,{}),round:s},h=`${o.dasharray.join(",")},${o.round}`,u=`${a.dasharray.join(",")},${a.round}`,c=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[h]=o,r.dashDependencies[u]=a,r.dashDependencies[c]=l,e.dashes[n.id]={min:h,mid:u,max:c}}}};let df,mf;Vo("LineBucket",pf,{omit:["layers","patternFeatures"]});var _f={get paint(){return mf||=new da({"line-opacity":new ua(Ke.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new ha(Ke.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new ua(Ke.paint_line["line-color"],"line-color"),"line-translate":new ha(Ke.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new ha(Ke.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new ua(Ke.paint_line["line-width"],"line-width"),"line-gap-width":new ua(Ke.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new ua(Ke.paint_line["line-offset"],"line-offset"),"line-blur":new ua(Ke.paint_line["line-blur"],"line-blur"),"line-dasharray":new ca(Ke.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new ca(Ke.paint_line["line-pattern"],"line-pattern"),"line-gradient":new pa(Ke.paint_line["line-gradient"],"line-gradient")})},get layout(){return df||=new da({"line-cap":new ua(Ke.layout_line["line-cap"],"line-cap"),"line-join":new ua(Ke.layout_line["line-join"],"line-join"),"line-miter-limit":new ua(Ke.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new ua(Ke.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new ua(Ke.layout_line["line-sort-key"],"line-sort-key")})}},gf=class extends ua{possiblyEvaluate(t,e){return e=new Ko(Math.floor(e.zoom),{now:e.now,fadeDuration:e.fadeDuration,zoomHistory:e.zoomHistory,transition:e.transition}),super.possiblyEvaluate(t,e)}evaluate(t,e,i,r){return e=St({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}};let yf;var vf=class extends ga{constructor(t,e){super(t,_f,e),this.gradientVersion=0,yf||(yf=new gf(_f.paint.properties["line-width"].specification,"line-floorwidth"),yf.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(t){if("line-gradient"===t){let t=this.gradientExpression();this.stepInterpolant=!!function(t){return void 0!==t._styleExpression}(t)&&t._styleExpression.expression instanceof Er,this.gradientVersion=(this.gradientVersion+1)%(2**53-1)}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(t,e){super.recalculate(t,e),this.paint._values["line-floorwidth"]=yf.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new pf(t)}queryRadius(t){let e=t,i=wf(Ch("line-width",this,e),Ch("line-gap-width",this,e)),r=Ch("line-offset",this,e);return i/2+Math.abs(r)+zh(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s}){let o=Th(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,s),a=s/2*wf(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),l=this.paint.get("line-offset").evaluate(e,i);return l&&(r=function(t,e){let i=[];for(let r of t){let t=Ph(r),n=[];for(let i=0;i<t.length;i++){let r=t[i],s=t[i-1],o=t[i+1],a=0===i?new f(0,0):r.sub(s)._unit()._perp(),l=i===t.length-1?new f(0,0):o.sub(r)._unit()._perp(),h=a._add(l)._unit(),u=h.x*l.x+h.y*l.y;0!==u&&h._mult(1/u),n.push(h._mult(e)._add(r))}i.push(n)}return i}(r,l*s)),function(t,e,i){for(let r of e){if(t.length>=3)for(let e of r)if(Ah(t,e))return!0;if(wh(t,r,i))return!0}return!1}(o,r,a)}isTileClipped(){return!0}};function wf(t,e){return e>0?e+2*t:t}const bf=Ea([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"},{name:"a_height_offset",components:1,type:"Float32"}],4),xf=Ea([{name:"a_projected_pos",components:3,type:"Float32"}],4);Ea([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Df=Ea([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Ea([{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 Mf=Ea([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Ef=Ea([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ea([{name:"triangle",components:3,type:"Uint16"}]),Ea([{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"},{type:"Float32",name:"heightOffset"}]);const Af=Ea([{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"},{type:"Float32",name:"heightOffset"}]);Ea([{type:"Float32",name:"offsetX"}]),Ea([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Ea([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Ff=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(Ff.isParsed())throw 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}async syncState(t,e){if(this.isParsed())return this.getState();if("loading"!==t.pluginStatus)return this.setState(t),t;let i=t.pluginURL,r=new Promise((t=>{this.loadScriptResolve=t})),n=new Promise((t=>setTimeout((()=>t()),this.TIMEOUT)));if(await e(i),await Promise.race([r,n]),this.isParsed()){let t={pluginStatus:"loaded",pluginURL:i};return this.setState(t),t}throw this.setState({pluginStatus:"error",pluginURL:""}),Error(`RTL Text Plugin failed to import scripts from ${i}`)}};function Sf(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 Cf(t){return/[\u02EA\u02EB\u1100-\u11FF\u1401-\u167F\u18B0-\u18FF\u2065\u20DD-\u20E0\u20E2-\u20E4\u2B97\u2BF0-\u2BFF\u2E50\u2E51\u2E80-\u3007\u3012\u3013\u3020-\u302F\u3031-\u30FB\u30FD-\uA4CF\uA960-\uA97F\uAC00-\uD7FF\uF900-\uFAFF\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\uFFF0-\uFFF8]|\uD802[\uDD80-\uDD9F]|\uD805[\uDD80-\uDDFF]|\uD806[\uDE00-\uDEBF]|[\uD80C-\uD810\uD81C-\uD822\uD83C\uD83D\uD840-\uD87E\uD880-\uD8BE][\uDC00-\uDFFF]|\uD811[\uDC00-\uDE7F]|\uD81B[\uDFE0-\uDFFF]|\uD823[\uDC00-\uDDFF]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFF]|\uD833[\uDEC0-\uDFCF]|\uD834[\uDC00-\uDDFF\uDEE0-\uDF7F]|\uD836[\uDC00-\uDEAF]|\uD83E[\uDD00-\uDEFF]|[\uD87F\uD8BF][\uDC00-\uDFFD]/gim.test(String.fromCodePoint(t))}function zf(t){return/[\u0E01-\u0E3A\u0E40-\u0E4E\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECE\u0EDC-\u0EDF\u0F00-\u0F47\u0F49-\u0F6C\u0F71-\u0F97\u0F99-\u0FBC\u0FBE-\u0FCC\u0FCE-\u0FD4\u0FD9\u0FDA\u1000-\u103F\u1050-\u108F\u109A-\u109F\u1780-\u17D3\u17D7\u17DC\u17DD\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19DE\u19DF\u1A20-\u1A5E\u1A60-\u1A7C\u1AA0-\u1AAD\u1B00-\u1B4C\u1B4E-\u1B7F\uA980-\uA9CD\uA9D0-\uA9D9\uA9DE-\uA9EF\uA9FA-\uA9FE\uAA60-\uAAC2\uAADB-\uAADF]|\uD805[\uDF00-\uDF1A\uDF1D-\uDF2B\uDF3A\uDF3B\uDF3F-\uDF46]/gim.test(String.fromCodePoint(t))}function Tf(t,e){return/(?:[\u1039\u17D2\u1A60\u1BAB\u200D\uAAF6]|\uD802\uDE3F|\uD804[\uDD33\uDFD0]|\uD806[\uDD3E\uDE47\uDE99]|\uD807[\uDD45\uDD97\uDF42])$/.test(t)||/^\p{gc=Mc}/u.test(e)}const Pf={C:"18g,1;g2,3;4nb,1",D:"17k,1;5,1;1,1;1,5;4,d;1,7;1,2;z,2;8,g;i,12;1,2;9,1;1,1;1,2;14,3;2,1;28,9;3,f;2,4;1,1;2,3;2,6;7a,1;2,5;1,1;g,a;5,2;2,6;1,f",R:"17m,4;1,1;1,1;5,4;l,1;14,3;1,3;g,i;12,1;2,9;1,1;1,1;2,2;1,1;o,2;2x,3;f,2;4,1;1,2;3,2;6u,j;b,1;r,3;1,1;2,2;6,1",T:"174,b;1,1;1a,l;g,1;2t,7;2,6;2,2;1,4;bt,9;16,o;1,t;1clb,1"},If={1569:[65152,0,0,0],1570:[65153,65154,0,0],1571:[65155,65156,0,0],1572:[65157,65158,0,0],1573:[65159,65160,0,0],1574:[65161,65162,65163,65164],1575:[65165,65166,0,0],1576:[65167,65168,65169,65170],1577:[65171,65172,0,0],1578:[65173,65174,65175,65176],1579:[65177,65178,65179,65180],1580:[65181,65182,65183,65184],1581:[65185,65186,65187,65188],1582:[65189,65190,65191,65192],1583:[65193,65194,0,0],1584:[65195,65196,0,0],1585:[65197,65198,0,0],1586:[65199,65200,0,0],1587:[65201,65202,65203,65204],1588:[65205,65206,65207,65208],1589:[65209,65210,65211,65212],1590:[65213,65214,65215,65216],1591:[65217,65218,65219,65220],1592:[65221,65222,65223,65224],1593:[65225,65226,65227,65228],1594:[65229,65230,65231,65232],1601:[65233,65234,65235,65236],1602:[65237,65238,65239,65240],1603:[65241,65242,65243,65244],1604:[65245,65246,65247,65248],1605:[65249,65250,65251,65252],1606:[65253,65254,65255,65256],1607:[65257,65258,65259,65260],1608:[65261,65262,0,0],1609:[65263,65264,64488,64489],1610:[65265,65266,65267,65268],1611:[65136,0,0,65137],1612:[65138,0,0,0],1613:[65140,0,0,0],1614:[65142,0,0,65143],1615:[65144,0,0,65145],1616:[65146,0,0,65147],1617:[65148,0,0,65149],1618:[65150,0,0,65151],1649:[64336,64337,0,0],1655:[64477,0,0,0],1657:[64358,64359,64360,64361],1658:[64350,64351,64352,64353],1659:[64338,64339,64340,64341],1662:[64342,64343,64344,64345],1663:[64354,64355,64356,64357],1664:[64346,64347,64348,64349],1667:[64374,64375,64376,64377],1668:[64370,64371,64372,64373],1670:[64378,64379,64380,64381],1671:[64382,64383,64384,64385],1672:[64392,64393,0,0],1676:[64388,64389,0,0],1677:[64386,64387,0,0],1678:[64390,64391,0,0],1681:[64396,64397,0,0],1688:[64394,64395,0,0],1700:[64362,64363,64364,64365],1702:[64366,64367,64368,64369],1705:[64398,64399,64400,64401],1709:[64467,64468,64469,64470],1711:[64402,64403,64404,64405],1713:[64410,64411,64412,64413],1715:[64406,64407,64408,64409],1722:[64414,64415,0,0],1723:[64416,64417,64418,64419],1726:[64426,64427,64428,64429],1728:[64420,64421,0,0],1729:[64422,64423,64424,64425],1733:[64480,64481,0,0],1734:[64473,64474,0,0],1735:[64471,64472,0,0],1736:[64475,64476,0,0],1737:[64482,64483,0,0],1739:[64478,64479,0,0],1740:[64508,64509,64510,64511],1744:[64484,64485,64486,64487],1746:[64430,64431,0,0],1747:[64432,64433,0,0]},kf={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},$f=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function jf(t,e,i){let r=0;for(let n of t.split(";")){let[t,s]=n.split(",").map((t=>parseInt(t,36))),o=r+t;for(let t=o;t<o+s;t++)i.set(t,e);r=o+s}}const Rf=new Map;for(let[t,e]of Object.entries(Pf))jf(e,t,Rf);function Of(t){return Rf.get(t)??"U"}function Bf(t){return"D"===t||"L"===t||"C"===t}function Lf(t){return"D"===t||"R"===t||"C"===t}function Uf(t,e,i){return"D"===t?e&&i?3:e?1:i?2:0:"R"===t?+!!e:"L"===t?i?2:0:null}function Nf(t){if(!$f.test(t))return t;let e=function(t){return[...t].map((t=>{let e=t.codePointAt(0);return{codePoint:e,type:Of(e),form:null}}))}(t);return function(t){let e=t.filter((t=>"T"!==t.type));for(let t=0;t<e.length;t++){let i=e[t],r=t>0&&Bf(e[t-1].type),n=t+1<e.length&&Lf(e[t+1].type);i.form=Uf(i.type,r,n)}}(e),function(t){let e=!1;for(let i of t)"T"===i.type?i.form=e?3:0:e=2===i.form||3===i.form}(e),function(t){let e=[];for(let i=0;i<t.length;i++){let r=t[i];if(1604!==r.codePoint){e.push(r);continue}let n=i+1;for(;n<t.length&&"T"===t[n].type;)n++;let s=t[n],o=s&&kf[String.fromCodePoint(1604,s.codePoint)];o?(e.push({codePoint:o[+!(3!==r.form&&1!==r.form)],type:"R",form:0}),e.push(...t.slice(i+1,n)),i=n):e.push(r)}return e}(e).map((t=>String.fromCodePoint(function(t){if(null===t.form)return t.codePoint;let e=If[t.codePoint];return e&&(e[t.form]||e[0])||t.codePoint}(t)))).join("")}function Gf(t,e,i){let r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),(Ff.applyArabicShaping??Nf)(t)}function qf(t,e,i){for(let r of t.sections)r.text=Gf(r.text,e,i);return t}function Vf(t,e,i){let r=i?e.last.points:e.first.points,n=i?r[r.length-1]:r[0];return`${t}:${n.x}:${n.y}`}function Zf(t){let e=t.first.points,i=e.length;for(let e=t.first.next;e;e=e.next)i+=e.points.length-1;let r=Array(i);for(let t=0;t<e.length;t++)r[t]=e[t];let n=e.length;for(let e=t.first.next;e;e=e.next){let t=e.points;for(let e=1;e<t.length;e++)r[n++]=t[e]}return r}function Wf(t,e,i,r,n){let s=e[i];delete e[i],e[r]=s;let o=t[s];return o.last.next=n.first,o.last=n.last,s}function Hf(t,e,i,r,n){let s=e[r];delete e[r],e[i]=s;let o=t[s];return n.last.next=o.first,o.first=n.first,s}const Yf=typeof Intl<"u"&&"Segmenter"in Intl;let Xf,Jf;function Kf(t){if(!Yf||!function(t){return/[\r\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0600-\u0605\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DD\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u070F\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0890\u0891\u0897-\u089F\u08CA-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D62\u0D63\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E33-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB3-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1037\u1039-\u103E\u1056-\u1059\u105E-\u1060\u1071-\u1074\u1082\u1084-\u1086\u108D\u109D\u1100-\u11FF\u135D-\u135F\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60\u1A62\u1A65-\u1A7C\u1A7F\u1AB0-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA960-\uA97C\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDD69-\uDD6D\uDEAB\uDEAC\uDEFA-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC00-\uDC02\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC82\uDCB0-\uDCBA\uDCBD\uDCC2\uDCCD\uDD00-\uDD02\uDD27-\uDD34\uDD45\uDD46\uDD73\uDD80-\uDD82\uDDB3-\uDDC0\uDDC2\uDDC3\uDDC9-\uDDCC\uDDCE\uDDCF\uDE2C-\uDE37\uDE3E\uDE41\uDEDF-\uDEEA\uDF00-\uDF03\uDF3B\uDF3C\uDF3E-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF57\uDF62\uDF63\uDF66-\uDF6C\uDF70-\uDF74\uDFB8-\uDFC0\uDFC2\uDFC5\uDFC7-\uDFCA\uDFCC-\uDFD2\uDFE1\uDFE2]|\uD805[\uDC35-\uDC46\uDC5E\uDCB0-\uDCC3\uDDAF-\uDDB5\uDDB8-\uDDC0\uDDDC\uDDDD\uDE30-\uDE40\uDEAB-\uDEB7\uDF1D-\uDF1F\uDF22-\uDF2B]|\uD806[\uDC2C-\uDC3A\uDD30-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDDD1-\uDDD7\uDDDA-\uDDE0\uDDE4\uDE01-\uDE0A\uDE33-\uDE39\uDE3B-\uDE3E\uDE47\uDE51-\uDE5B\uDE84-\uDE99\uDF60-\uDF67]|\uD807[\uDC2F-\uDC36\uDC38-\uDC3F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD8A-\uDD8E\uDD90\uDD91\uDD93-\uDD97\uDEF3-\uDEF6\uDF00-\uDF03\uDF34-\uDF3A\uDF3E-\uDF42\uDF5A]|\uD80D[\uDC40\uDC47-\uDC55]|\uD818[\uDD1E-\uDD2F]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDD63\uDD67-\uDD6A\uDF4F\uDF51-\uDF87\uDF8F-\uDF92\uDFE4\uDFF0\uDFF1]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF\uDDEE\uDDEF\uDEE3\uDEE6\uDEEE\uDEEF\uDEF5]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDDE6-\uDDFF\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF]/.test(t)}(t))return[...t];Xf??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let e=[];for(let{segment:i}of Xf.segment(t)){let t=e.length-1;t>=0&&Tf(e[t],i)?e[t]+=i:e.push(i)}return e}function Qf(t){let e=new Set;if(Yf){Jf??=new Intl.Segmenter(void 0,{granularity:"word"});for(let{index:i}of Jf.segment(t))e.add(i);return e}let i=0;for(let r of t.split(/\b|(?=\p{Ideo})/u))e.add(i),i+=r.length;return e}function tp(t){let e=t.codePointAt(0);return t.length>(e>65535?2:1)}function ep(t){return/\s/u.test(String.fromCodePoint(t))}function ip(t){for(let e of t)if(Cf(e.codePointAt(0)))return!0;return!1}function rp(t){for(let e of t)if(!np(e.codePointAt(0)))return!1;return!0}function np(t){return!function(t){return/[\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u077F\u07C0-\u07FA\u07FD-\u07FF\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\u1800\u1801\u1804\u1806-\u1819\u1820-\u1878\u1880-\u18AA\uA840-\uA877\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF80-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDD00-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDEFF\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB]|\uD805[\uDE60-\uDE6C]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9C-\uDC9F]|\uD83A[\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(t))}(t)}function sp(t){return!(Cf(t)||function(t){return/[\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(t))}(t))}function op(t){return/\p{sc=Arab}/u.test(String.fromCodePoint(t))}function ap(t){return function(t){return/[\u0591-\u05C7\u05D0-\u05EA\u05EF-\u05F4\u0600-\u0604\u0606-\u060B\u060D-\u061A\u061C-\u061E\u0620-\u063F\u0641-\u064A\u0656-\u066F\u0671-\u06DC\u06DE-\u070D\u070F-\u074A\u074D-\u07B1\u07C0-\u07FA\u07FD-\u082D\u0830-\u083E\u0840-\u085B\u085E\u0860-\u086A\u0870-\u0891\u0897-\u08E1\u08E3-\u08FF\uFB1D-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFF\uFE70-\uFE74\uFE76-\uFEFC]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC57-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD1F-\uDD39\uDD3F-\uDD59\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE50-\uDE58\uDE60-\uDE9F\uDEC0-\uDEE6\uDEEB-\uDEF6\uDF00-\uDF35\uDF39-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDF99-\uDF9C\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDD40-\uDD65\uDD69-\uDD85\uDD8E\uDD8F\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB-\uDEAD\uDEB0\uDEB1\uDEC2-\uDEC7\uDED0-\uDED8\uDEFA-\uDF27\uDF30-\uDF59\uDF70-\uDF89\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59\uDD5E\uDD5F]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB\uDEF0\uDEF1]/gim.test(String.fromCodePoint(t))}(t)}function lp(t){for(let e of t)if(ap(e.codePointAt(0)))return!0;return!1}const hp={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},up={10:!0,13:!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},cp={40:!0};function fp(t,e,i,r,n,s){if("fontStack"in e){let r=i[e.fontStack]?.default,s=r?.[t];if(s)return s.metrics.advance*e.scale+n;let o=0;for(let i of t){let t=r?.[i];t&&(o+=t.metrics.advance*e.scale+n)}return o}{let t=r[e.imageName];return t?t.displaySize[0]*e.scale*24/s+n:0}}function pp(t,e,i,r){let n=(t-e)**2;return r?t<e?n/2:2*n:n+Math.abs(i)*i}function dp(t){return/^\s+$/u.test(t)}function mp(t,e,i){let r=0;return(10===t||13===t)&&(r-=1e4),i&&(r+=150),(40===t||65288===t)&&(r+=50),(41===e||65289===e)&&(r+=50),r}function _p(t,e,i,r,n,s){let o=null,a=pp(e,i,n,s);for(let t of r){let r=pp(e-t.x,i,n,s)+t.badness;r<=a&&(o=t,a=r)}return{index:t,x:e,priorBreak:o,badness:a}}function gp(t){return t?gp(t.priorBreak).concat(t.index):[]}var yp=class t{constructor(t="",e=[],i=[]){this.text=t,this.sections=e,this.sectionIndex=i,this.imageSectionID=null,this._graphemes=null}graphemes(){return this._graphemes??=Kf(this.text),this._graphemes}static fromFeature(e,i){let r=new t;for(let t of e.sections)t.image?r.addImageSection(t):r.addTextSection(t,i);return r}length(){return this.graphemes().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},r=t[Symbol.iterator](),n=r.next(),s=t[Symbol.iterator]();s.next();let o=s.next();for(;!n.done;)!o.done&&sp(o.value.codePointAt(0))&&!hp[o.value]||!i.premature&&sp(i.value.codePointAt(0))&&!hp[i.value]||!hp[n.value]?e+=n.value:e+=hp[n.value],i={value:n.value,premature:!1},n=r.next(),o=s.next();return e}(this.text),this._graphemes=null}hasZeroWidthSpaces(){return this.text.includes("​")}trim(){let t=this.graphemes(),e=0;for(;e<t.length&&dp(t[e]);)e++;let i=t.length;for(;i>e&&dp(t[i-1]);)i--;this.text=t.slice(e,i).join(""),this.sectionIndex=this.sectionIndex.slice(e,i),this._graphemes=null}substring(e,i){let r=this.graphemes().slice(e,i).join(""),n=this.sectionIndex.slice(e,i);return new t(r,this.sections,n)}toCodeUnitIndex(t){return this.graphemes().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 r=0;r<this.length();r++){let n=this.getSection(r);if("imageName"in n){let r=t[n.imageName];if(!r)continue;let s=r.displaySize;e=Math.max(e,s[0]),i=Math.max(i,s[1])}}return{maxImageWidth:e,maxImageHeight:i}}_appendSection(t,e){let i=this.graphemes(),r=i.length>0?i[i.length-1]:"",n=Kf(r+t);this.text+=t,this._graphemes=i.slice(0,r?-1:void 0).concat(n);let s=n.length-+!!r;for(let t=0;t<s;t++)this.sectionIndex.push(e)}addTextSection(t,e){this.sections.push({scale:t.scale||1,verticalAlign:t.verticalAlign||"bottom",fontStack:t.fontStack||e}),this._appendSection(t.text,this.sections.length-1)}addImageSection(t){let e=t.image?t.image.name:"";if(0===e.length)return void Lt("Can't add FormattedSection with an empty image.");let i=this.getNextImageSectionCharCode();i?(this.sections.push({scale:1,verticalAlign:t.verticalAlign||"bottom",imageName:e}),this._appendSection(String.fromCharCode(i),this.sections.length-1)):Lt("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,r,n){let s=this.determineTotalWidth(t,i,r,n);if(t>=0&&s>0&&s<=e&&!/[\n\r]/.test(this.text))return[this.length()];let o=[],a=s/Math.max(1,Math.ceil(s/e)),l=this.hasZeroWidthSpaces(),h=this.graphemes(),u=null,c=0,f=0;for(let e=0;e<h.length;e++){let s=h[e];if(e>0){let t=h[e-1].codePointAt(0),i=s.codePointAt(0),r=Sf(t),n=zf(t)&&zf(i);(up[t]||r||"imageName"in this.getSection(e-1)||void 0!==h[e+1]&&cp[i]||n&&(u??=Qf(this.text)).has(f))&&o.push(_p(e,c,a,o,mp(t,i,r&&l),!1))}ep(s.codePointAt(0))||(c+=fp(s,this.getSection(e),i,r,t,n)),f+=s.length}return gp(_p(this.length(),c,a,o,0,!0))}determineTotalWidth(t,e,i,r){let n=0,s=0;for(let o of this.graphemes())n+=fp(o,this.getSection(s),e,i,t,r),s++;return n}};const vp=function(t){var e={R:"13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",EN:"1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",ES:"17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",ET:"z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",AN:"16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",CS:"18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",B:"a,3,f+2,2v,690",S:"9,2,k",WS:"c,k,4f4,1vk+a,u,1j,335",ON:"x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",BN:"0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",NSM:"lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",AL:"16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",LRO:"6ct",RLO:"6cu",LRE:"6cq",RLE:"6cr",PDF:"6cs",LRI:"6ee",RLI:"6ef",FSI:"6eg",PDI:"6eh"},i={},r={};i.L=1,r[1]="L",Object.keys(e).forEach((function(t,e){i[t]=1<<e+1,r[i[t]]=t})),Object.freeze(i);var n=i.LRI|i.RLI|i.FSI,s=i.L|i.R|i.AL,o=i.B|i.S|i.WS|i.ON|i.FSI|i.LRI|i.RLI|i.PDI,a=i.BN|i.RLE|i.LRE|i.RLO|i.LRO|i.PDF,l=i.S|i.WS|i.B|n|i.PDI|a,h=null;function u(t){return function(){if(!h){h=new Map;var t=0;for(var r in e)if(e.hasOwnProperty(r))for(var n=e[r],s="",o=void 0,a=!1,l=0,u=0;u<=n.length+1;u+=1){var c=n[u];if(","!==c&&u!==n.length)"+"===c?(a=!0,l=t=l+parseInt(s,36),s=""):s+=c;else{a?o=t+parseInt(s,36):(l=t=l+parseInt(s,36),o=t),a=!1,s="",l=o;for(var f=t;f<o+1;f+=1)h.set(f,i[r])}}}}(),h.get(t.codePointAt(0))||i.L}var c,f,p,d="14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",m="6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye";function _(t,e){var i,r=0,n=new Map,s=e&&new Map;return t.split(",").forEach((function t(o){if(-1!==o.indexOf("+"))for(var a=+o;a--;)t(i);else{i=o;var l=o.split(">"),h=l[0],u=l[1];h=String.fromCodePoint(r+=parseInt(h,36)),u=String.fromCodePoint(r+=parseInt(u,36)),n.set(h,u),e&&s.set(u,h)}})),{map:n,reverseMap:s}}function g(){if(!c){var t=_(d,!0);c=t.map,f=t.reverseMap,p=_(m,!1).map}}function y(t){return g(),c.get(t)||null}function v(t){return g(),f.get(t)||null}function w(t){return g(),p.get(t)||null}var b,x=i.L,D=i.R,M=i.EN,E=i.ES,A=i.ET,F=i.AN,S=i.CS,C=i.B,z=i.S,T=i.ON,P=i.BN,I=i.NSM,k=i.AL,$=i.LRO,j=i.RLO,R=i.LRE,O=i.RLE,B=i.PDF,L=i.LRI,U=i.RLI,N=i.FSI,G=i.PDI;function q(t){return function(){if(!b){var t=_("14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1",!0),e=t.map;t.reverseMap.forEach((function(t,i){e.set(i,t)})),b=e}}(),b.get(t)||null}function V(t,e,i,r){var n=t.length;i=Math.max(0,null==i?0:+i),r=Math.min(n-1,null==r?n-1:+r);var s=[];return e.paragraphs.forEach((function(n){var o=Math.max(i,n.start),a=Math.min(r,n.end);if(o<a){for(var h=e.levels.slice(o,a+1),c=a;c>=o&&u(t[c])&l;c--)h[c]=n.level;for(var f=n.level,p=1/0,d=0;d<h.length;d++){var m=h[d];m>f&&(f=m),m<p&&(p=1|m)}for(var _=f;_>=p;_--)for(var g=0;g<h.length;g++)if(h[g]>=_){for(var y=g;g+1<h.length&&h[g+1]>=_;)g++;g>y&&s.push([y+o,g+o])}}})),s}function Z(t,e,i,r){for(var n=V(t,e,i,r),s=[],o=0;o<t.length;o++)s[o]=o;return n.forEach((function(t){for(var e=t[1],i=s.slice(t[0],e+1),r=i.length;r--;)s[e-r]=i[r]})),s}return t.closingToOpeningBracket=v,t.getBidiCharType=u,t.getBidiCharTypeName=function(t){return r[u(t)]},t.getCanonicalBracket=w,t.getEmbeddingLevels=function(t,e){for(var i=new Uint32Array(t.length),r=0;r<t.length;r++)i[r]=u(t[r]);var h=new Map;function c(t,e){var r=i[t];i[t]=e,h.set(r,h.get(r)-1),r&o&&h.set(o,h.get(o)-1),h.set(e,(h.get(e)||0)+1),e&o&&h.set(o,(h.get(o)||0)+1)}for(var f=new Uint8Array(t.length),p=new Map,d=[],m=null,_=0;_<t.length;_++)m||d.push(m={start:_,end:t.length-1,level:"rtl"===e?1:"ltr"===e?0:Be(_,!1)}),i[_]&C&&(m.end=_,m=null);for(var g=O|R|j|$|n|G|B|C,b=function(t){return t+(1&t?1:2)},q=function(t){return t+(1&t?2:1)},V=0;V<d.length;V++){var Z=[{_level:(m=d[V]).level,_override:0,_isolate:0}],W=void 0,H=0,Y=0,X=0;h.clear();for(var J=m.start;J<=m.end;J++){var K=i[J];if(W=Z[Z.length-1],h.set(K,(h.get(K)||0)+1),K&o&&h.set(o,(h.get(o)||0)+1),K&g)if(K&(O|R)){f[J]=W._level;var Q=(K===O?q:b)(W._level);Q<=125&&!H&&!Y?Z.push({_level:Q,_override:0,_isolate:0}):H||Y++}else if(K&(j|$)){f[J]=W._level;var tt=(K===j?q:b)(W._level);tt<=125&&!H&&!Y?Z.push({_level:tt,_override:K&j?D:x,_isolate:0}):H||Y++}else if(K&n){K&N&&(K=1===Be(J+1,!0)?U:L),f[J]=W._level,W._override&&c(J,W._override);var et=(K===U?q:b)(W._level);et<=125&&0===H&&0===Y?(X++,Z.push({_level:et,_override:0,_isolate:1,_isolInitIndex:J})):H++}else if(K&G){if(H>0)H--;else if(X>0){for(Y=0;!Z[Z.length-1]._isolate;)Z.pop();var it=Z[Z.length-1]._isolInitIndex;null!=it&&(p.set(it,J),p.set(J,it)),Z.pop(),X--}f[J]=(W=Z[Z.length-1])._level,W._override&&c(J,W._override)}else K&B?(0===H&&(Y>0?Y--:!W._isolate&&Z.length>1&&(Z.pop(),W=Z[Z.length-1])),f[J]=W._level):K&C&&(f[J]=m.level);else f[J]=W._level,W._override&&K!==P&&c(J,W._override)}for(var rt=[],nt=null,st=m.start;st<=m.end;st++){var ot=i[st];if(!(ot&a)){var at=f[st],lt=ot&n,ht=ot===G;nt&&at===nt._level?(nt._end=st,nt._endsWithIsolInit=lt):rt.push(nt={_start:st,_end:st,_level:at,_startsWithPDI:ht,_endsWithIsolInit:lt})}}for(var ut=[],ct=0;ct<rt.length;ct++){var ft=rt[ct];if(!ft._startsWithPDI||ft._startsWithPDI&&!p.has(ft._start)){for(var pt=[nt=ft],dt=void 0;nt&&nt._endsWithIsolInit&&null!=(dt=p.get(nt._end));)for(var mt=ct+1;mt<rt.length;mt++)if(rt[mt]._start===dt){pt.push(nt=rt[mt]);break}for(var _t=[],gt=0;gt<pt.length;gt++)for(var yt=pt[gt],vt=yt._start;vt<=yt._end;vt++)_t.push(vt);for(var wt=f[_t[0]],bt=m.level,xt=_t[0]-1;xt>=0;xt--)if(!(i[xt]&a)){bt=f[xt];break}var Dt=_t[_t.length-1],Mt=f[Dt],Et=m.level;if(!(i[Dt]&n))for(var At=Dt+1;At<=m.end;At++)if(!(i[At]&a)){Et=f[At];break}ut.push({_seqIndices:_t,_sosType:Math.max(bt,wt)%2?D:x,_eosType:Math.max(Et,Mt)%2?D:x})}}for(var Ft=0;Ft<ut.length;Ft++){var St=ut[Ft],Ct=St._seqIndices,zt=St._sosType,Tt=St._eosType,Pt=1&f[Ct[0]]?D:x;if(h.get(I))for(var It=0;It<Ct.length;It++){var kt=Ct[It];if(i[kt]&I){for(var $t=zt,jt=It-1;jt>=0;jt--)if(!(i[Ct[jt]]&a)){$t=i[Ct[jt]];break}c(kt,$t&(n|G)?T:$t)}}if(h.get(M))for(var Rt=0;Rt<Ct.length;Rt++){var Ot=Ct[Rt];if(i[Ot]&M)for(var Bt=Rt-1;Bt>=-1;Bt--){var Lt=-1===Bt?zt:i[Ct[Bt]];if(Lt&s){Lt===k&&c(Ot,F);break}}}if(h.get(k))for(var Ut=0;Ut<Ct.length;Ut++){var Nt=Ct[Ut];i[Nt]&k&&c(Nt,D)}if(h.get(E)||h.get(S))for(var Gt=1;Gt<Ct.length-1;Gt++){var qt=Ct[Gt];if(i[qt]&(E|S)){for(var Vt=0,Zt=0,Wt=Gt-1;Wt>=0&&(Vt=i[Ct[Wt]])&a;Wt--);for(var Ht=Gt+1;Ht<Ct.length&&(Zt=i[Ct[Ht]])&a;Ht++);Vt===Zt&&(i[qt]===E?Vt===M:Vt&(M|F))&&c(qt,Vt)}}if(h.get(M))for(var Yt=0;Yt<Ct.length;Yt++)if(i[Ct[Yt]]&M){for(var Xt=Yt-1;Xt>=0&&i[Ct[Xt]]&(A|a);Xt--)c(Ct[Xt],M);for(Yt++;Yt<Ct.length&&i[Ct[Yt]]&(A|a|M);Yt++)i[Ct[Yt]]!==M&&c(Ct[Yt],M)}if(h.get(A)||h.get(E)||h.get(S))for(var Jt=0;Jt<Ct.length;Jt++){var Kt=Ct[Jt];if(i[Kt]&(A|E|S)){c(Kt,T);for(var Qt=Jt-1;Qt>=0&&i[Ct[Qt]]&a;Qt--)c(Ct[Qt],T);for(var te=Jt+1;te<Ct.length&&i[Ct[te]]&a;te++)c(Ct[te],T)}}if(h.get(M))for(var ee=0,ie=zt;ee<Ct.length;ee++){var re=Ct[ee],ne=i[re];ne&M?ie===x&&c(re,x):ne&s&&(ie=ne)}if(h.get(o)){for(var se=D|M|F,oe=se|x,ae=[],le=[],he=0;he<Ct.length;he++)if(i[Ct[he]]&o){var ue=t[Ct[he]],ce=void 0;if(null!==y(ue)){if(!(le.length<63))break;le.push({char:ue,seqIndex:he})}else if(null!==(ce=v(ue)))for(var fe=le.length-1;fe>=0;fe--){var pe=le[fe].char;if(pe===ce||pe===v(w(ue))||y(w(pe))===ue){ae.push([le[fe].seqIndex,he]),le.length=fe;break}}}ae.sort((function(t,e){return t[0]-e[0]}));for(var de=0;de<ae.length;de++){for(var me=ae[de],_e=me[0],ge=me[1],ye=!1,ve=0,we=_e+1;we<ge;we++){var be=Ct[we];if(i[be]&oe){ye=!0;var xe=i[be]&se?D:x;if(xe===Pt){ve=xe;break}}}if(ye&&!ve){ve=zt;for(var De=_e-1;De>=0;De--){var Me=Ct[De];if(i[Me]&oe){var Ee=i[Me]&se?D:x;ve=Ee===Pt?Pt:Ee;break}}}if(ve){if(i[Ct[_e]]=i[Ct[ge]]=ve,ve!==Pt)for(var Ae=_e+1;Ae<Ct.length;Ae++)if(!(i[Ct[Ae]]&a)){u(t[Ct[Ae]])&I&&(i[Ct[Ae]]=ve);break}if(ve!==Pt)for(var Fe=ge+1;Fe<Ct.length;Fe++)if(!(i[Ct[Fe]]&a)){u(t[Ct[Fe]])&I&&(i[Ct[Fe]]=ve);break}}}for(var Se=0;Se<Ct.length;Se++)if(i[Ct[Se]]&o){for(var Ce=Se,ze=Se,Te=zt,Pe=Se-1;Pe>=0;Pe--){if(!(i[Ct[Pe]]&a)){Te=i[Ct[Pe]]&se?D:x;break}Ce=Pe}for(var Ie=Tt,ke=Se+1;ke<Ct.length;ke++){if(!(i[Ct[ke]]&(o|a))){Ie=i[Ct[ke]]&se?D:x;break}ze=ke}for(var $e=Ce;$e<=ze;$e++)i[Ct[$e]]=Te===Ie?Te:Pt;Se=ze}}}for(var je=m.start;je<=m.end;je++){var Re=i[je];if(1&f[je]?Re&(x|M|F)&&f[je]++:Re&D?f[je]++:Re&(F|M)&&(f[je]+=2),Re&a&&(f[je]=0===je?m.level:f[je-1]),je===m.end||u(t[je])&(z|C))for(var Oe=je;Oe>=0&&u(t[Oe])&l;Oe--)f[Oe]=m.level}}return{levels:f,paragraphs:d};function Be(e,r){for(var s=e;s<t.length;s++){var o=i[s];if(o&(D|k))return 1;if(o&(C|x)||r&&o===G)return 0;if(o&n){var a=Le(s);s=-1===a?t.length:a}}return 0}function Le(e){for(var r=1,s=e+1;s<t.length;s++){var o=i[s];if(o&C)break;if(o&G){if(0==--r)return s}else o&n&&r++}return-1}},t.getMirroredCharacter=q,t.getMirroredCharactersMap=function(t,e,i,r){var n=t.length;i=Math.max(0,null==i?0:+i),r=Math.min(n-1,null==r?n-1:+r);for(var s=new Map,o=i;o<=r;o++)if(1&e[o]){var a=q(t[o]);null!==a&&s.set(o,a)}return s},t.getReorderSegments=V,t.getReorderedIndices=Z,t.getReorderedString=function(t,e,i,r){var n=Z(t,e,i,r),s=[].concat(t);return n.forEach((function(i,r){s[r]=(1&e.levels[i]?q(t[i]):null)||t[i]})),s.join("")},t.openingToClosingBracket=y,Object.defineProperty(t,"__esModule",{value:!0}),t}({}),wp=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,bp=new Set(["WS","FSI","LRI","RLI","PDI"]),xp=new Set(["S","B"]);function Dp(t){return t.level%2==0?t.text:vp.getMirroredCharacter(t.text)??t.text}function Mp(t,e){let{levels:i,paragraphs:r}=vp.getEmbeddingLevels(t);return function(t,e){let i=e.filter((e=>e>0&&e<t.length)),r=[...new Set([0,...i,t.length])].sort(((t,e)=>t-e)),n=[];for(let t=0;t+1<r.length;t++)n.push([r[t],r[t+1]]);return n}(t,e.concat(r.map((t=>t.start)))).map((([e,n])=>function(t,e,i,r,n){let s=function(t,e,i,r){let n=[],s=i;for(let o of Kf(t.slice(i,r)))n.push({index:s,text:o,level:e[s]}),s+=o.length;return n}(t,e,r,n);!function(t,e){let i=!0;for(let r=t.length-1;r>=0;r--){let n=vp.getBidiCharTypeName(t[r].text[0]);xp.has(n)?(t[r].level=e,i=!0):i&&bp.has(n)?t[r].level=e:i=!1}}(s,i);let o="",a=[];for(let t of function(t,e){let i=e,r=1/0;for(let{level:e}of t)e>i&&(i=e),(1|e)<r&&(r=1|e);let n=t.slice();for(let t=i;t>=r;t--)for(let e=0;e<n.length;e++){if(n[e].level<t)continue;let i=e;for(;i+1<n.length&&n[i+1].level>=t;)i++;for(let t=e,r=i;t<r;t++,r--)[n[t],n[r]]=[n[r],n[t]];e=i}return n}(s,i)){if(wp.test(t.text))continue;let e=Dp(t);o+=e,a.push(...Array(e.length).fill(t.index))}return{text:o,sourceIndices:a}}(t,i,function(t,e){return t.find((t=>e>=t.start&&e<=t.end))?.level??0}(r,e),e,n)))}const Ep=4294967296,Ap=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var Fp=class{constructor(t){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength),this.pos=0,this.type=0,this._valueStart=-1,this.length=this.buf.length}readFields(t,e,i=this.length){let r;for(;r=this.nextField(i);)t(r,e,this);return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){let t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){let t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Ep;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Ep;return this.pos+=8,t}readFloat(){let t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){let t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){let e=this.buf,i=e[this.pos++];if(i<128)return i;let r,n=127&i;return r=e[this.pos++],n|=(127&r)<<7,r<128||(r=e[this.pos++],n|=(127&r)<<14,r<128)||(r=e[this.pos++],n|=(127&r)<<21,r<128)?n:(r=e[this.pos],n|=(15&r)<<28,function(t,e,i){let r,n,s=i.buf;if(n=s[i.pos++],r=(112&n)>>4,n<128||(n=s[i.pos++],r|=(127&n)<<3,n<128)||(n=s[i.pos++],r|=(127&n)<<10,n<128)||(n=s[i.pos++],r|=(127&n)<<17,n<128)||(n=s[i.pos++],r|=(127&n)<<24,n<128)||(n=s[i.pos++],r|=(1&n)<<31,n<128))return function(t,e,i){return i?4294967296*e+(t>>>0):4294967296*(e>>>0)+(t>>>0)}(t,r,e);throw Error("Expected varint not more than 10 bytes")}(n,t,this))}readSVarint(){let t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return!!this.readVarint()}readString(){let t=this.readVarint()+this.pos,e=this.pos;return this.pos=t,t-e>=12&&Ap?Ap.decode(this.buf.subarray(e,t)):function(t,e,i){let r="",n=e;for(;n<i;){let e,s,o,a=t[n],l=null,h=a>239?4:a>223?3:a>191?2:1;if(n+h>i)break;1===h?a<128&&(l=a):2===h?(e=t[n+1],128==(192&e)&&(l=(31&a)<<6|63&e,l<=127&&(l=null))):3===h?(e=t[n+1],s=t[n+2],128==(192&e)&&128==(192&s)&&(l=(15&a)<<12|(63&e)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(e=t[n+1],s=t[n+2],o=t[n+3],128==(192&e)&&128==(192&s)&&128==(192&o)&&(l=(15&a)<<18|(63&e)<<12|(63&s)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=h}return r}(this.buf,e,t)}readBytes(){let t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){let i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readVarint(e));return t}readPackedSVarint(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFloat());return t}readPackedDouble(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){let e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){let 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}nextField(t=this.length){if(this.pos===this._valueStart&&this.skip(this.type),this.pos>=t)return 0;let e=this.readVarint();return this.type=7&e,this._valueStart=this.pos,e>>>3}skip(t){let 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 Error(`Unimplemented type: ${e}`);this.pos+=8}}};function Sp(t,e,i){1===t&&i.readMessage(Cp,e)}function Cp(t,e,i){if(3===t){let{id:t,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(zp,{});e.push({id:t,bitmap:new Yh({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}}function zp(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 Tp(t){return"function"==typeof t?.renderWithWebGL}function Pp(t){let{userImage:e}=t;return!(!e?.render||!e.render()||(Tp(e.data)||t.data.replace(new Uint8Array(e.data.buffer)),0))}function Ip(t){let e=0,i=0;for(let r of t)e+=r.w*r.h,i=Math.max(i,r.w);t.sort(((t,e)=>e.h-t.h));let r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}],n=0,s=0;for(let e of t)for(let t=r.length-1;t>=0;t--){let i=r[t];if(!(e.w>i.w||e.h>i.h)){if(e.x=i.x,e.y=i.y,s=Math.max(s,e.y+e.h),n=Math.max(n,e.x+e.w),e.w===i.w&&e.h===i.h){let e=r.pop();e&&t<r.length&&(r[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):(r.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:n,h:s,fill:e/(n*s)||0}}var kp=class{constructor(t,{pixelRatio:e,version:i,isWebGLImage:r=!1,stretchX:n,stretchY:s,content:o,textFitWidth:a,textFitHeight:l}){this.paddedRect=t,this.pixelRatio=e,this.stretchX=n,this.stretchY=s,this.content=o,this.version=i,this.needsFirstWebGLRender=r,this.textFitWidth=a,this.textFitHeight=l}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]}};Vo("ImagePosition",kp),Vo("ImageAtlas",class{constructor(t,e){let i={},r={};this.haveRenderCallbacks=[],this.patchedUpdateVersion=-1;let n=[];this.addImages(t,i,n),this.addImages(e,r,n);let{w:s,h:o}=Ip(n),a=new Xh({width:s||1,height:o||1});for(let e in t){let r=t[e];if(r.isWebGLImage)continue;let n=i[e].paddedRect;Xh.copy(r.data,a,{x:0,y:0},{x:n.x+1,y:n.y+1},r.data)}for(let t in e){let i=e[t],n=r[t].paddedRect,s=n.x+1,o=n.y+1,l=i.data.width,h=i.data.height;Xh.copy(i.data,a,{x:0,y:0},{x:s,y:o},i.data),Xh.copy(i.data,a,{x:0,y:h-1},{x:s,y:o-1},{width:l,height:1}),Xh.copy(i.data,a,{x:0,y:0},{x:s,y:o+h},{width:l,height:1}),Xh.copy(i.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:h}),Xh.copy(i.data,a,{x:0,y:0},{x:s+l,y:o},{width:1,height:h})}this.image=a,this.iconPositions=i,this.patternPositions=r}addImages(t,e,i){for(let r in t){let n=t[r],s={x:0,y:0,w:n.data.width+2,h:n.data.height+2};i.push(s),e[r]=new kp(s,n),n.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(t,e){if(t.dispatchRenderCallbacks(this.haveRenderCallbacks),this.patchedUpdateVersion!==t.updateVersion){this.patchedUpdateVersion=t.updateVersion;for(let i in this.iconPositions)this.patchUpdatedImage(this.iconPositions[i],t.getImage(i),e);for(let i in this.patternPositions)this.patchUpdatedImage(this.patternPositions[i],t.getImage(i),e)}}patchUpdatedImage(t,e,i){if(!t||!e||!t.needsFirstWebGLRender&&t.version===e.version)return;t.needsFirstWebGLRender=!1,t.version=e.version;let[r,n]=t.tl,s=e.userImage?.data;if(!Tp(s))return void i.update(e.data,void 0,{x:r,y:n});let{width:o,height:a}=e.data;i.context.setCustomLayerDefaults(),s.renderWithWebGL({gl:i.context.gl,texture:i.texture,x:r,y:n,width:o,height:a}),i.context.setDirty()}});var $p=function(t){return t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly",t}($p||{});const jp=/^\p{gc=M}$/u;function Rp(t,e,i){let r=new yp(t.join(""),e,[]),n=0;for(let t of r.graphemes())r.sectionIndex.push(i[n]??0),n+=[...t].length;return r}function Op(t){let e=[],i=0;for(let r of t)e.push(i),i+=r.length;return e}function Bp(t,e,i){let r=[...t],n=Op(r),s=function(t){let e=[],i=0;for(;i<t.length;){if(!jp.test(t[i])){e.push(i),i++;continue}let r=i;for(;r<t.length&&jp.test(t[r]);)r++;let n=t[r];if(void 0!==n&&ap(n.codePointAt(0))){e.push(r);for(let t=r-1;t>=i;t--)e.push(t);i=r+1}else{for(let t=i;t<r;t++)e.push(t);i=r}}return e}(r);return Rp(s.map((t=>r[t])),e,s.map((t=>i[n[t]]??0)))}function Lp(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d){let m=yp.fromFeature(t,n);2===c&&m.verticalizePunctuation();let _=m.determineLineBreaks(h,s,e,r,p),g=lp(m.text)?function(t,e){let i=e.map((e=>t.toCodeUnitIndex(e))),r=Ff.isParsed()?Ff:null;if(1===t.sections.length)return r?r.processBidirectionalText(t.toString(),i).map((e=>Bp(e,t.sections,[...e].map((()=>0))))):function(t,e){return Mp(t,e).map((t=>t.text))}(t.toString(),i).map((e=>Rp([...e],t.sections,[...e].map((()=>0)))));let n=function(t){let e=[],i=0;for(let r of t.graphemes())e.push(...Array(r.length).fill(t.sectionIndex[i])),i++;return e}(t);return r?r.processStyledBidirectionalText(t.text,n,i).map((([e,i])=>Bp(e,t.sections,i))):function(t,e,i){return Mp(t,i).map((t=>[t.text,t.sourceIndices.map((t=>e[t]??0))]))}(t.text,n,i).map((([e,i])=>{let r=[...e];return Rp(r,t.sections,Op(r).map((t=>i[t]??0)))}))}(m,_):function(t,e){let i=[],r=0;for(let n of e)i.push(t.substring(r,n)),r=n;return r<t.length()&&i.push(t.substring(r,t.length())),i}(m,_),y=[],v={positionedLines:y,text:m.toString(),top:u[1],bottom:u[1],left:u[0],right:u[0],writingMode:c,iconsInText:!1,verticalizable:!1};return function(t,e,i,r,n,s,o,a,l,h,u,c){let f=0,p=0,d=0,m=0,_="right"===a?1:"left"===a?0:.5,g=24/c,y=0;for(let o of n){o.trim();let n=o.getMaxScale(),a={positionedGlyphs:[],lineOffset:0};t.positionedLines[y]=a;let c=a.positionedGlyphs,v=0;if(!o.length()){p+=s,++y;continue}let w=Np(r,o,g),b=2!==l||u?null:Yp(o),x=o.graphemes();for(let s=0;s<x.length;s++){let a=o.getSection(s),d=x[s],m=d.codePointAt(0),_=b?b[s]:qp(l,u,m),y="fontStack"in a&&tp(d)&&!e[a.fontStack]?.default?.[d]?[...d]:[d];for(let l of y){let u,d={glyph:l.codePointAt(0),grapheme:l,imageName:null,x:f,y:p+-17,vertical:_,scale:1,fontStack:"",sectionIndex:o.getSectionIndex(s),metrics:null,rect:null};if("fontStack"in a){if(u=Xp(a,l,_,w,e,i),!u)continue;d.fontStack=a.fontStack}else{if(t.iconsInText=!0,a.scale*=g,u=Jp(a,_,n,w,r),!u)continue;v=Math.max(v,u.imageOffset),d.imageName=a.imageName}let{rect:m,metrics:y,baselineOffset:b}=u;d.y+=b,d.scale=a.scale,d.metrics=y,d.rect=m,c.push(d),_?(t.verticalizable=!0,f+=("imageName"in a?y.advance:24)*a.scale+h):f+=y.advance*a.scale+h}}0!==c.length&&(d=Math.max(f-h,d),Kp(c,0,c.length-1,_)),f=0,a.lineOffset=Math.max(v,24*(n-1));let D=s*n+v;p+=D,m=Math.max(D,m),++y}let{horizontalAlign:v,verticalAlign:w}=Up(o);(function(t,e,i,r,n,s,o,a,l){let h=(e-i)*n,u=0;u=s===o?-r*l*o+.5*o:-a*r- -17;for(let e of t)for(let t of e.positionedGlyphs)t.x+=h,t.y+=u})(t.positionedLines,_,v,w,d,m,s,p,n.length),t.top+=-w*p,t.bottom=t.top+p,t.left+=-v*d,t.right=t.left+d}(v,e,i,r,g,o,a,l,c,h,f,d),!function(t){for(let e of t)if(0!==e.positionedGlyphs.length)return!1;return!0}(y)&&v}function Up(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 Np(t,e,i){let r=24*e.getMaxScale(),{maxImageWidth:n,maxImageHeight:s}=e.getMaxImageSize(t),o=Math.max(r,s*i);return{verticalLineContentWidth:Math.max(r,n*i),horizontalLineContentHeight:o}}function Gp(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function qp(t,e,i){return!(1===t||!e&&!Cf(i)||e&&(ep(i)||op(i)))}function Vp(t){return/\p{Nd}/u.test(String.fromCodePoint(t))}function Zp(t){return/\p{Lu}/u.test(String.fromCodePoint(t))}function Wp(t){let e=t.some(Vp)&&t.every((t=>Vp(t)||function(t){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(t))}(t))),i=t.length<=3&&t.every((t=>Zp(t)||Vp(t)));return e||i}function Hp(t){return(Vp(t)||Zp(t))&&!op(t)}function Yp(t){let e=t.graphemes().slice(),i=e.map((t=>t.codePointAt(0))),r=i.map(Cf),n=e=>!r[e]&&!ep(i[e])&&!("imageName"in t.getSection(e));for(let t=0;t<i.length;t++){if(!n(t))continue;let e=t;for(;e+1<i.length&&n(e+1);)e++;if(Wp(i.slice(t,e+1)))for(let n=t;n<=e;n++)r[n]=Hp(i[n]);t=e}return function(t,e){let i=!1;for(let r=0;r<t.length;r++){if(e[r])continue;let n=hp[t[r]];n&&(0===r||e[r-1])&&(r===t.length-1||e[r+1])&&(t[r]=n,e[r]=!0,i=!0)}return i}(e,r)&&(t.text=e.join(""),t._graphemes=null),r}function Xp(t,e,i,r,n,s){let o,a=s[t.fontStack]?.default?.[e],l=function(t,e,i,r){if(t?.rect)return t;let n=e[i.fontStack]?.default?.[r];return n?{rect:null,metrics:n.metrics}:null}(a,n,t,e);if(null===l)return null;if(i)o=r.verticalLineContentWidth-24*t.scale;else{let e=Gp(t.verticalAlign);o=(r.horizontalLineContentHeight-24*t.scale)*e}return{rect:l.rect,metrics:l.metrics,baselineOffset:o}}function Jp(t,e,i,r,n){let s=n[t.imageName];if(!s)return null;let o,a=s.paddedRect,l=s.displaySize,h={width:l[0],height:l[1],left:1,top:-3,advance:e?l[1]:l[0]};if(e)o=r.verticalLineContentWidth-l[1]*t.scale;else{let e=Gp(t.verticalAlign);o=(r.horizontalLineContentHeight-l[1]*t.scale)*e}return{rect:a,metrics:h,baselineOffset:o,imageOffset:(e?l[0]:l[1])*t.scale-24*i}}function Kp(t,e,i,r){if(0===r)return;let n=t[i],s=(t[i].x+n.metrics.advance*n.scale)*r;for(let r=e;r<=i;r++)t[r].x-=s}function Qp(t,e,i){let{horizontalAlign:r,verticalAlign:n}=Up(i),s=e[0]-t.displaySize[0]*r,o=e[1]-t.displaySize[1]*n;return{image:t,top:o,bottom:o+t.displaySize[1],left:s,right:s+t.displaySize[0]}}function td(t){let e=t.left,i=t.top,r=t.right-e,n=t.bottom-i,s=t.image.textFitWidth??"stretchOrShrink",o=t.image.textFitHeight??"stretchOrShrink",a=(t.image.content[2]-t.image.content[0])/(t.image.content[3]-t.image.content[1]);if("proportional"===o){if("stretchOnly"===s&&r/n<a||"proportional"===s){let t=Math.ceil(n*a);e*=t/r,r=t}}else if("proportional"===s&&"stretchOnly"===o&&0!==a&&r/n>a){let t=Math.ceil(r/a);i*=t/n,n=t}return{x1:e,y1:i,x2:e+r,y2:i+n}}function ed(t,e,i,r,n,s){let o,a=t.image;if(a.content){let t=a.content,e=a.pixelRatio||1;o=[t[0]/e,t[1]/e,a.displaySize[0]-t[2]/e,a.displaySize[1]-t[3]/e]}let l,h,u,c,f=e.left*s,p=e.right*s;"width"===i||"both"===i?(c=n[0]+f-r[3],h=n[0]+p+r[1]):(c=n[0]+(f+p-a.displaySize[0])/2,h=c+a.displaySize[0]);let d=e.top*s,m=e.bottom*s;return"height"===i||"both"===i?(l=n[1]+d-r[0],u=n[1]+m+r[2]):(l=n[1]+(d+m-a.displaySize[1])/2,u=l+a.displaySize[1]),{image:a,top:l,right:h,bottom:u,left:c,collisionPadding:o}}function id(t,e){let{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Ko(t+1))};if("source"===i.kind)return{kind:"source"};if("composite"===i.kind){let{minZoom:e,maxZoom:r}=function(t,e){let i=0;for(;i<t.length&&t[i]<=e;)i++;i=Math.max(0,i-1);let r=i;for(;r<t.length&&t[r]<e+1;)r++;return r=Math.min(t.length-1,r),{minZoom:t[i],maxZoom:t[r]}}(i.zoomStops,t);return{kind:"composite",minZoom:e,maxZoom:r,interpolationType:i.interpolationType}}{let e=function(t){return t.zoomStops.map((e=>t.evaluate(new Ko(e===-1/0?t.zoomStops[1]-1:e))))}(i),r=i.evaluate(new Ko(t+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:e,layoutSize:r,interpolationType:i.interpolationType}}}function rd(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/128:"composite"===t.kind?Sr.number(r/128,n/128,i):e}function nd(t,e){let i=0,r=0;return"constant"===t.kind?r=t.layoutSize:"camera"===t.kind?r=function({zoomStops:t,sizes:e,layoutSize:i,interpolationType:r},n){let s=t.length-1;for(;s>0&&t[s]>n;)s--;let o=Math.min(s+1,t.length-1),a=r?At(Ar.interpolationFactor(r,n,t[s],t[o]),0,1):0;return Math.min(Sr.number(e[s],e[o],a),i)}(t,e):"composite"===t.kind&&(i=function({interpolationType:t,minZoom:e,maxZoom:i},r){return t?At(Ar.interpolationFactor(t,r,e,i),0,1):0}(t,e)),{uSizeT:i,uSize:r}}var sd=class t extends f{constructor(t,e,i,r){super(t,e),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new t(this.x,this.y,this.angle,this.segment)}};function od(t,e,i,r,n){if(void 0===e.segment||0===i)return!0;let s=e,o=e.segment+1,a=0;for(;a>-i/2;){if(o--,o<0)return!1;a-=t[o].dist(s),s=t[o]}a+=t[o].dist(t[o+1]),o++;let l=[],h=0;for(;a<i/2;){let e=t[o],i=t[o+1];if(!i)return!1;let s=t[o-1].angleTo(e)-e.angleTo(i);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:a,angleDelta:s}),h+=s;a-l[0].distance>r;)h-=l.shift().angleDelta;if(h>n)return!1;o++,a+=e.dist(i)}return!0}function ad(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function ld(t,e,i){return t?.6*e*i:0}function hd(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function ud(t,e,i,r,n,s){let o=ld(i,n,s),a=hd(i,r)*s,l=0,h=ad(t)/2;for(let i=0;i<t.length-1;i++){let r=t[i],n=t[i+1],s=r.dist(n);if(l+s>h){let u=(h-l)/s,c=new sd(Sr.number(r.x,n.x,u),Sr.number(r.y,n.y,u),n.angleTo(r),i);return c._round(),!o||od(t,c,a,o,e)?c:void 0}l+=s}}function cd(t,e,i,r,n,s,o,a,l){let h=ld(r,s,o),u=hd(r,n),c=u*o,f=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-c<e/4&&(e=c+e/4),fd(t,f?e/2*a%e:(u/2+2*s)*o*a%e,e,h,i,c,f,!1,l)}function fd(t,e,i,r,n,s,o,a,l){let h=s/2,u=ad(t),c=0,f=e-i,p=[];for(let e=0;e<t.length-1;e++){let o=t[e],a=t[e+1],d=o.dist(a),m=a.angleTo(o);for(;f+i<c+d;){f+=i;let _=(f-c)/d,g=Sr.number(o.x,a.x,_),y=Sr.number(o.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&f-h>=0&&f+h<=u){let i=new sd(g,y,m,e);i._round(),(!r||od(t,i,s,r,n))&&p.push(i)}}c+=d}return!a&&!p.length&&!o&&(p=fd(t,c/2,i,r,n,s,o,!0,l)),p}function pd(t,e,i,r,n){let s=[];for(let o of t){let t;for(let a=0;a<o.length-1;a++){let l=o[a],h=o[a+1];l.x<e&&h.x<e||(l.x<e?l=new f(e,l.y+(e-l.x)/(h.x-l.x)*(h.y-l.y))._round():h.x<e&&(h=new f(e,l.y+(e-l.x)/(h.x-l.x)*(h.y-l.y))._round()),!(l.y<i&&h.y<i)&&(l.y<i?l=new f(l.x+(i-l.y)/(h.y-l.y)*(h.x-l.x),i)._round():h.y<i&&(h=new f(l.x+(i-l.y)/(h.y-l.y)*(h.x-l.x),i)._round()),!(l.x>=r&&h.x>=r)&&(l.x>=r?l=new f(r,l.y+(r-l.x)/(h.x-l.x)*(h.y-l.y))._round():h.x>=r&&(h=new f(r,l.y+(r-l.x)/(h.x-l.x)*(h.y-l.y))._round()),!(l.y>=n&&h.y>=n)&&(l.y>=n?l=new f(l.x+(n-l.y)/(h.y-l.y)*(h.x-l.x),n)._round():h.y>=n&&(h=new f(l.x+(n-l.y)/(h.y-l.y)*(h.x-l.x),n)._round()),(!t||!l.equals(t[t.length-1]))&&(t=[l],s.push(t)),t.push(h)))))}}return s}function dd(t,e,i,r){let n=[],s=t.image,o=s.pixelRatio,a=s.paddedRect.w-2,l=s.paddedRect.h-2,h={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom},u=s.stretchX||[[0,a]],c=s.stretchY||[[0,l]],p=(t,e)=>t+e[1]-e[0],d=u.reduce(p,0),m=c.reduce(p,0),_=a-d,g=l-m,y=0,v=d,w=0,b=m,x=0,D=_,M=0,E=g;if(s.content&&r){let e=s.content,i=e[2]-e[0],r=e[3]-e[1];(s.textFitWidth||s.textFitHeight)&&(h=td(t)),y=md(u,0,e[0]),w=md(c,0,e[1]),v=md(u,e[0],e[2]),b=md(c,e[1],e[3]),x=e[0]-y,M=e[1]-w,D=i-v,E=r-b}let A=h.x1,F=h.y1,S=h.x2-A,C=h.y2-F,z=(t,r,n,a)=>{let l=gd(t.stretch-y,v,S,A),h=yd(t.fixed-x,D,t.stretch,d),u=gd(r.stretch-w,b,C,F),c=yd(r.fixed-M,E,r.stretch,m),p=gd(n.stretch-y,v,S,A),_=yd(n.fixed-x,D,n.stretch,d),g=gd(a.stretch-w,b,C,F),z=yd(a.fixed-M,E,a.stretch,m),T=new f(l,u),P=new f(p,u),I=new f(p,g),k=new f(l,g),$=new f(h/o,c/o),j=new f(_/o,z/o),R=e*Math.PI/180;if(R){let t=Math.sin(R),e=Math.cos(R),i=[e,-t,t,e];T._matMult(i),P._matMult(i),k._matMult(i),I._matMult(i)}let O=t.stretch+t.fixed,B=r.stretch+r.fixed;return{tl:T,tr:P,bl:k,br:I,tex:{x:s.paddedRect.x+1+O,y:s.paddedRect.y+1+B,w:n.stretch+n.fixed-O,h:a.stretch+a.fixed-B},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:$,pixelOffsetBR:j,minFontScaleX:D/o/S,minFontScaleY:E/o/C,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){let t=_d(u,_,d),e=_d(c,g,m);for(let i=0;i<t.length-1;i++){let r=t[i],s=t[i+1];for(let t=0;t<e.length-1;t++)n.push(z(r,e[t],s,e[t+1]))}}else n.push(z({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:a+1},{fixed:0,stretch:l+1}));return n}function md(t,e,i){let r=0;for(let n of t)r+=Math.max(e,Math.min(i,n[1]))-Math.max(e,Math.min(i,n[0]));return r}function _d(t,e,i){let r=[{fixed:-1,stretch:0}];for(let[e,i]of t){let t=r[r.length-1];r.push({fixed:e-t.stretch,stretch:t.stretch}),r.push({fixed:e-t.stretch,stretch:t.stretch+(i-e)})}return r.push({fixed:e+1,stretch:i}),r}function gd(t,e,i,r){return t/e*i+r}function yd(t,e,i,r){return t-e*i/r}function vd(t,e,i,r,n,s,o,a){let l=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,h=[];for(let t of e.positionedLines)for(let r of t.positionedGlyphs){if(!r.rect)continue;let s=r.rect||{},u=4,c=!0,p=1,d=0,m=(n||a)&&r.vertical,_=r.metrics.advance*r.scale/2;if(a&&e.verticalizable&&(d=t.lineOffset/2-(r.imageName?-(24-r.metrics.width*r.scale)/2:24*(r.scale-1))),r.imageName){let t=o[r.imageName];c=t.sdf,p=t.pixelRatio,u=1/p}let g=n?[r.x+_,r.y]:[0,0],y=n?[0,0]:[r.x+_+i[0],r.y+i[1]-d],v=[0,0];m&&(v=y,y=[0,0]);let w=r.metrics.isDoubleResolution?2:1,b=(r.metrics.left-u)*r.scale-_+y[0],x=(-r.metrics.top-u)*r.scale+y[1],D=b+s.w/w*r.scale/p,M=x+s.h/w*r.scale/p,E=new f(b,x),A=new f(D,x),F=new f(b,M),S=new f(D,M);if(m){let t=new f(-_,_- -17),e=-Math.PI/2,i=12-_,n=new f(22-i,-(r.imageName?i:0)),s=new f(...v);E._rotateAround(e,t)._add(n)._add(s),A._rotateAround(e,t)._add(n)._add(s),F._rotateAround(e,t)._add(n)._add(s),S._rotateAround(e,t)._add(n)._add(s)}if(l){let t=Math.sin(l),e=Math.cos(l),i=[e,-t,t,e];E._matMult(i),A._matMult(i),F._matMult(i),S._matMult(i)}let C=new f(0,0),z=new f(0,0);h.push({tl:E,tr:A,bl:F,br:S,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:r.sectionIndex,isSDF:c,pixelOffsetTL:C,pixelOffsetBR:z,minFontScaleX:0,minFontScaleY:0})}return h}Vo("Anchor",sd);var wd=class{constructor(t,e,i,r,n,s,o,a,l,h){if(this.boxStartIndex=t.length,l){let t=s.top,e=s.bottom,i=s.collisionPadding;i&&(t-=i[1],e+=i[3]);let r=e-t;r>0&&(r=Math.max(10,r),this.circleDiameter=r)}else{let l=s.image?.content&&(s.image.textFitWidth||s.image.textFitHeight)?td(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};l.y1=l.y1*o-a[0],l.y2=l.y2*o+a[2],l.x1=l.x1*o-a[3],l.x2=l.x2*o+a[1];let u=s.collisionPadding;if(u&&(l.x1-=u[0]*o,l.y1-=u[1]*o,l.x2+=u[2]*o,l.y2+=u[3]*o),h){let t=new f(l.x1,l.y1),e=new f(l.x2,l.y1),i=new f(l.x1,l.y2),r=new f(l.x2,l.y2),n=h*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),l.x1=Math.min(t.x,e.x,i.x,r.x),l.x2=Math.max(t.x,e.x,i.x,r.x),l.y1=Math.min(t.y,e.y,i.y,r.y),l.y2=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,l.x1,l.y1,l.x2,l.y2,i,r,n)}this.boxEndIndex=t.length}},bd=class{constructor(t=[],e=(t,e)=>t<e?-1:+(t>e)){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;let 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){let{data:e,compare:i}=this,r=e[t];for(;t>0;){let n=t-1>>1,s=e[n];if(i(r,s)>=0)break;e[t]=s,t=n}e[t]=r}_down(t){let{data:e,compare:i}=this,r=this.length>>1,n=e[t];for(;t<r;){let r=1+(t<<1),s=r+1;if(s<this.length&&i(e[s],e[r])<0&&(r=s),i(e[r],n)>=0)break;e[t]=e[r],t=r}e[t]=n}};function xd(t,e=1){let i=yc.fromPoints(t[0]),r=Math.min(i.width(),i.height()),n=r/2,s=new bd([],Dd),{minX:o,minY:a,maxX:l,maxY:h}=i;if(0===r)return new f(o,a);for(let e=o;e<l;e+=r)for(let i=a;i<h;i+=r)s.push(new Md(e+n,i+n,n,t));let u=function(t){let e=0,i=0,r=0,n=t[0];for(let t=0,s=n.length,o=s-1;t<s;o=t++){let s=n[t],a=n[o],l=s.x*a.y-a.x*s.y;i+=(s.x+a.x)*l,r+=(s.y+a.y)*l,e+=3*l}return new Md(i/e,r/e,0,t)}(t),c=u;for(;s.length;){let i=s.pop();(i.d>c.d||!c.d)&&(c=i),!(i.max-c.d<=e)&&(n=i.h/2,s.push(new Md(i.p.x-n,i.p.y-n,n,t)),s.push(new Md(i.p.x+n,i.p.y-n,n,t)),s.push(new Md(i.p.x-n,i.p.y+n,n,t)),s.push(new Md(i.p.x+n,i.p.y+n,n,t)))}return u.d>0&&c.d-u.d<=e?u.p:c.p}function Dd(t,e){return e.max-t.max}var Md=class{constructor(t,e,i,r){this.p=new f(t,e),this.h=i,this.d=function(t,e){let i=!1,r=1/0;for(let n of e)for(let e=0,s=n.length,o=s-1;e<s;o=e++){let s=n[e],a=n[o];s.y>t.y!=a.y>t.y&&t.x<(a.x-s.x)*(t.y-s.y)/(a.y-s.y)+s.x&&(i=!i),r=Math.min(r,Mh(t,s,a))}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}};let Ed=function(t){return t[t.center=1]="center",t[t.left=2]="left",t[t.right=3]="right",t[t.top=4]="top",t[t.bottom=5]="bottom",t[t["top-left"]=6]="top-left",t[t["top-right"]=7]="top-right",t[t["bottom-left"]=8]="bottom-left",t[t["bottom-right"]=9]="bottom-right",t}({});const Ad=1/0;function Fd(t,e){return e[1]===Ad?function(t,e){let i=0,r=0;e<0&&(e=0);let n=e/Math.SQRT2;switch(t){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-e;break;case"top":r=e-7}switch(t){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=e;break;case"right":i=-e}return[i,r]}(t,e[0]):function(t,e,i){let r=0,n=0;switch(e=Math.abs(e),i=Math.abs(i),t){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(t){case"top-right":case"bottom-right":case"right":r=-e;break;case"top-left":case"bottom-left":case"left":r=e}return[r,n]}(t,e[0],e[1])}function Sd(t,e,i){let r=t.layout,n=r.get("text-variable-anchor-offset")?.evaluate(e,{},i);if(n){let t=n.values,e=[];for(let i=0;i<t.length;i+=2){let r=e[i]=t[i],n=t[i+1].map((t=>24*t));r.startsWith("top")?n[1]-=7:r.startsWith("bottom")&&(n[1]+=7),e[i+1]=n}return new pr(e)}let s=r.get("text-variable-anchor");if(s){let n;n=void 0===t._unevaluatedLayout.getValue("text-radial-offset")?r.get("text-offset").evaluate(e,{},i).map((t=>24*t)):[24*r.get("text-radial-offset").evaluate(e,{},i),Ad];let o=[];for(let t of s)o.push(t,Fd(t,n));return new pr(o)}return null}function Cd(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 zd(t,e,i,r,n,s,o,a,l,h,u,c,f){let p=s.textMaxSize.evaluate(e,{});void 0===p&&(p=o);let d,m=t.layers[0].layout,_=m.get("icon-offset").evaluate(e,{},u),g=Pd(i.horizontal),y=o/24,v=t.tilePixelRatio*y,w=t.tilePixelRatio*p/24,b=t.tilePixelRatio*a,x=t.tilePixelRatio*m.get("symbol-spacing"),D=m.get("text-padding")*t.tilePixelRatio,M=function(t,e,i,r=1){let n=t.get("icon-padding").evaluate(e,{},i)?.values;return[n[0]*r,n[1]*r,n[2]*r,n[3]*r]}(m,e,u,t.tilePixelRatio),E=m.get("text-max-angle")/180*Math.PI,A="viewport"!==m.get("text-rotation-alignment")&&"point"!==m.get("symbol-placement"),F="map"===m.get("icon-rotation-alignment").constantOr("viewport")&&"point"!==m.get("symbol-placement"),S=m.get("symbol-placement"),C=x/2,z=m.get("icon-text-fit");r&&"none"!==z&&(t.allowVerticalPlacement&&i.vertical&&(d=ed(r,i.vertical,z,m.get("icon-text-fit-padding"),_,y)),g&&(r=ed(r,g,z,m.get("icon-text-fit-padding"),_,y)));let T=u?c.line.getGranularityForZoomLevel(u.z):1,P=(a,c)=>{c.x<0||c.x>=8192||c.y<0||c.y>=8192||function(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b,x,D,M,E){let A=t.addToLineVertexArray(e,i),F=a.layout.get("symbol-height-offset").evaluate(w,{},D);F>t.maxHeightOffset&&(t.maxHeightOffset=F);let S,C,z,T,P=0,I=0,k=0,$=0,j=-1,R=-1,O={},B=(0,jl.default)("");if(t.allowVerticalPlacement&&r.vertical){let t=a.layout.get("text-rotate").evaluate(w,{},D)+90;z=new wd(l,e,h,u,c,r.vertical,f,p,d,t),o&&(T=new wd(l,e,h,u,c,o,_,g,d,t))}if(n){let i=a.layout.get("icon-rotate").evaluate(w,{}),r="none"!==a.layout.get("icon-text-fit"),s=dd(n,i,x,r),f=o?dd(o,i,x,r):void 0;C=new wd(l,e,h,u,c,n,_,g,!1,i),P=4*s.length;let p=t.iconSizeData,d=null;"source"===p.kind?(d=[128*a.layout.get("icon-size").evaluate(w,{})],d[0]>32640&&Lt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===p.kind&&(d=[128*b.compositeIconSizes[0].evaluate(w,{},D),128*b.compositeIconSizes[1].evaluate(w,{},D)],(d[0]>32640||d[1]>32640)&&Lt(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,d,v,y,w,0,e,A.lineStartIndex,A.lineLength,-1,D,F),j=t.icon.placedSymbolArray.length-1,f&&(I=4*f.length,t.addSymbols(t.icon,f,d,v,y,w,2,e,A.lineStartIndex,A.lineLength,-1,D,F),R=t.icon.placedSymbolArray.length-1)}let L=Object.keys(r.horizontal);for(let i of L){let n=r.horizontal[i];S||=(B=(0,jl.default)(n.text),new wd(l,e,h,u,c,n,f,p,d,a.layout.get("text-rotate").evaluate(w,{},D)));let o=1===n.positionedLines.length;if(k+=Td(t,e,n,s,a,d,w,m,F,A,r.vertical?1:3,o?L:[i],O,j,b,D),o)break}r.vertical&&($+=Td(t,e,r.vertical,s,a,d,w,m,F,A,2,["vertical"],O,R,b,D));let U=S?S.boxStartIndex:t.collisionBoxArray.length,N=S?S.boxEndIndex:t.collisionBoxArray.length,G=z?z.boxStartIndex:t.collisionBoxArray.length,q=z?z.boxEndIndex:t.collisionBoxArray.length,V=C?C.boxStartIndex:t.collisionBoxArray.length,Z=C?C.boxEndIndex:t.collisionBoxArray.length,W=T?T.boxStartIndex:t.collisionBoxArray.length,H=T?T.boxEndIndex:t.collisionBoxArray.length,Y=-1,X=(t,e)=>t?.circleDiameter?Math.max(t.circleDiameter,e):e;Y=X(S,Y),Y=X(z,Y),Y=X(C,Y),Y=X(T,Y);let J=+(Y>-1);J&&(Y*=M/24),t.glyphOffsetArray.length>=t.maxGlyphs&&Lt("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==w.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,w.sortKey);let K=Sd(a,w,D),[Q,tt]=function(t,e){let i=t.length,r=e?.values;if(r?.length>0)for(let e=0;e<r.length;e+=2){let i=r[e+1];t.emplaceBack(Ed[r[e]],i[0],i[1])}return[i,t.length]}(t.textAnchorOffsets,K);E&&(B=function(t,e){return null==e.id||e.properties?.cluster?t:(0,jl.default)(String(e.id),t)}(B,w)),t.symbolInstances.emplaceBack(e.x,e.y,O.right>=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,j,R,B,U,N,G,q,V,Z,W,H,h,k,$,P,I,J,0,f,Y,Q,tt,F)}(t,c,a,i,r,n,d,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,v,[D,D,D,D],A,l,b,M,F,_,e,s,h,u,o,f)};if("line"===S)for(let n of pd(e.geometry,0,0,st,st)){let e=sc(n,T),s=cd(e,x,E,i.vertical||g,r,24,w,t.overscaling,st);for(let i of s)(!g||!Id(t,g.text,C,i))&&P(e,i)}else if("line-center"===S){for(let t of e.geometry)if(t.length>1){let e=sc(t,T),n=ud(e,E,i.vertical||g,r,24,w);n&&P(e,n)}}else if("Polygon"===e.type)for(let t of Ir(e.geometry,0)){let e=xd(t,16);P(sc(t[0],T,!0),new sd(e.x,e.y,0))}else if("LineString"===e.type)for(let t of e.geometry){let e=sc(t,T);P(e,new sd(e[0].x,e[0].y,0))}else if("Point"===e.type)for(let t of e.geometry)for(let e of t)P([e],new sd(e.x,e.y,0))}function Td(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m){let _=vd(0,i,a,n,s,o,r,t.allowVerticalPlacement),g=t.textSizeData,y=null;"source"===g.kind?(y=[128*n.layout.get("text-size").evaluate(o,{})],y[0]>32640&&Lt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===g.kind&&(y=[128*d.compositeTextSizes[0].evaluate(o,{},m),128*d.compositeTextSizes[1].evaluate(o,{},m)],(y[0]>32640||y[1]>32640)&&Lt(`${t.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),t.addSymbols(t.text,_,y,a,s,o,u,e,h.lineStartIndex,h.lineLength,p,m,l);for(let e of c)f[e]=t.text.placedSymbolArray.length-1;return 4*_.length}function Pd(t){for(let e in t)return t[e];return null}function Id(t,e,i,r){let n=t.compareText;if(e in n){let t=n[e];for(let e=t.length-1;e>=0;e--)if(r.dist(t[e])<i)return!0}else n[e]=[];return n[e].push(r),!1}function kd(t,e,i){let r="never",n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}const $d=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function jd(t,e,i,r,n,s,o,a,l,h,u,c,f,p){let d=a?Math.min(32640,Math.round(a[0])):0,m=a?Math.min(32640,Math.round(a[1])):0;t.emplaceBack(e,i,Math.round(32*r),Math.round(32*n),s,o,+!!l+(d<<1),m,16*h,16*u,256*c,256*f,p)}function Rd(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 Od(t){for(let e of t.sections)if(lp(e.text))return!0;return!1}var Bd=class{constructor(t){this.layoutVertexArray=new vl,this.indexArray=new Al,this.programConfigurations=t,this.segments=new zl,this.dynamicLayoutVertexArray=new wl,this.opacityVertexArray=new bl,this.hasVisibleVertices=!1,this.placedSymbolArray=new tl}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(t,e,i,r){this.isEmpty()||(i&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,bf.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,xf.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,$d,!0),this.opacityVertexBuffer.itemSize=1),(i||r)&&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())}};Vo("SymbolBuffers",Bd);var Ld=class{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new zl,this.collisionVertexArray=new Ml}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Df.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};Vo("CollisionBuffers",Ld);var Ud=class{constructor(t){this.collisionBoxArray=t.collisionBoxArray,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.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!0,this.hasRTLText=!1,this.maxHeightOffset=0,this.sortKeyRanges=[],this.collisionCircleArray=[],this.maxGlyphs=65535;let e=this.layers[0]._unevaluatedLayout._values;this.textSizeData=id(this.zoom,e["text-size"]),this.iconSizeData=id(this.zoom,e["icon-size"]);let i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=i.get("symbol-z-order");this.canOverlap="never"!==kd(i,"text-overlap","text-allow-overlap")||"never"!==kd(i,"icon-overlap","icon-allow-overlap")||i.get("text-ignore-placement")||i.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==n&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===i.get("symbol-placement")&&(this.writingModes=i.get("text-writing-mode").map((t=>$p[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Bd(new ah(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new Bd(new ah(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new rl,this.lineVertexArray=new nl,this.symbolInstances=new il,this.textAnchorOffsets=new ol}calculateGlyphDependencies(t,e,i,r,n){let s=(r||this.allowVerticalPlacement)&&n,o=yp.fromFeature(t,i),a=o.graphemes();for(let t=0;t<a.length;t++){let i=o.getSection(t);if("imageName"in i)continue;let r=(e[i.fontStack]||={default:{}}).default,n=a[t];tp(n)&&(r[n]=!0);for(let t of n){if(r[t]=!0,!s)continue;let e=hp[t];e&&(r[e]=!0)}}}populate(t,e,i){let r=this.layers[0],n=r.layout,s=n.get("text-font"),o=n.get("text-field"),a=n.get("icon-image"),l=("constant"!==o.value.kind||o.value.value instanceof ar&&!o.value.value.isEmpty()||o.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==a.value.kind||!!a.value.value||Object.keys(a.parameters).length>0,u=n.get("symbol-sort-key");if(this.features=[],!l&&!h)return;let c=e.iconDependencies,f=e.glyphDependencies,p=e.availableImages,d=new Ko(this.zoom);for(let{feature:e,id:o,index:a,sourceLayerIndex:m}of t){let t,_,g=r._featureFilter.needGeometry,y=ph(e,g);if(!r._featureFilter.filter(d,y,i))continue;if(g||(y.geometry=fh(e)),l){let e=r.getValueAndResolveTokens("text-field",y,i,p),n=ar.factory(e);this.hasRTLText||=Od(n),t=qf(n,r,y)}if(h){let t=r.getValueAndResolveTokens("icon-image",y,i,p);_=t instanceof dr?t:dr.fromString(t)}if(!t&&!_)continue;let v=this.sortFeaturesByKey?u.evaluate(y,{},i):void 0;if(this.features.push({id:o,text:t,icon:_,index:a,sourceLayerIndex:m,geometry:y.geometry,properties:e.properties,type:xc.types[e.type],sortKey:v}),_&&(c[_.name]=!0),t){let e=s.evaluate(y,{},i).join(","),r="viewport"!==n.get("text-rotation-alignment")&&"point"!==n.get("symbol-placement");this.allowVerticalPlacement=this.writingModes?.includes(2);let o=ip(t.toString());this.calculateGlyphDependencies(t,f,e,r,o);for(let e of t.sections)e.image&&(c[e.image.name]=!0)}}"line"===n.get("symbol-placement")&&(this.features=function(t){let e={},i={},r=[];for(let n of t){let t=n.text?n.text.toString():null,s={points:n.geometry[0],next:null},o={feature:n,first:s,last:s};if(!t){r.push(o);continue}let a=Vf(t,o),l=Vf(t,o,!0);if(a in i&&l in e&&i[a]!==e[l]){let n=Hf(r,e,a,l,o),s=Wf(r,i,a,l,r[n]);delete e[a],delete i[l],i[Vf(t,r[s],!0)]=s,r[n].feature.geometry=null}else if(a in i)Wf(r,i,a,l,o);else if(l in e)Hf(r,e,a,l,o);else{let t=r.push(o)-1;e[a]=t,i[l]=t}}let n=[];for(let t of r){let e=t.feature;e.geometry&&(t.first.next&&(e.geometry[0]=Zf(t)),n.push(e))}return n}(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}))}addFeatures({options:t,canonical:e,glyphMap:i,glyphPositions:r,iconMap:n,iconPositions:s,showCollisionBoxes:o}){!function(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=st/(512*t.bucket.overscaling),t.bucket.compareText={},t.bucket.iconsNeedLinear=!1;let e=t.bucket.layers[0],i=e.layout,r=e._unevaluatedLayout._values,n={layoutIconSize:r["icon-size"].possiblyEvaluate(new Ko(t.bucket.zoom+1),t.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new Ko(t.bucket.zoom+1),t.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new Ko(18))};if("composite"===t.bucket.textSizeData.kind){let{minZoom:e,maxZoom:i}=t.bucket.textSizeData;n.compositeTextSizes=[r["text-size"].possiblyEvaluate(new Ko(e),t.canonical),r["text-size"].possiblyEvaluate(new Ko(i),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){let{minZoom:e,maxZoom:i}=t.bucket.iconSizeData;n.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new Ko(e),t.canonical),r["icon-size"].possiblyEvaluate(new Ko(i),t.canonical)]}let s=24*i.get("text-line-height"),o="viewport"!==i.get("text-rotation-alignment")&&"point"!==i.get("symbol-placement"),a=i.get("text-keep-upright"),l=i.get("text-size");for(let r of t.bucket.features){let h=i.get("text-font").evaluate(r,{},t.canonical).join(","),u=l.evaluate(r,{},t.canonical),c=n.layoutTextSize.evaluate(r,{},t.canonical),f=n.layoutIconSize.evaluate(r,{},t.canonical),p={horizontal:{},vertical:void 0},d=r.text,m=[0,0];if(d){let n=d.toString(),l=24*i.get("text-letter-spacing").evaluate(r,{},t.canonical),f=rp(n)?l:0,_=i.get("text-anchor").evaluate(r,{},t.canonical),g=Sd(e,r,t.canonical);if(!g){let e=i.get("text-radial-offset").evaluate(r,{},t.canonical);m=e?Fd(_,[24*e,Ad]):i.get("text-offset").evaluate(r,{},t.canonical).map((t=>24*t))}let y=o?"center":i.get("text-justify").evaluate(r,{},t.canonical),v="point"===i.get("symbol-placement")?24*i.get("text-max-width").evaluate(r,{},t.canonical):1/0,w=()=>{t.bucket.allowVerticalPlacement&&ip(n)&&(p.vertical=Lp(d,t.glyphMap,t.glyphPositions,t.imagePositions,h,v,s,_,"left",f,m,2,!0,c,u))};if(!o&&g){let e=new Set;if("auto"===y)for(let t=0;t<g.values.length;t+=2)e.add(Cd(g.values[t]));else e.add(y);let i=!1;for(let r of e)if(!p.horizontal[r])if(i)p.horizontal[r]=p.horizontal[0];else{let e=Lp(d,t.glyphMap,t.glyphPositions,t.imagePositions,h,v,s,"center",r,f,m,1,!1,c,u);e&&(p.horizontal[r]=e,i=1===e.positionedLines.length)}w()}else{"auto"===y&&(y=Cd(_));let e=Lp(d,t.glyphMap,t.glyphPositions,t.imagePositions,h,v,s,_,y,f,m,1,!1,c,u);e&&(p.horizontal[y]=e),w(),ip(n)&&o&&a&&(p.vertical=Lp(d,t.glyphMap,t.glyphPositions,t.imagePositions,h,v,s,_,y,f,m,2,!1,c,u))}}let _,g=!1;if(r.icon?.name){let e=t.imageMap[r.icon.name];e&&(_=Qp(t.imagePositions[r.icon.name],i.get("icon-offset").evaluate(r,{},t.canonical),i.get("icon-anchor").evaluate(r,{},t.canonical)),g=!!e.sdf,void 0===t.bucket.sdfIcons?t.bucket.sdfIcons=g:t.bucket.sdfIcons!==g&&Lt("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),e.pixelRatio===t.bucket.pixelRatio?0!==i.get("icon-rotate").constantOr(1)&&(t.bucket.iconsNeedLinear=!0):t.bucket.iconsNeedLinear=!0)}let y=Pd(p.horizontal)||p.vertical;t.bucket.iconsInText||=!!y&&y.iconsInText,(y||_)&&zd(t.bucket,r,p,_,t.imageMap,n,c,f,m,g,t.canonical,t.subdivisionGranularity,t.hasPromoteId)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()}({bucket:this,glyphMap:i,glyphPositions:r,imageMap:n,imagePositions:s,showCollisionBoxes:o,canonical:e,subdivisionGranularity:t.subdivisionGranularity,hasPromoteId:null!=t.featureIndex.promoteId})}isEmpty(){return 0===this.symbolInstances.length}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){let i=this.lineVertexArray.length;if(void 0!==t.segment){let i=t.dist(e[t.segment+1]),r=t.dist(e[t.segment]),n={};for(let r=t.segment+1;r<e.length;r++)n[r]={x:e[r].x,y:e[r].y,tileUnitDistanceFromAnchor:i},r<e.length-1&&(i+=e[r+1].dist(e[r]));for(let i=t.segment||0;i>=0;i--)n[i]={x:e[i].x,y:e[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=e[i-1].dist(e[i]));for(let t=0;t<e.length;t++){let e=n[t];this.lineVertexArray.emplaceBack(e.x,e.y,e.tileUnitDistanceFromAnchor)}}return{lineStartIndex:i,lineLength:this.lineVertexArray.length-i}}addSymbols(t,e,i,r,n,s,o,a,l,h,u,c,f){let p=t.indexArray,d=t.layoutVertexArray,m=t.segments.prepareSegment(4*e.length,d,p,this.canOverlap?s.sortKey:void 0),_=this.glyphOffsetArray.length,g=m.vertexLength,y=this.allowVerticalPlacement&&2===o?Math.PI/2:0,v=s.text&&s.text.sections;for(let r=0;r<e.length;r++){let{tl:n,tr:o,bl:l,br:h,tex:u,pixelOffsetTL:_,pixelOffsetBR:g,minFontScaleX:w,minFontScaleY:b,glyphOffset:x,isSDF:D,sectionIndex:M}=e[r],E=m.vertexLength,A=x[1];jd(d,a.x,a.y,n.x,A+n.y,u.x,u.y,i,D,_.x,_.y,w,b,f),jd(d,a.x,a.y,o.x,A+o.y,u.x+u.w,u.y,i,D,g.x,_.y,w,b,f),jd(d,a.x,a.y,l.x,A+l.y,u.x,u.y+u.h,i,D,_.x,g.y,w,b,f),jd(d,a.x,a.y,h.x,A+h.y,u.x+u.w,u.y+u.h,i,D,g.x,g.y,w,b,f),Rd(t.dynamicLayoutVertexArray,a,y),p.emplaceBack(E,E+2,E+1),p.emplaceBack(E+1,E+2,E+3),m.vertexLength+=4,m.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(x[0]),(r===e.length-1||M!==e[r+1].sectionIndex)&&t.programConfigurations.populatePaintArrays(d.length,s,s.index,{imagePositions:{},canonical:c,formattedSection:v?.[M]})}t.placedSymbolArray.emplaceBack(a.x,a.y,_,this.glyphOffsetArray.length-_,g,l,h,a.segment,i?i[0]:0,i?i[1]:0,r[0],r[1],o,0,!1,0,u,f)}_addCollisionDebugVertex(t,e,i,r,n,s){return e.emplaceBack(0,0),t.emplaceBack(i.x,i.y,r,n,Math.round(s.x),Math.round(s.y))}addCollisionDebugVertices(t,e,i,r,n,s,o){let a=n.segments.prepareSegment(4,n.layoutVertexArray,n.indexArray),l=a.vertexLength,h=n.layoutVertexArray,u=n.collisionVertexArray,c=o.anchorX,p=o.anchorY;this._addCollisionDebugVertex(h,u,s,c,p,new f(t,e)),this._addCollisionDebugVertex(h,u,s,c,p,new f(i,e)),this._addCollisionDebugVertex(h,u,s,c,p,new f(i,r)),this._addCollisionDebugVertex(h,u,s,c,p,new f(t,r)),a.vertexLength+=4;let d=n.indexArray;d.emplaceBack(l,l+1),d.emplaceBack(l+1,l+2),d.emplaceBack(l+2,l+3),d.emplaceBack(l+3,l),a.primitiveLength+=4}addDebugCollisionBoxes(t,e,i,r){for(let n=t;n<e;n++){let t=this.collisionBoxArray.get(n);this.addCollisionDebugVertices(t.x1,t.y1,t.x2,t.y2,r?this.textCollisionBox:this.iconCollisionBox,t.anchorPoint,i)}}generateCollisionDebugBuffers(){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new Ld(xl,Mf.members,Fl),this.iconCollisionBox=new Ld(xl,Mf.members,Fl);for(let t=0;t<this.symbolInstances.length;t++){let 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,r,n,s,o,a,l){let h={};for(let r=e;r<i;r++){let e=t.get(r);h.textBox={x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,anchorPointX:e.anchorPointX,anchorPointY:e.anchorPointY},h.textFeatureIndex=e.featureIndex;break}for(let e=r;e<n;e++){let i=t.get(e);h.verticalTextBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.verticalTextFeatureIndex=i.featureIndex;break}for(let e=s;e<o;e++){let i=t.get(e);h.iconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.iconFeatureIndex=i.featureIndex;break}for(let e=a;e<l;e++){let i=t.get(e);h.verticalIconBox={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,anchorPointX:i.anchorPointX,anchorPointY:i.anchorPointY},h.verticalIconFeatureIndex=i.featureIndex;break}return h}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let e=0;e<this.symbolInstances.length;e++){let 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){let i=t.placedSymbolArray.get(e),r=i.vertexStartIndex+4*i.numGlyphs;for(let e=i.vertexStartIndex;e<r;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;let e=Math.sin(t),i=Math.cos(t),r=[],n=[],s=[];for(let t=0;t<this.symbolInstances.length;++t){s.push(t);let o=this.symbolInstances.get(t);r.push(0|Math.round(e*o.anchorX+i*o.anchorY)),n.push(o.featureIndex)}return s.sort(((t,e)=>r[t]-r[e]||n[e]-n[t])),s}addToSortKeyRanges(t,e){let i=this.sortKeyRanges[this.sortKeyRanges.length-1];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(let t of this.symbolInstanceIndexes){let e=this.symbolInstances.get(t);this.featureSortOrder.push(e.featureIndex);let i=[e.rightJustifiedTextSymbolIndex,e.centerJustifiedTextSymbolIndex,e.leftJustifiedTextSymbolIndex];for(let t=0;t<i.length;t++){let 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 Nd,Gd;Vo("SymbolBucket",Ud,{omit:["layers","collisionBoxArray","features","compareText"]});var qd={get paint(){return Gd||=new da({"icon-opacity":new ua(Ke.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new ua(Ke.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new ua(Ke.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new ua(Ke.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new ua(Ke.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new ha(Ke.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new ha(Ke.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new ua(Ke.paint_symbol["text-opacity"],"text-opacity"),"text-color":new ua(Ke.paint_symbol["text-color"],"text-color",{runtimeType:gi,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new ua(Ke.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new ua(Ke.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new ua(Ke.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new ha(Ke.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new ha(Ke.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return Nd||=new da({"symbol-placement":new ha(Ke.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new ha(Ke.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new ha(Ke.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new ua(Ke.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new ha(Ke.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new ha(Ke.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new ha(Ke.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new ha(Ke.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new ha(Ke.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new ua(Ke.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new ua(Ke.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new ha(Ke.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new ha(Ke.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new ua(Ke.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new ua(Ke.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new ua(Ke.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new ha(Ke.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new ua(Ke.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new ua(Ke.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new ha(Ke.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new ha(Ke.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new ha(Ke.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new ua(Ke.layout_symbol["text-field"],"text-field"),"text-font":new ua(Ke.layout_symbol["text-font"],"text-font"),"text-size":new ua(Ke.layout_symbol["text-size"],"text-size"),"text-max-width":new ua(Ke.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new ha(Ke.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new ua(Ke.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new ua(Ke.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new ua(Ke.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new ha(Ke.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new ua(Ke.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new ua(Ke.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new ha(Ke.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new ha(Ke.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new ua(Ke.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new ha(Ke.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new ha(Ke.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new ua(Ke.layout_symbol["text-transform"],"text-transform"),"text-offset":new ua(Ke.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new ha(Ke.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new ha(Ke.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new ha(Ke.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new ha(Ke.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new ua(Ke.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new ha(Ke.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})}},Vd=class{constructor(t){if(void 0===t.property.overrides)throw Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=t.property.overrides?t.property.overrides.runtimeType:pi,this.defaultValue=t}evaluate(t){if(t.formattedSection){let e=this.defaultValue.property.overrides;if(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}};Vo("FormatSectionOverride",Vd,{omit:["defaultValue"]});const Zd=t=>"symbol"===t.type;var Wd=class t extends ga{constructor(t,e){super(t,qd,e)}recalculate(t,e){super.recalculate(t,e);let i=this.layout.get("icon-rotation-alignment");if(("constant"!==i.value.kind||"auto"===i.value.value)&&(this.layout._values["icon-rotation-alignment"]=new sa(i.property,{kind:"constant",value:"point"===this.layout.get("symbol-placement")?"viewport":"map"},i.parameters)),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"===this.layout.get("symbol-placement")?"viewport":"map"),"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").constantOr("viewport")),"point"===this.layout.get("symbol-placement")){let t=this.layout.get("text-writing-mode");if(t){let e=[];for(let 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,r){let n=this.layout.get(t).evaluate(e,{},i,r),s=this._unevaluatedLayout._values[t];return s.isDataDriven()||As(s.value)||!n?n:function(t,e){return e.replace(/{([^{}]+)}/g,((e,i)=>t&&i in t?String(t[i]):""))}(e.properties,n)}createBucket(t){return new Ud(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of qd.paint.overridableProperties){if(!t.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new Ds(new Vd(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),n=null;n="constant"===i.value.kind||"source"===i.value.kind?new Ss("source",r):new Cs("composite",r,i.value.zoomStops),this.paint._values[e]=new sa(i.property,n,i.parameters)}}_handleOverridablePaintPropertyUpdate(e,i,r){return!(!this.layout||i.isDataDriven()||r.isDataDriven())&&t.hasPaintOverride(this.layout,e)}static hasPaintOverride(t,e){let i=t.get("text-field"),r=qd.paint.properties[e],n=!1,s=t=>{for(let e of t)if(r.overrides?.hasOverride(e))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof ar)s(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let t=e=>{n||(e instanceof br&&vr(e.value)===xi?s(e.value.sections):e instanceof Cr?s(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}};let Hd;var Yd={get paint(){return Hd||=new da({"background-color":new ha(Ke.paint_background["background-color"],"background-color"),"background-pattern":new fa(Ke.paint_background["background-pattern"],"background-pattern"),"background-opacity":new ha(Ke.paint_background["background-opacity"],"background-opacity")})}},Xd=class extends ga{constructor(t,e){super(t,Yd,e)}};const Jd=t=>"custom"===t.type;var Kd=class extends ga{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 Error("Custom layers cannot be serialized")}};function Qd(t,e){if("custom"===t.type)return new Kd(t,e);switch(t.type){case"background":return new Xd(t,e);case"circle":return new Nh(t,e);case"color-relief":return new uu(t,e);case"fill":return new dc(t,e);case"fill-extrusion":return new sf(t,e);case"heatmap":return new tu(t,e);case"hillshade":return new ru(t,e);case"line":return new vf(t,e);case"raster":return new ba(t,e);case"symbol":return new Wd(t,e)}}function tm(t){let e=[];if("string"==typeof t)e.push({id:"default",url:t});else if(t&&t.length>0){let i=[];for(let{id:r,url:n}of t){let t=`${r}${n}`;i.includes(t)||(i.push(t),e.push({id:r,url:n}))}}return e}function em(t,e,i){try{let r=new URL(t);return r.pathname+=`${e}${i}`,r.toString()}catch{throw Error(`Invalid sprite URL "${t}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}var im=class extends Re{constructor(){super(),this.images={},this.updateVersion=0,this.loaded=!1,this.requestors=[],this.missingImageResolver=null,this._spriteImagesIds={},this._imagesIds=null,this._renderCallbacksDispatchedThisFrame={}}destroy(){for(let t of Object.keys(this.images))this.removeImage(t);this._spriteImagesIds={}}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(let{ids:t,promiseResolve:e}of this.requestors)e(this._getImagesForIds(t));this.requestors=[]}}getImage(t){let e=this.images[t];if(e&&!e.data&&e.spriteData){let t=e.spriteData;e.data=new Xh({width:t.width,height:t.height},t.context.getImageData(t.x,t.y,t.width,t.height).data),e.spriteData=null}return e}addImage(t,e){if(this.images[t])throw Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,e)&&(this.images[t]=e,this._imagesIds=null,e.isWebGLImage&&this.updateImage(t,e,!1))}_validate(t,e){let i=!0,r=e.data||e.spriteData;return this._validateStretch(e.stretchX,r?.width)||(this.fire(new je(Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,r?.height)||(this.fire(new je(Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new je(Error(`Image "${t}" has invalid "content" value`))),i=!1),i}_validateStretch(t,e){if(!t)return!0;let i=0;for(let r of t){if(r[0]<i||r[1]<r[0]||e<r[1])return!1;i=r[1]}return!0}_validateContent(t,e){if(!t)return!0;if(4!==t.length)return!1;let i=e.spriteData,r=i?.width||e.data.width,n=i?.height||e.data.height;return!(t[0]<0||r<t[0]||t[1]<0||n<t[1]||t[2]<0||r<t[2]||t[3]<0||n<t[3]||t[2]<t[0])&&t[3]>=t[1]}updateImage(t,e,i=!0){let r=this.images[t];if(i){let t=r.data||r.spriteData;if(t.width!==e.data.width||t.height!==e.data.height)throw Error(`size mismatch between old image (${t.width}x${t.height}) and new image (${e.data.width}x${e.data.height}).`)}e.version=(r.version??0)+1,this.images[t]=e,this.updateVersion++}removeImage(t){let e=this.images[t];e&&(delete this.images[t],this._imagesIds=null,e.userImage?.onRemove&&e.userImage.onRemove())}listImages(){return this._imagesIds??=Object.keys(this.images),this._imagesIds}_getSpriteImageId(t,e){return"default"===t?e:`${t}:${e}`}setSpriteImages(t,e){let i=this._spriteImagesIds[t]??[],r=[];for(let i in e){let n=this._getSpriteImageId(t,i);r.push(n),n in this.images?this.updateImage(n,e[i],!1):this.addImage(n,e[i])}let n=new Set(r),s=i.filter((t=>!n.has(t)));for(let t of s)this.removeImage(t);return this._spriteImagesIds[t]=r,{loaded:r,removed:s}}removeSpriteImages(t){let e=this._spriteImagesIds[t]??[];for(let t of e)this.removeImage(t);return delete this._spriteImagesIds[t],e}removeAllSpriteImages(){let t=Object.values(this._spriteImagesIds).flat();for(let e of t)this.removeImage(e);return this._spriteImagesIds={},t}setMissingImageResolver(t){this.missingImageResolver=t}getImages(t){return new Promise((e=>{let i=!0;if(!this.isLoaded())for(let e of t)this.images[e]||(i=!1);this.isLoaded()||i?e(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:e})}))}async _getImagesForIds(t){let e=new Set(t.filter((t=>!this.getImage(t)))),i=this.missingImageResolver;i&&await Promise.allSettled(Array.from(e,(t=>i(t))));let r={};for(let i of t){let t=this.getImage(i);t&&(e.delete(i),r[i]={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:!!t.userImage?.render,isWebGLImage:t.isWebGLImage})}for(let t of e)this.fire(new Xe({id:t})),Lt(`Image "${t}" could not be loaded. Please make sure you have added the image before it is needed with map.addImage(), resolved it with map.setMissingStyleImageResolver(), or included it in a "sprite" property in your style.`);return r}beginFrame(){this._renderCallbacksDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(let e of t){if(this._renderCallbacksDispatchedThisFrame[e])continue;this._renderCallbacksDispatchedThisFrame[e]=!0;let t=this.getImage(e);t||Lt(`Image with ID: "${e}" was not found`),Pp(t)&&this.updateImage(e,t)}}cloneImages(){let t={};for(let e in this.images){let i=this.images[e];t[e]={...i,data:i.data?i.data.clone():null}}return t}},rm=class{constructor(t){this._imageManager=t,this._entries={},this._image=new Xh({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new Xh({width:1,height:1}),this._dirty=!0}getPixelSize(){let{width:t,height:e}=this._image;return{width:t,height:e}}getPattern(t){let e=this._imageManager.getImage(t);if(!e)return null;let i=this._entries[t];if(i?.image!==e){let i={w:e.data.width+2,h:e.data.height+2,x:0,y:0};this._entries[t]={bin:i,position:new kp(i,e),image:e}}else{if(i.position.version===e.version)return i.position;i.position.version=e.version}return this._update(),this._entries[t].position}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let e=this.getPattern(t.from.toString()),i=this.getPattern(t.to.toString());return!e||!i}bind(t){let e=t.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new au(t,this._image,e.RGBA),this._dirty=!1),this._texture.bind(e.LINEAR,e.CLAMP_TO_EDGE)}_update(){for(let t in this._entries)this._imageManager.getImage(t)||delete this._entries[t];let t=[];for(let e in this._entries)t.push(this._entries[e].bin);let{w:e,h:i}=Ip(t),r=this._image;r.resize({width:e||1,height:i||1});for(let t in this._entries){let{bin:e}=this._entries[t],i=e.x+1,n=e.y+1,s=this._entries[t].image.data,o=s.width,a=s.height;Xh.copy(s,r,{x:0,y:0},{x:i,y:n},{width:o,height:a}),Xh.copy(s,r,{x:0,y:a-1},{x:i,y:n-1},{width:o,height:1}),Xh.copy(s,r,{x:0,y:0},{x:i,y:n+a},{width:o,height:1}),Xh.copy(s,r,{x:o-1,y:0},{x:i-1,y:n},{width:1,height:a}),Xh.copy(s,r,{x:0,y:0},{x:i+o,y:n},{width:1,height:a})}this._dirty=!0}};const nm=1114111,sm={start:0,end:nm};let om=0;function am(t){let e=/^u\+([0-9a-f]*)(\?+)$/i.exec(t);if(e){let[,t,i]=e;return t.length+i.length>6?null:lm(parseInt(`${t}${"0".repeat(i.length)}`,16),parseInt(`${t}${"f".repeat(i.length)}`,16))}let i=/^u\+([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?$/i.exec(t);if(!i)return null;let r=parseInt(i[1],16);return lm(r,void 0===i[2]?r:parseInt(i[2],16))}function lm(t,e){return t>e||t>nm?null:{start:t,end:Math.min(e,nm)}}function hm(t,e){return t.ranges.some((({start:t,end:i})=>e>=t&&e<=i))}var um=class{constructor(t){this.requestManager=t,this._faces={},this._registered=new Set}setFontFaces(t){this._unregisterAll(),this._faces={};for(let[e,i]of Object.entries(t??{})){let t=Array.isArray(i)?i:[i];this._faces[e]=t.map((t=>this._declareFontFace(e,t))).filter((t=>null!==t))}}hasFontFaces(){return Object.keys(this._faces).length>0}async getFontFamily(t,e){for(let i of t.split(","))for(let t of this._faces[i.trim()]??[])if(hm(t,e)&&(t.loaded??=this._loadFontFace(t),await t.loaded))return t.family;return null}_declareFontFace(t,e){let i="string"==typeof e?{url:e}:e;if("string"!=typeof i?.url)return Lt(`Ignoring the font face declared for "${t}": it has no URL.`),null;let r="maplibre-gl-font-face-"+om++,n=i["unicode-range"];if(!n?.length)return{url:i.url,ranges:[sm],family:r};let s=[];for(let t of n){let e=am(t);e?s.push(e):Lt(`Ignoring the unicode range "${t}" of the font face at ${i.url}: it is not a valid range.`)}return s.length?{url:i.url,ranges:s,family:r}:null}async _loadFontFace(t){if(typeof FontFace>"u"||typeof document>"u"||!document.fonts)return Lt(`Ignoring the font face at ${t.url}: this environment has no CSS Font Loading API.`),!1;let e;try{return e=new FontFace(t.family,await this._downloadFontFile(t.url)),!!Object.values(this._faces).some((e=>e.includes(t)))&&(document.fonts.add(e),this._registered.add(e),await e.load(),!0)}catch(i){return e&&this._unregister(e),Lt(`Ignoring the font face at ${t.url}: ${at(i).message}`),!1}}async _downloadFontFile(t){let e=await this.requestManager.transformRequest(t,"Glyphs"),i=await Ce(e,new AbortController);if(!i?.data)throw Error(`the response was empty for the font file at ${t}`);return i.data}_unregister(t){document.fonts?.delete(t),this._registered.delete(t)}_unregisterAll(){for(let t of this._registered)document.fonts?.delete(t);this._registered.clear()}destroy(){this._unregisterAll(),this._faces={}}};const cm=1e20,fm=new Float64Array(256);for(let t=0;t<256;t++){let e=.5-(t/255)**(1/2.2);fm[t]=e*Math.abs(e)}fm[255]=-1e20;var pm=class{constructor({fontSize:t=24,buffer:e=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:s="normal",fontStyle:o="normal",lang:a=null}={}){this.buffer=e,this.radius=i,this.cutoff=r,this.lang=a;let l=this.size=t+4*e,h=this._createCanvas(l),u=this.ctx=h.getContext("2d",{willReadFrequently:!0});u.font=`${o} ${s} ${t}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(t,t);let e=document.createElement("canvas");return e.width=e.height=t,e}draw(t){let{width:e,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:s}=this.ctx.measureText(t),o=Math.ceil(i),a=Math.floor(-n),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(s)-a)),h=Math.max(0,Math.min(this.size-this.buffer,o+Math.ceil(r))),u=l+2*this.buffer,c=h+2*this.buffer,f=Math.max(u*c,0),p=new Uint8ClampedArray(f),d={data:p,width:u,height:c,glyphWidth:l,glyphHeight:h,glyphTop:o,glyphLeft:a,glyphAdvance:e};if(0===l||0===h)return d;let{ctx:m,buffer:_,gridInner:g,gridOuter:y}=this;this.lang&&(m.lang=this.lang),m.clearRect(_,_,l,h),m.fillText(t,_-a,_+o);let v=m.getImageData(_,_,l,h);y.fill(cm,0,f),g.fill(0,0,f);let w=3;for(let t=0;t<h;t++){let e=(t+_)*u+_;for(let t=0;t<l;t++,w+=4,e++){let t=v.data[w];if(0===t)continue;let i=fm[t];y[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}dm(y,0,0,u,c,u,this.f,this.v,this.z);let b=Math.min(_,1);dm(g,_-b,_-b,l+2*b,h+2*b,u,this.f,this.v,this.z);let x=255/this.radius,D=255*(1-this.cutoff);for(let t=0;t<f;t++){let e=Math.sqrt(y[t])-Math.sqrt(g[t]);p[t]=Math.round(D-x*e)}return d}};function dm(t,e,i,r,n,s,o,a,l){for(let h=e;h<e+r;h++)mm(t,i*s+h,s,n,o,a,l);for(let h=i;h<i+n;h++)mm(t,h*s+e,1,r,o,a,l)}function mm(t,e,i,r,n,s,o){s[0]=0,o[0]=-1e20,o[1]=cm,n[0]=t[e];for(let a=1,l=0,h=0;a<r;a++){n[a]=t[e+a*i];let r=a*a;do{let t=s[l];h=(n[a]-n[t]+r-t*t)/(a-t)/2}while(h<=o[l]&&--l>-1);l++,s[l]=a,o[l]=h,o[l+1]=cm}for(let a=0,l=0;a<r;a++){for(;o[l+1]<a;)l++;let r=s[l],h=a-r;t[e+a*i]=n[r]+h*h}}const _m=Ke.layout_symbol["text-font"].default.join(","),gm=(t,e)=>{let i=new pm(t);return i.buffer=e,i};var ym=class{constructor(t,e,i,r=gm){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={},this.lang=i,this.fontFaceManager=new um(t),this.createRasterizer=r}setURL(t){this.url=t}setFontFaces(t){this.fontFaceManager.setFontFaces(t),this.entries={}}async getGlyphs(t){let e=[];for(let i in t)for(let r in t[i])for(let n of t[i][r])e.push(this._getAndCacheGlyphsPromise(i,n,r));let i=await Promise.all(e),r={};for(let{stack:t,id:e,variant:n,glyph:s}of i)r[t]||={},r[t][n]||={},r[t][n][e]=s&&{id:s.id,bitmap:s.bitmap.clone(),metrics:s.metrics};return r}async _getAndCacheGlyphsPromise(t,e,i){this.entries[t]??={glyphs:{default:{}},requests:{},ranges:{}};let r=this.entries[t],n=r.glyphs[i]||={},s=n[e];if(void 0!==s)return{stack:t,id:e,variant:i,glyph:s};if("default"!==i)return n[e]=null,{stack:t,id:e,variant:i,glyph:null};let o=e.codePointAt(0),a=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(t,o):null;return a?(s=n[e]=await this._drawGlyph(r,t,e,a),{stack:t,id:e,variant:i,glyph:s}):!this.url||tp(e)||this._charUsesLocalIdeographFontFamily(o)?(s=n[e]=await this._drawGlyph(r,t,e),{stack:t,id:e,variant:i,glyph:s}):{...await this._downloadAndCacheRangePromise(t,e),variant:i}}async _downloadAndCacheRangePromise(t,e){let i=e.codePointAt(0),r=this.entries[t],n=Math.floor(i/256);if(r.ranges[n])return{stack:t,id:e,glyph:null};r.requests[n]||=this._loadGlyphRange(t,n);try{let s=await r.requests[n];for(let t in s)r.glyphs.default[String.fromCodePoint(+t)]=s[+t];return r.ranges[n]=!0,{stack:t,id:e,glyph:s[i]||null}}catch(s){let o=r.glyphs.default[e]=await this._drawGlyph(r,t,e);return this._warnOnMissingGlyphRange(o,n,i,at(s)),{stack:t,id:e,glyph:o}}}async _loadGlyphRange(t,e){let i=256*e,r=i+255,n=await this.requestManager.transformRequest(this.url.replace("{fontstack}",t).replace("{range}",`${i}-${r}`),"Glyphs"),s=await Ce(n,new AbortController);if(!s?.data)throw Error(`Could not load glyph range. range: ${e}, ${i}-${r}`);let o={};for(let t of function(t){return new Fp(t).readFields(Sp,[])}(s.data))o[t.id]=t;return o}_warnOnMissingGlyphRange(t,e,i,r){let n=256*e;Lt(`Unable to load glyph range ${e}, ${n}-${n+255}. Rendering codepoint U+${i.toString(16).padStart(4,"0").toUpperCase()} locally instead. ${r}`)}_charUsesLocalIdeographFontFamily(t){return!!this.localIdeographFontFamily&&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)}async _drawGlyph(t,e,i,r){let n=(await this._getTinySDF(t,e,i,r)).draw(i),s=/^\p{gc=Cf}+$/u.test(i);return{id:i.codePointAt(0),bitmap:new Yh({width:n.width||60,height:n.height||60},n.data),metrics:{width:s?0:n.glyphWidth/2||24,height:n.glyphHeight/2||24,left:n.glyphLeft/2+.5||0,top:n.glyphTop/2-27.5||-8,advance:s?0:n.glyphAdvance/2||24,isDoubleResolution:!0}}}_getTinySDF(t,e,i,r){let n=tp(i);if(r){let e=n?"clusterTinySDFs":"fontFaceTinySDFs";return t[e]??={},t[e][r]||=this._createTinySDF(r,!1,n?3:1),t[e][r]}let s=e===_m&&""!==this.localIdeographFontFamily&&this._charUsesLocalIdeographFontFamily(i.codePointAt(0)),o=s?this.localIdeographFontFamily:e;if(n)return t.clusterTinySDFs??={},t.clusterTinySDFs[o]||=this._createTinySDF(o,!0,3),t.clusterTinySDFs[o];let a=s?"ideographTinySDF":"tinySDF";return t[a]||=this._createTinySDF(o),t[a]}async _createTinySDF(t,e=!0,i=1){let r=t?t.split(","):[];r.push("sans-serif");let n=r.map((t=>/[-\w]+/.test(t)?t:`'${CSS.escape(t)}'`)).join(","),s=e?this._fontWeight(r[0]):void 0,o=e?this._fontStyle(r[0]):"normal";if(typeof document<"u"&&document.fonts?.load)try{await document.fonts.load(`${o} ${s||"normal"} 48px ${n}`)}catch(t){Lt(`Failed to load font "${n}": ${at(t).message}`)}return this.createRasterizer({fontSize:48,buffer:Math.max(6,Math.ceil(48*(i-1)/4)),radius:16,cutoff:.25,fontFamily:n,fontWeight:s,fontStyle:o,lang:this.lang},6)}_fontStyle(t){return/italic/i.test(t)?"italic":/oblique/i.test(t)?"oblique":"normal"}_fontWeight(t){let e,i={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};for(let[r,n]of Object.entries(i))RegExp(`\\b${r}\\b`,"i").test(t)&&(e=`${n}`);return e}destroy(){for(let t in this.entries){let e=this.entries[t];e.tinySDF=null,e.ideographTinySDF=null,e.fontFaceTinySDFs={},e.glyphs={default:{}},e.requests={},e.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let vm;var wm=class extends Re{constructor(t,e){super(),this._transitionable=new ea(vm||=new da({anchor:new ha(Ke.light.anchor,"anchor"),position:new ha(Ke.light.position,"position"),color:new ha(Ke.light.color,"color"),intensity:new ha(Ke.light.intensity,"intensity")}),"light",e),this.setLight(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ko(0))}getLight(){return this._transitionable.serialize()}getEvaluated(){return{anchor:this.properties.get("anchor"),position:this.properties.get("position"),color:this.properties.get("color"),intensity:this.properties.get("intensity")}}setLight(t,e={}){this._validate(Oo.light,t,e)||this._transitionable.setValues(t)}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(t,e,i){this._transitioning=this._transitionable.applyGlobalStateChange(t,e,this._transitioning,i)}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return No(this,t,{value:e},i)}};let bm;var xm=class extends Re{constructor(t,e){super(),this._transitionable=new ea(bm||=new da({"sky-color":new ha(Ke.sky["sky-color"],"sky-color"),"horizon-color":new ha(Ke.sky["horizon-color"],"horizon-color"),"fog-color":new ha(Ke.sky["fog-color"],"fog-color"),"fog-ground-blend":new ha(Ke.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new ha(Ke.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new ha(Ke.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new ha(Ke.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",e),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ko(0))}setSky(t,e={}){return!this._validate(Oo.sky,t,e)&&(t||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},this._transitionable.setValues(t),!0)}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}applyGlobalStateChange(t,e,i){this._transitioning=this._transitionable.applyGlobalStateChange(t,e,this._transitioning,i)}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i={}){return No(this,t,{value:e},i)}getEvaluated(){return{"sky-color":this.properties.get("sky-color"),"horizon-color":this.properties.get("horizon-color"),"fog-color":this.properties.get("fog-color"),"fog-ground-blend":this.properties.get("fog-ground-blend"),"horizon-fog-blend":this.properties.get("horizon-fog-blend"),"sky-horizon-blend":this.properties.get("sky-horizon-blend"),"atmosphere-blend":this.properties.get("atmosphere-blend")}}};function Dm(t){return t<60?0:t<70?(t-60)/10:1}var Mm=class{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){let i=t.join(",")+String(e);return this.dashEntry[i]||=this.addDash(t,e),this.dashEntry[i]}getDashRanges(t,e,i){let r=[],n=t.length%2==1?-t[t.length-1]*i:0,s=t[0]*i,o=!0;r.push({left:n,right:s,isDash:o,zeroLength:0===t[0]});let a=t[0];for(let e=1;e<t.length;e++){o=!o;let l=t[e];n=a*i,a+=l,s=a*i,r.push({left:n,right:s,isDash:o,zeroLength:0===l})}return r}addRoundDash(t,e,i){let r=e/2;for(let e=-i;e<=i;e++){let n=this.width*(this.nextRow+i+e),s=0,o=t[s];for(let a=0;a<this.width;a++){a/o.right>1&&(o=t[++s]);let l,h=Math.abs(a-o.left),u=Math.abs(a-o.right),c=Math.min(h,u),f=e/i*(r+1);if(o.isDash){let t=r-Math.abs(f);l=Math.sqrt(c*c+t*t)}else l=r-Math.sqrt(c*c+f*f);this.data[n+a]=Math.max(0,Math.min(255,l+128))}}}addRegularDash(t){for(let e=t.length-1;e>=0;--e){let i=t[e],r=t[e+1];i.zeroLength?t.splice(e,1):r?.isDash===i.isDash&&(r.left=i.left,t.splice(e,1))}let e=t[0],i=t[t.length-1];e.isDash===i.isDash&&(e.left=i.left-this.width,i.right=e.right+this.width);let r=this.width*this.nextRow,n=0,s=t[n];for(let e=0;e<this.width;e++){e/s.right>1&&(s=t[++n]);let i=Math.abs(e-s.left),o=Math.abs(e-s.right),a=Math.min(i,o);this.data[r+e]=Math.max(0,Math.min(255,(s.isDash?a:-a)+128))}}addDash(t,e){let i=e?7:0,r=2*i+1;if(this.nextRow+r>this.height)return Lt("LineAtlas out of space"),null;let n=0;for(let e of t)n+=e;if(0!==n){let r=this.width/n,s=this.getDashRanges(t,this.width,r);e?this.addRoundDash(s,r,i):this.addRegularDash(s)}let s={y:this.nextRow+i,height:2*i,width:n};return this.nextRow+=r,this.dirty=!0,s}bind(t){let 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))}},Em=class{constructor(t){this._methodToThrottle=t,this._triggered=!1,this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()}}trigger(){this._triggered||(this._triggered=!0,this._channel?.port1.postMessage(!0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}};const Am={once:!0};var Fm=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Em((()=>this.process())),this.subscription=Wt(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=qt(self)?t:window}registerMessageHandler(t,e){this.messageHandlers[t]=e}unregisterMessageHandler(t){delete this.messageHandlers[t]}sendAsync(t,e){return new Promise(((i,r)=>{let n=Math.round(1e18*Math.random()).toString(36).substring(0,10),s=e?Wt(e.signal,"abort",(()=>{s?.unsubscribe(),delete this.resolveRejects[n];let i={id:n,type:"<cancel>",origin:location.origin,targetMapId:t.targetMapId,sourceMapId:this.mapId};this.target.postMessage(i),r(new oe(e.signal.reason))}),Am):null;this.resolveRejects[n]={resolve:t=>{s?.unsubscribe(),i(t)},reject:t=>{s?.unsubscribe(),r(t)}};let o=[],a={...t,id:n,sourceMapId:this.mapId,origin:location.origin,data:Yo(t.data,o)};this.target.postMessage(a,{transfer:o})}))}receive(t){let e=t.data,i=e.id,r=["file://","resource://android","null"],n=[e.origin,location.origin],s=e.origin===location.origin,o=n.some((t=>r.includes(t)));if((s||o)&&(!e.targetMapId||this.mapId===e.targetMapId)){if("<cancel>"===e.type){delete this.tasks[i];let t=this.abortControllers[i];return delete this.abortControllers[i],void(t&&t.abort())}if(qt(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;let t=this.taskQueue.shift(),e=this.tasks[t];delete this.tasks[t],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(t,e)}async processTask(t,e){if("<response>"===e.type){let i=this.resolveRejects[t];if(delete this.resolveRejects[t],!i)return;return void(e.error?i.reject(at(Xo(e.error))):i.resolve(Xo(e.data)))}if(!this.messageHandlers[e.type])return void this.completeTask(t,null,null);let i=Xo(e.data),r=new AbortController;this.abortControllers[t]=r;try{let n=await this.messageHandlers[e.type](e.sourceMapId,i,r);this.completeTask(t,null,n)}catch(e){this.completeTask(t,at(e))}}completeTask(t,e,i){let r=[];delete this.abortControllers[t];let n={id:t,type:"<response>",sourceMapId:this.mapId,origin:location.origin,error:e?Yo(e):null,data:Yo(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function Sm(t,e){if(e)try{return new Worker(t,{type:"module"})}catch(t){console.warn("Module worker not supported, falling back to classic worker",t)}return new Worker(t)}async function Cm(){let t=function(){let t=import.meta.url;if(!/^https?:/.test(t))return"";let e=t.endsWith("-dev.mjs")?"maplibre-gl-worker-dev.mjs":"maplibre-gl-worker.mjs",i=new URL(`./${e}`,t);return i.searchParams.set("v",c),i.href}(),e=!function(t){return t.split(/[?#]/)[0].endsWith(".cjs")}(t);if(!function(t){if(!t)return!1;let e=globalThis.location;if(!e)return!1;try{return new URL(t,e.href).origin!==e.origin}catch{return!1}}(t))return Sm(t,e);if(e){let i=function(t){let e=new Blob([`import ${JSON.stringify(new URL(t,import.meta.url).href)}`],{type:"text/javascript"});return URL.createObjectURL(e)}(t);try{return Sm(i,e)}finally{URL.revokeObjectURL(i)}}let i=await async function(t){let e=await fetch(t);if(!e.ok)throw Error(`Failed to fetch worker script (${e.status}): ${t}`);let i=await e.text(),r=new Blob([i],{type:"text/javascript"});return URL.createObjectURL(r)}(t);try{return Sm(i,e)}finally{URL.revokeObjectURL(i)}}var zm=class t{constructor(){this.active={},this.workersPromise=null}async acquire(e){if(this.active[e]=!0,!this.workersPromise){let e=[];for(;e.length<t.workerCount;)e.push(Cm());this.workersPromise=Promise.all(e)}return(await this.workersPromise).slice()}release(t){if(delete this.active[t],0===this.numActive()&&this.workersPromise){let t=this.workersPromise;this.workersPromise=null,t.then((t=>{for(let e of t)e.terminate()}))}}isPreloaded(){return!!this.active.maplibre_preloaded_worker_pool}numActive(){return Object.keys(this.active).length}};const Tm=Math.floor(fe.hardwareConcurrency/2);let Pm;function Im(){return Pm||=new zm,Pm}zm.workerCount=function(t){if(null==Vt){let e=t.navigator?t.navigator.userAgent:null;Vt=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Vt}(globalThis)?Math.max(Math.min(Tm,3),1):1;var km=class extends Re{constructor(t,e){super(),this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e,this.removed=!1,this.workerErrorSubscriptions=[],this.actorsPromise=this.initActors(e)}async initActors(t){let e=await this.workerPool.acquire(t);if(this.removed)return[];if(this.actors=e.map(((e,i)=>{this.workerErrorSubscriptions.push(Wt(e,"error",(()=>{this.fire(new je(Error("Worker failed to load. Check that the worker URL is correct.")))}),!1));let r=new Fm(e,t);return r.name=`Worker ${i}`,r})),!this.actors.length)throw Error("No actors found");return this.actors}async broadcast(t,e){let i=await this.actorsPromise;return Promise.all(i.map((i=>i.sendAsync({type:t,data:e}))))}async getActor(){let t=await this.actorsPromise;return this.currentActor=(this.currentActor+1)%t.length,t[this.currentActor]}async waitForInitComplete(){0===this.actors.length&&await this.actorsPromise}getReadyActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(t=!0){this.removed=!0;for(let t of this.actors)t.remove();for(let t of this.workerErrorSubscriptions)t.unsubscribe();this.actors=[],this.workerErrorSubscriptions=[],this.setEventedParent(null),t&&this.workerPool.release(this.id)}async registerMessageHandler(t,e){let i=await this.actorsPromise;for(let r of i)r.registerMessageHandler(t,e)}async unregisterMessageHandler(t){let e=await this.actorsPromise;for(let i of e)i.unregisterMessageHandler(t)}};let $m;function jm(t,e){let i=w();E(i,i,[1,1,0]),A(i,i,[.5*t.width,.5*t.height,1]);let r=t.getFastPathSimpleProjectionMatrix(e);return r?M(i,i,r):i}function Rm(t,e,i,r,n,s,o){let a=function(t,e,i){if(t)for(let r of t){let t=e[r];if(t?.source===i&&"fill-extrusion"===t.type)return!0}else for(let t in e){let r=e[t];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(n?.layers??null,e,t.id),l=s.maxPitchScaleFactor(),h=t.tilesIn(r,l,a);h.sort(Om);let u=[];for(let r of h)u.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(e,i,t.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,n,s,l,jm(s,r.tileID),o?(t,e)=>o(r.tileID,t,e):void 0)});return function(t,e){for(let i in t)for(let r of t[i])Bm(r,e);return t}(function(t){let e={},i={};for(let{queryResults:r,wrappedTileID:n}of t){i[n]||={};let t=i[n];for(let i in r){let n=r[i];t[i]||={};let s=t[i];e[i]||=[];for(let t of n)s[t.featureIndex]||(s[t.featureIndex]=!0,e[i].push(t))}}return e}(u),t)}function Om(t,e){let i=t.tileID,r=e.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Bm(t,e){let i=t.feature,r=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=r}async function Lm(t,e,i,r){let n=t;if(t.url?n=(await Se(await e.transformRequest(t.url,"Source"),i)).data:await fe.frameAsync(i,r),!n)return null;let s=Ct(St(n,t),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(s.vectorLayerIds=n.vector_layers.map((t=>t.id))),s}var Um=class t{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 Cc?new Cc(t.lng,t.lat):Cc.convert(t),this}setSouthWest(t){return this._sw=t instanceof Cc?new Cc(t.lng,t.lat):Cc.convert(t),this}extend(e){let i,r,n=this._sw,s=this._ne;if(e instanceof Cc)i=e,r=e;else{if(!(e instanceof t))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(t.convert(e)):this.extend(Cc.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(Cc.convert(e)):this;if(i=e._sw,r=e._ne,!i||!r)return this}return n||s?(n.lng=Math.min(i.lng,n.lng),n.lat=Math.min(i.lat,n.lat),s.lng=Math.max(r.lng,s.lng),s.lat=Math.max(r.lat,s.lat)):(this._sw=new Cc(i.lng,i.lat),this._ne=new Cc(r.lng,r.lat)),this}getCenter(){return new Cc((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 Cc(this.getWest(),this.getNorth())}getSouthEast(){return new Cc(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){let{lng:e,lat:i}=Cc.convert(t),r=this._sw.lng<=e&&e<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=e&&e>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}intersects(e){if(!((e=t.convert(e)).getNorth()>=this.getSouth()&&e.getSouth()<=this.getNorth()))return!1;let i=Math.abs(this.getEast()-this.getWest()),r=Math.abs(e.getEast()-e.getWest());if(i>=360||r>=360)return!0;let n=Ft(this.getWest(),-180,180),s=Ft(this.getEast(),-180,180),o=Ft(e.getWest(),-180,180),a=Ft(e.getEast(),-180,180),l=n>s,h=o>a;return!(!l||!h)||(l?a>=n||o<=s:h?s>=o||n<=a:o<=s&&a>=n)}static convert(e){return e instanceof t||!e?e:new t(e)}static fromLngLat(e,i=0){let r=360*i/40075017,n=r/Math.cos(Math.PI/180*e.lat);return new t(new Cc(e.lng-n,e.lat-r),new Cc(e.lng+n,e.lat+r))}adjustAntiMeridian(){let e=new Cc(this._sw.lng,this._sw.lat),i=new Cc(this._ne.lng,this._ne.lat);return new t(e,e.lng>i.lng?new Cc(i.lng+360,i.lat):i)}},Nm=class{constructor(t,e,i){this.bounds=Um.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){let e=2**t.z,i=Math.floor(Pc(this.bounds.getWest())*e),r=Math.floor(Ic(this.bounds.getNorth())*e),n=Math.ceil(Pc(this.bounds.getEast())*e),s=Math.ceil(Ic(this.bounds.getSouth())*e);return t.x>=i&&t.x<n&&t.y>=r&&t.y<s}},Gm=class extends Re{constructor(t,e,i,r){if(super(),this.id=t,this.dispatcher=i,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,St(this,Ct(e,["url","scheme","tileSize","promoteId","encoding"])),this._options=St({type:"vector"},e),this._collectResourceTiming=e.collectResourceTiming,512!==this.tileSize)throw Error("vector tile sources must have a tileSize of 512");this.setEventedParent(r)}async load(t=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Lm(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(St(this,e),e.bounds&&(this.tileBounds=new Nm(e.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,ae(t)||this.fire(new je(at(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.tiles=t,this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}serialize(){return St({},this._options)}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:await 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:await this._getOverzoomParameters(t),etag:t.etag};if(i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete(),t.aborted)return;let r="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.getReadyActor(),r="LT";t.abortController=new AbortController;try{let e=await t.actor.sendAsync({type:r,data:i},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,e);let n={};return e?.etagUnmodified&&(n.unmodified=!0),n}catch(e){if(delete t.abortController,t.aborted||ae(e))return;if(e&&404!==e.status)throw e;this._afterTileLoadWorkerResponse(t,null)}}async _getOverzoomParameters(t){if(t.tileID.canonical.z<=this.maxzoom||void 0===this.map._zoomLevelsToOverscale)return;let e=t.tileID.scaledTo(this.maxzoom).canonical,i=e.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:e,overzoomRequest:await this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(t,e){if(e?.resourceTiming&&(t.resourceTiming=e.resourceTiming),e&&this.map._refreshExpiredTiles&&t.setExpiryData(e),t.etag=e?.etag,t.loadVectorData(e,this.map.style),t.reloadPromise){let e=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(e.resolve).catch(e.reject)}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&await t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}})}async unloadTile(t){t.unloadVectorData(),t.actor&&await t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}hasTransition(){return!1}},qm=class extends Re{constructor(t,e,i,r){super(),this.id=t,this.dispatcher=i,this.setEventedParent(r),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._premultiplyAlpha=!0,this._options=St({type:"raster"},e),St(this,Ct(e,["url","scheme","tileSize"]))}async load(t=!1){this._loaded=!1,this.fire(new Ne("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Lm(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(St(this,e),e.bounds&&(this.tileBounds=new Nm(e.bounds,this.minzoom,this.maxzoom)),this.fire(new Ne("data",{sourceDataType:"metadata"})),this.fire(new Ne("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,ae(t)||this.fire(new je(at(t)))}}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null)}setSourceProperty(t){this._tileJSONRequest&&=(this._tileJSONRequest.abort(),null),t(),this.load(!0)}setTiles(t){return this.setSourceProperty((()=>{this.tiles=t,this._options.tiles=t})),this}setUrl(t){return this.setSourceProperty((()=>{this.url=t,this._options.url=t})),this}serialize(){return St({},this._options)}setPremultiplyAlpha(t){return this._premultiplyAlpha===t||this.setSourceProperty((()=>{this._premultiplyAlpha=t})),this}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i=this._premultiplyAlpha,r=i?void 0:{premultiplyAlpha:"none"};t.abortController=new AbortController;try{let n=await Te.transformAndGetImage(this.map._requestManager,e,"Tile",t.abortController,this.map._refreshExpiredTiles,r);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(n){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&t.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});let e=this.map.painter.context,r=e.gl,s=n.data??new Xh({width:1,height:1},new Uint8Array(4));t.texture=this.map.painter.getTileTexture(s.width),t.texture?t.texture.update(s,{useMipmap:!0,premultiply:i}):(t.texture=new au(e,s,r.RGBA,{useMipmap:!0,premultiply:i}),t.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.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}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController)}async unloadTile(t){t.texture&&this.map.painter.saveTileTexture(t.texture)}hasTransition(){return!1}};function Vm(t,e){let{x:i,y:r}=Oc.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)}var Zm=class{constructor(t,e,i){if(!function(t,e,i){return!(t<0||t>25||i<0||i>=2**t||e<0||e>=2**t)}(t,e,i))throw Error(`x=${e}, y=${i}, z=${t} outside of bounds. 0<=x<${2**t}, 0<=y<${2**t} 0<=z<=25 `);this.z=t,this.x=e,this.y=i,this.key=Ym(0,t,t,e,i)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,e,i){let r=function(t,e,i){let r=Jm(256*t,256*(e=2**i-e-1),i),n=Jm(256*(t+1),256*(e+1),i);return`${r[0]},${r[1]},${n[0]},${n[1]}`}(this.x,this.y,this.z),n=function(t,e,i){let r="";for(let n=t;n>0;n--){let t=1<<n-1;r+=(e&t?1:0)+(i&t?2:0)}return r}(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?2**this.z-this.y-1:this.y)).replace(/{ratio}/g,e>1?"@2x":"").replace(/{quadkey}/g,n).replace(/{bbox-epsg-3857}/g,r)}isChildOf(t){let e=this.z-t.z;return e>0&&t.x===this.x>>e&&t.y===this.y>>e}getTilePoint(t){let e=2**this.z;return new f((t.x*e-this.x)*st,(t.y*e-this.y)*st)}toString(){return`${this.z}/${this.x}/${this.y}`}},Wm=class{constructor(t,e){this.wrap=t,this.canonical=e,this.key=Ym(t,e.z,e.z,e.x,e.y)}},Hm=class t{constructor(t,e,i,r,n){if(this.terrainRttPosMatrix32f=null,t<i)throw Error(`overscaledZ should be >= z; overscaledZ = ${t}; z = ${i}`);this.overscaledZ=t,this.wrap=e,this.canonical=new Zm(i,+r,+n),this.key=Ym(e,t,i,r,n)}clone(){return new t(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(e){if(e>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-e;return e>this.canonical.z?new t(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new t(e,this.wrap,e,this.canonical.x>>i,this.canonical.y>>i)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(t,e){if(t>this.overscaledZ)throw Error(`targetZ > this.overscaledZ; targetZ = ${t}; overscaledZ = ${this.overscaledZ}`);let i=this.canonical.z-t;return t>this.canonical.z?Ym(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):Ym(this.wrap*+e,t,t,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(t){if(t.wrap!==this.wrap||this.overscaledZ-t.overscaledZ<=0)return!1;if(0===t.overscaledZ)return this.overscaledZ>0;let 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(e){if(this.overscaledZ>=e)return[new t(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];let i=this.canonical.z+1,r=2*this.canonical.x,n=2*this.canonical.y;return[new t(i,this.wrap,i,r,n),new t(i,this.wrap,i,r+1,n),new t(i,this.wrap,i,r,n+1),new t(i,this.wrap,i,r+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 t(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(e){return new t(this.overscaledZ,e,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return 2**(this.overscaledZ-this.canonical.z)}toUnwrapped(){return new Wm(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new Oc(t.x-this.wrap,t.y))}normalizeCoordinates(e,i,r=st){if(e>=0&&e<r&&i>=0&&i<r)return{tileID:this,x:e,y:i};let n=Math.floor(e/r),s=Math.floor(i/r),o=e-n*r,a=i-s*r,l=this.canonical.z,h=1<<l,u=this.canonical.y+s;if(u<0||u>=h)return null;let c=this.canonical.x+n,f=this.wrap;return c<0?(f-=Math.ceil(-c/h),c=(c%h+h)%h):c>=h&&(f+=Math.floor(c/h),c%=h),{tileID:new t(this.overscaledZ,f,l,c,u),x:o,y:a}}};function Ym(t,e,i,r,n){(t*=2)<0&&(t=-1*t-1);let s=1<<i;return(s*s*t+s*n+r).toString(36)+i.toString(36)+e.toString(36)}const Xm=6378137*Math.PI;function Jm(t,e,i){let r=2*Xm/256/2**i;return[t*r-Xm,e*r-Xm]}function Km(t,e){let i=Math.abs(2*t.wrap)-+(t.wrap<0),r=Math.abs(2*e.wrap)-+(e.wrap<0);return t.overscaledZ-e.overscaledZ||r-i||e.canonical.y-t.canonical.y||e.canonical.x-t.canonical.x}Vo("CanonicalTileID",Zm),Vo("OverscaledTileID",Hm,{omit:["terrainRttPosMatrix32f"]});var Qm=class extends qm{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=St({type:"raster-dem"},e),this.encoding=e.encoding||"mapbox",this.redFactor=e.redFactor,this.greenFactor=e.greenFactor,this.blueFactor=e.blueFactor,this.baseShift=e.baseShift}async loadTile(t){let e=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{let i=await Te.transformAndGetImage(this.map._requestManager,e,"Tile",t.abortController,this.map._refreshExpiredTiles,{colorSpaceConversion:"none"});if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(i){if(this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&t.setExpiryData({cacheControl:i.cacheControl,expires:i.expires}),!i.data)return void(t.state="loaded");let e=i.data,r=Zt(e)&&m()?e:await this.readImageNow(e),n={type:this.type,uid:t.uid,source:this.id,rawImageData:r,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;await this.dispatcher.waitForInitComplete(),(!t.actor||"expired"===t.state)&&(t.actor=this.dispatcher.getReadyActor()),t.dem=await t.actor.sendAsync({type:"LDT",data:n}),t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.needsColorReliefPrepare=!0,t.state="loaded"}}catch(e){if(delete t.abortController,t.aborted)t.state="unloaded";else if(e)throw t.state="errored",e}}async readImageNow(t){if(typeof VideoFrame<"u"&&_()){let e=t.width+4,i=t.height+4;try{return new Xh({width:e,height:i},await async function(t,e,i,r,n){if(typeof VideoFrame>"u")throw Error("VideoFrame not supported");let s=new VideoFrame(t,{timestamp:0});try{let o=s?.format;if(!o||!o.startsWith("BGR")&&!o.startsWith("RGB"))throw Error(`Unrecognized format ${o}`);let a=o.startsWith("BGR"),l=new Uint8ClampedArray(r*n*4);if(await s.copyTo(l,function(t,e,i,r,n){let s=4*Math.max(-e,0),o=(Math.max(0,i)-i)*r*4+s,a=4*r,l=Math.max(0,e),h=Math.max(0,i);return{rect:{x:l,y:h,width:Math.min(t.width,e+r)-l,height:Math.min(t.height,i+n)-h},layout:[{offset:o,stride:a}]}}(t,e,i,r,n)),a)for(let t=0;t<l.length;t+=4){let e=l[t];l[t]=l[t+2],l[t+2]=e}return l}finally{s.close()}}(t,-2,-2,e,i))}catch{}}return fe.getImageData(t,2)}_getNeighboringTiles(t){let e=t.canonical,i=2**e.z,r=(e.x-1+i)%i,n=0===e.x?t.wrap-1:t.wrap,s=(e.x+1+i)%i,o=e.x+1===i?t.wrap+1:t.wrap,a={};return a[new Hm(t.overscaledZ,n,e.z,r,e.y).key]={backfilled:!1},a[new Hm(t.overscaledZ,o,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new Hm(t.overscaledZ,n,e.z,r,e.y-1).key]={backfilled:!1},a[new Hm(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new Hm(t.overscaledZ,o,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new Hm(t.overscaledZ,n,e.z,r,e.y+1).key]={backfilled:!1},a[new Hm(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new Hm(t.overscaledZ,o,e.z,s,e.y+1).key]={backfilled:!1}),a}async unloadTile(t){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&&await t.actor.sendAsync({type:"RDT",data:{type:this.type,uid:t.uid,source:this.id}})}};function t_(t,e){return e?t.properties[e]:t.id}function e_(t,e){let i={id:t.id};if(e.removeAllProperties&&(delete t.removeProperties,delete t.addOrUpdateProperties,delete e.removeProperties),e.removeProperties&&t.addOrUpdateProperties){let i=new Set(e.removeProperties);t.addOrUpdateProperties=t.addOrUpdateProperties.filter((t=>!i.has(t.key)))}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 i_(t,e){if(!t)return{};let i={};return i.removeAll=t.removeAll,i.remove=new Set(t.remove||[]),i.add=new Map(t.add?.map((t=>[t_(t,e),t]))),i.update=new Map(t.update?.map((t=>[t.id,t]))),i}function r_(t){return t&&0!==t.length?"number"==typeof t[0]?[t]:t.flatMap((t=>r_(t))):[]}function n_(t){return"GeometryCollection"===t.type?t.geometries.flatMap((t=>n_(t))):r_(t.coordinates)}function s_(t){let e,i=new Um;switch(t.type){case"FeatureCollection":e=t.features.flatMap((t=>n_(t.geometry)));break;case"Feature":e=n_(t.geometry);break;default:e=n_(t)}if(0===e.length)return i;for(let t of e){let[e,r]=t;i.extend([e,r])}return i}var o_=class{constructor(t){this._waiting=[],this._sending=!1,this._replacedWhileSending=!1,this._handlers=t}isIdle(){return!this._sending&&0===this._waiting.length}top(){return this._waiting.length?this._waiting[this._waiting.length-1]:void 0}some(t){return this._waiting.some(t)}enqueue(t){this._waiting.push(t)}replace(t){this._waiting=[t],this._replacedWhileSending=this._sending}clear(){this._waiting=[]}flush(){if(this.isIdle())return Promise.resolve();if(!this._flushing){let t,e=new Promise((e=>{t=e}));this._flushing={promise:e,resolve:t}}let{promise:t}=this._flushing;return this._next(),t}_next(){if(this._sending)return;let t=this._waiting.shift();if(void 0===t)return this._flushing?.resolve(),void(this._flushing=void 0);this._sending=!0,this._replacedWhileSending=!1,this._send(t).finally((()=>this._next()))}async _send(t){let e;try{e=await this._handlers.send(t)}catch(e){return this._sending=!1,void this._handlers.onError(t,e)}this._sending=!1;try{this._handlers.onResult(t,e,this._replacedWhileSending)}catch(e){this._handlers.onError(t,e)}}},a_=class extends Re{constructor(t,e,i,r){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._workerUpdates=new o_({send:t=>this._sendWorkerUpdate(t),onResult:(t,e,i)=>this._onWorkerUpdateResult(t,e,i),onError:(t,e)=>this._onWorkerUpdateError(e)}),void 0!==e.data&&this._workerUpdates.enqueue({data:e.data}),this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof e.data?{url:e.data}:{geojson:e.data},this._options=St({},e),this._collectResourceTiming=e.collectResourceTiming,void 0!==e.maxzoom&&(this.maxzoom=e.maxzoom),e.type&&(this.type=e.type),e.attribution&&(this.attribution=e.attribution),this.promoteId=e.promoteId,void 0!==e.clusterMaxZoom&&this.maxzoom<=e.clusterMaxZoom&&Lt(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${e.clusterMaxZoom}".`),this.workerOptions=St({source:this.id,geojsonVtOptions:{buffer:this._pixelsToTileUnits(void 0===e.buffer?128:e.buffer),tolerance:this._pixelsToTileUnits(void 0===e.tolerance?.375:e.tolerance),extent:st,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1,promoteId:this._promoteIdKey,cluster:e.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(e.clusterMaxZoom),minPoints:Math.max(2,e.clusterMinPoints||2),extent:st,radius:this._pixelsToTileUnits(e.clusterRadius||50),log:!1,generateId:e.generateId||!1}},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}get _promoteIdKey(){return"string"==typeof this.promoteId?this.promoteId:void 0}_pixelsToTileUnits(t){return t*(st/this.tileSize)}_tileUnitsToPixels(t){return t/(st/this.tileSize)}_getClusterMaxZoom(t){let e=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||Lt(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${e}"`),e}async load(){this._workerUpdates.isIdle()?Lt(`No pending worker updates for GeoJSONSource ${this.id}.`):await this._workerUpdates.flush()}onAdd(t){this.map=t,this.load()}setData(t){return this._data="string"==typeof t?{url:t}:{geojson:t},this._workerUpdates.replace({data:t}),this._workerUpdates.flush()}updateData(t){let e=this._getWaitingWorkerChange();return e?e.diff=function(t,e,i){if(!t)return e||{};if(!e)return t||{};let r=i_(t,i),n=i_(e,i);!function(t,e){e.removeAll&&(t.add.clear(),t.update.clear(),t.remove.clear(),e.remove.clear());for(let i of e.remove)t.add.delete(i),t.update.delete(i);for(let[i,r]of e.update){let n=t.update.get(i);n&&(e.update.set(i,e_(n,r)),t.update.delete(i))}}(r,n);let s={};if((r.removeAll||n.removeAll)&&(s.removeAll=!0),s.remove=new Set([...r.remove,...n.remove]),s.add=new Map([...r.add,...n.add]),s.update=new Map([...r.update,...n.update]),s.remove.size&&s.add.size)for(let t of s.add.keys())s.remove.delete(t);return function(t){let 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)}(e.diff,t,this._promoteIdKey):this._workerUpdates.enqueue({diff:t}),this._workerUpdates.flush()}async getData(){for(;this._data.url;)await this.once("data");return this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return s_(await this.getData())}setClusterOptions(t){if(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._workerUpdates.some((t=>"data"in t))){let t=this._getWaitingWorkerChange();t?t.updateCluster=!0:this._workerUpdates.enqueue({updateCluster:!0})}return this._workerUpdates.flush()}_getWaitingWorkerChange(){let t=this._workerUpdates.top();return t&&!("data"in t)?t:void 0}getClusterOptions(){let{cluster:t,clusterOptions:e}=this.workerOptions.geojsonVtOptions;return{cluster:t,clusterMaxZoom:e.maxZoom,clusterRadius:this._tileUnitsToPixels(e.radius)}}async getClusterExpansionZoom(t){return(await this.actorPromise).sendAsync({type:"GCEZ",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterChildren(t){return(await this.actorPromise).sendAsync({type:"GCC",data:{type:this.type,clusterId:t,source:this.id}})}async getClusterLeaves(t,e,i){return(await this.actorPromise).sendAsync({type:"GCL",data:{type:this.type,source:this.id,clusterId:t,limit:e,offset:i}})}async _getLoadGeoJSONParameters(t){let e=St({type:this.type,source:this.id},this.workerOptions);return"data"in t?"string"==typeof t.data?(e.request=await this.map._requestManager.transformRequest(fe.resolveURL(t.data),"Source"),e.request.collectResourceTiming=this._collectResourceTiming,e):(e.data=t.data,e):(t.diff&&(e.dataDiff=t.diff),t.updateCluster&&(e.updateCluster=!0),e)}async _sendWorkerUpdate(t){this.fire(new Ne("dataloading"));let e=await this._getLoadGeoJSONParameters(t);return(await this.actorPromise).sendAsync({type:"LD",data:e})}_onWorkerUpdateResult(t,e,i){if(this._removed||e.abandoned)return void this.fire(new Ne("dataabort"));e.data&&!i&&(this._data={geojson:e.data});let r=this._applyDiffToSource("data"in t||i?void 0:t.diff),n=!("data"in t)&&t.updateCluster?void 0:this._getShouldReloadTileOptions(r),s={};this._applyResourceTiming(s,e),this.fire(new Ne("data",{...s,sourceDataType:"metadata"})),this.fire(new Ne("data",{...s,sourceDataType:"content",shouldReloadTileOptions:n}))}_onWorkerUpdateError(t){this.fire(this._removed?new Ne("dataabort"):new je(at(t)))}_applyResourceTiming(t,e){if(!this._collectResourceTiming)return;let i=e.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&St(t,{resourceTiming:r})}_applyDiffToSource(t){if(!t)return;let e=this._promoteIdKey;if(!this._data.url&&!this._data.updateable){let t=function(t,e){let i=new Map;if(null==t||null==t.type)return i;if("Feature"===t.type){let r=t_(t,e);return null==r?void 0:(i.set(r,t),i)}if("FeatureCollection"===t.type){let r=new Set;for(let n of t.features){let t=t_(n,e);if(null==t||r.has(t))return;r.add(t),i.set(t,n)}return i}}(this._data.geojson,e);if(!t)throw Error(`GeoJSONSource "${this.id}": GeoJSON data is not compatible with updateData`);this._data={updateable:t}}if(!this._data.updateable)return;let i=function(t,e,i){let r=[];if(e.removeAll)t.clear();else if(e.remove)for(let i of e.remove){let e=t.get(i);e&&(r.push(e.geometry),t.delete(i))}if(e.add)for(let n of e.add){let e=t_(n,i);if(null==e)continue;let s=t.get(e);s&&r.push(s.geometry),r.push(n.geometry),t.set(e,n)}if(e.update)for(let i of e.update){let e=t.get(i.id);if(!e)continue;let n=!!i.newGeometry,s=i.removeAllProperties||i.removeProperties?.length>0||i.addOrUpdateProperties?.length>0;if(!n&&!s)continue;r.push(e.geometry);let o={...e};if(t.set(i.id,o),n&&(r.push(i.newGeometry),o.geometry=i.newGeometry),s){if(o.properties=i.removeAllProperties?{}:{...o.properties||{}},i.removeProperties)for(let t of i.removeProperties)delete o.properties[t];if(i.addOrUpdateProperties)for(let{key:t,value:e}of i.addOrUpdateProperties)o.properties[t]=e}}return r}(this._data.updateable,t,e);return t.removeAll||this.workerOptions.geojsonVtOptions.cluster?void 0:i}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((t=>s_(t)))}}shouldReloadTile(t,{affectedBounds:e}){if("loading"===t.state)return!0;if("unloaded"===t.state)return!1;let{buffer:i,extent:r}=this.workerOptions.geojsonVtOptions,n=function({x:t,y:e,z:i},r=0){let n=$c((t-r)/2**i),s=jc((e+1+r)/2**i),o=$c((t+1+r)/2**i),a=jc((e-r)/2**i);return new Um([n,s],[o,a])}(t.tileID.canonical,i/r);for(let t of e)if(n.intersects(t))return!0;return!1}loaded(){return this._workerUpdates.isIdle()}async loadTile(t){let e=t.actor?"RT":"LT";t.actor=await this.actorPromise;let 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;try{let r=await(await this.actorPromise).sendAsync({type:e,data:i},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(r,this.map.style,"RT"===e)}catch(e){if(delete t.abortController,t.aborted||ae(e))return;throw e}}async abortTile(t){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0}async unloadTile(t){t.unloadVectorData(),await(await this.actorPromise).sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})}onRemove(){this._removed=!0,this._workerUpdates.clear(),this.actorPromise.then((t=>t.sendAsync({type:"RS",data:{type:this.type,source:this.id}})))}serialize(){return St({},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}};const l_=[0,0,1],h_=(t,e,i,r,n,s)=>({u_tl_parent:t,u_scale_parent:e,u_buffer_scale:1,u_image_warp:s,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:f_(r.paint.get("raster-saturation")),u_contrast_factor:c_(r.paint.get("raster-contrast")),u_spin_weights:u_(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]});function u_(t){t*=Math.PI/180;let 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]}function c_(t){return t>0?1/(1-t):1+t}function f_(t){return t>0?1-1/(1.001-t):-t}var p_=class{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}};const d_=Ea([{name:"a_pos",type:"Int16",components:2}]);function m_(t,e){let i=function(t){let e=void 0===t.granularity?1:Math.max(t.granularity,1),i=e+(t.generateBorders?2:0),r=e+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),n=i+1,s=r+1,o=t.generateBorders?-1:0,a=t.generateBorders||t.extendToNorthPole?-1:0,l=e+ +!!t.generateBorders,h=e+(t.generateBorders||t.extendToSouthPole?1:0),u=n*s,c=i*r*6,f=n*s>65536;if(f)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let p=f||!1,d=new Int16Array(2*u),m=0;for(let i=a;i<=h;i++)for(let r=o;r<=l;r++){let n=r/e*st;-1===r&&(n=-64),r===e+1&&(n=8256);let s=i/e*st;-1===i&&(s=t.extendToNorthPole?ec:-64),i===e+1&&(s=t.extendToSouthPole?ic:8256),d[m++]=n,d[m++]=s}let _=p?new Uint32Array(c):new Uint16Array(c),g=0;for(let t=0;t<r;t++)for(let e=0;e<i;e++){let i=e+1+t*n,r=e+(t+1)*n,s=e+1+(t+1)*n;_[g++]=e+t*n,_[g++]=r,_[g++]=i,_[g++]=i,_[g++]=r,_[g++]=s}return{vertices:d.buffer.slice(0),indices:_.buffer.slice(0),uses32bitIndices:p}}(e),r=hl.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),n=Al.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new p_(t.createVertexBuffer(r,d_.members),t.createIndexBuffer(n),zl.simpleSegment(0,0,r.length,n.length))}var __=class extends Re{constructor(t,e,i,r){super(),this.imageWarp=l_,this.flippedWindingOrder=!1,this._warp="auto",this._imageDirty=!1,this._subdividedQuad=!1,this._subdividedMesh=null,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(r),this.options=e}async load(t){if(void 0===this.options.url)return this._loaded=!0,void this._finishLoading();this._loaded=!1,this.fire(new Ne("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let e=await Te.transformAndGetImage(this.map._requestManager,this.url,"Image",this._abortController);this._abortController=null,this._loaded=!0,e?.data?(this._setImage(e.data),t&&(this.coordinates=t),this._finishLoading()):this.fire(new je(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(ae(t))return;this._abortController=null,this._loaded=!0,this.fire(new je(at(t)))}}loaded(){return this._loaded}updateImage(t){return this._abortController&&=(this._abortController.abort(),null),"image"in t?(this._loaded=!0,this._setImage(t.image),t.coordinates&&(this.coordinates=t.coordinates),this._finishLoading(),this):t.url?(this.options.url=t.url,this.load(t.coordinates),this):this}_setImage(t){this.image=t,this._imageDirty=!0}getMesh(t,e){return!this._subdividedQuad||e?null:(this._subdividedMesh??=m_(t,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){if(this.map)try{this.setCoordinates(this.coordinates),this.fire(new Ne("data",{sourceDataType:"metadata"}))}catch(t){this.fire(new je(at(t)))}}onAdd(t){this.map=t,this.load()}onRemove(){this._abortController&&=(this._abortController.abort(),null),this._disposeTexture(),this._subdividedMesh?.destroy(),this._subdividedMesh=null,this.image=null,this.tiles={}}setWarp(t){return this._warp===t||(this._warp=t,this.tileCoords&&this.setCoordinates(this.coordinates)),this}getWarp(){return this._warp}setCoordinates(t){this.coordinates=t;let e=t.map(Oc.fromLngLat);return this.tileID=function(t){let e=yc.fromPoints(t),i=e.width(),r=e.height(),n=Math.max(0,Math.floor(-Math.log(Math.max(i,r))/Math.LN2)),s=2**n;return new Zm(n,Math.floor((e.minX+e.maxX)/2*s),Math.floor((e.minY+e.maxY)/2*s))}(e),this.terrainTileRanges=this._getOverlappingTileRanges(e),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=e.map((t=>this.tileID.getTilePoint(t)._round())),this.imageWarp=function(t,e){if("flat"===e||g_(t))return l_;let[i,r,n,s]=t,o=i.x-r.x+n.x-s.x,a=i.y-r.y+n.y-s.y,l=[r.x-n.x,r.y-n.y,s.x-n.x,s.y-n.y],[h,u,c,f]=l,p=function(t){return t[0]*t[3]-t[2]*t[1]}(l),d=(o*f-c*a)/p,m=(h*a-o*u)/p,_=[1,1+d,1+d+m,1+m],g=Math.max(..._)/Math.min(..._),y="perspective"===e?0:function(t){return Math.max(0,(1-4/t)/(1-4/512))}(g);return!(g>=1&&g<=512)||y>=1?l_:[d,m,y]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!g_(this.tileCoords),this.flippedWindingOrder=function(t){return(t[1].x-t[0].x)*(t[2].y-t[0].y)-(t[1].y-t[0].y)*(t[2].x-t[0].x)<0}(this.tileCoords),this.fire(new Ne("data",{sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;let t=this.map.painter.context,e=t.gl;this.texture?this._imageDirty&&(this.texture.update(this.image),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE)):(this.texture=new au(t,this.image,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE)),this._imageDirty=!1;let i=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}async loadTile(t){this.tileID?.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"}serialize(){let t={type:"image",coordinates:this.coordinates};return void 0!==this.options.url&&(t.url=this.options.url),t}hasTransition(){return!1}_getOverlappingTileRanges(t){let{minX:e,minY:i,maxX:r,maxY:n}=yc.fromPoints(t),s={};for(let t=0;t<=25;t++){let o=2**t,a=Math.floor(e*o),l=Math.floor(i*o),h=Math.floor(r*o),u=Math.floor(n*o),c=(a%o+o)%o,f=h%o,p=Math.floor(a/o),d=Math.floor(h/o);s[t]={minWrap:p,maxWrap:d,minTileXWrapped:c,maxTileXWrapped:f,minTileY:l,maxTileY:u}}return s}};function g_(t){let[e,i,r,n]=t;return e.x+r.x===i.x+n.x&&e.y+r.y===i.y+n.y}var y_=class extends __{constructor(t,e,i,r){super(t,e,i,r),this._onPlayingHandler=()=>{this.map?.triggerRepaint()},this.roundZoom=!0,this.type="video",this.options=e}async load(){this._loaded=!1;let t=this.options;this.urls=[];for(let e of t.urls)this.urls.push((await this.map._requestManager.transformRequest(e,"Source")).url);try{let t=await(t=>{let e=window.document.createElement("video");return e.muted=!0,new Promise((i=>{e.onloadstart=()=>{i(e)};for(let i of t){let t=window.document.createElement("source");ze(i)||(e.crossOrigin="Anonymous"),t.src=i,e.appendChild(t)}}))})(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 je(at(t)))}}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){let e=this.video.seekable;t<e.start(0)||t>e.end(0)?this.fire(new je(new fi(`sources.${this.id}`,null,`Playback for this video can be set only between the ${e.start(0)} and ${e.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;let t=this.map.painter.context,e=t.gl;this.texture?this.video.paused||(this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE),e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,this.video)):(this.texture=new au(t,this.video,e.RGBA),this.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE));let i=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,i=!0)}i&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},v_=class extends __{constructor(t,e,i,r){super(t,e,i,r),e.coordinates?(!Array.isArray(e.coordinates)||4!==e.coordinates.length||e.coordinates.some((t=>!Array.isArray(t)||2!==t.length||t.some((t=>"number"!=typeof t)))))&&this.fire(new je(new fi(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new je(new fi(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new je(new fi(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"!=typeof e.canvas&&!(e.canvas instanceof HTMLCanvasElement)&&this.fire(new je(new fi(`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 je(new fi(`sources.${t}`,null,'missing required property "canvas"'))),this.options=e,this.animate=void 0===e.animate||e.animate}async load(){this._loaded=!0,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 je(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(),!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(t){this.map=t,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this._playing=!1,super.onRemove()}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()||0===Object.keys(this.tiles).length)return;let e=this.map.painter.context,i=e.gl;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):(this.texture=new au(e,this.canvas,i.RGBA,{premultiply:!0}),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(let t in this.tiles){let e=this.tiles[t];"loaded"!==e.state&&(e.state="loaded",e.texture=this.texture,r=!0)}r&&this.fire(new Ne("data",{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(let t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}};const w_={},b_="_geojsonTileLayer";var x_=class{constructor(t){this._stringToNumber={},this._numberToString=[];for(let e=0;e<t.length;e++){let 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 Error(`Out of bounds. Index requested n=${t} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[t]}},D_=class{constructor(t,e,i,r,n){this.type="Feature",this._vectorTileFeature=t,this._x=i,this._y=r,this._z=e;for(let e in t.properties)"string"==typeof t.properties[e]&&t.properties[e].startsWith("__$json__:")&&(t.properties[e]=JSON.parse(t.properties[e].slice(10)));this.properties=t.properties,this.id=n}projectPoint(t,e,i,r){return[360*(t.x+e)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+i)/r)*Math.PI))-90]}projectLine(t,e,i,r){return t.map((t=>this.projectPoint(t,e,i,r)))}get geometry(){if(this._geometry)return this._geometry;let t=this._vectorTileFeature,e=t.extent*2**this._z,i=t.extent*this._x,r=t.extent*this._y,n=t.loadGeometry();switch(t.type){case 1:{let t=[];for(let e of n)t.push(e[0]);let s=this.projectLine(t,i,r,e);this._geometry=1===t.length?{type:"Point",coordinates:s[0]}:{type:"MultiPoint",coordinates:s};break}case 2:{let t=n.map((t=>this.projectLine(t,i,r,e)));this._geometry=1===t.length?{type:"LineString",coordinates:t[0]}:{type:"MultiLineString",coordinates:t};break}case 3:{let t=Dc(n),s=[];for(let n of t)s.push(n.map((t=>this.projectLine(t,i,r,e))));this._geometry=1===s.length?{type:"Polygon",coordinates:s[0]}:{type:"MultiPolygon",coordinates:s};break}default:throw Error(`unknown feature type: ${t.type}`)}return this._geometry}set geometry(t){this._geometry=t}toJSON(){let t={geometry:this.geometry};for(let e in this)"_geometry"!==e&&"_vectorTileFeature"!==e&&"_x"!==e&&"_y"!==e&&"_z"!==e&&(t[e]=this[e]);return t}},M_=class{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}},E_=class extends M_{},A_=class extends E_{getValueFromBuffer(t){return this.dataBuffer[t]}},F_=class extends E_{getValueFromBuffer(t){return this.dataBuffer[t]}},S_=class extends M_{constructor(t,e,i,r){super(t,e,r),this.delta=i}},C_=class extends S_{constructor(t,e,i,r,n){super(t,n?Int32Array.of(e):Uint32Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+t*this.delta}},z_=class extends M_{constructor(t,e,i,r){super(t,r?Int32Array.of(e):Uint32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},T_=class{constructor(t,e,i,r,n=4096){if(this._name=t,this._geometryVector=e,this._idVector=i,this._propertyVectors=r,this._extent=n,0===t.length)throw Error("Missing layer name")}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||=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(){let t=[],e=this.geometryVector.getGeometries();for(let i=0;i<this.numFeatures;i++){let r;if(this.idVector){let t=this.idVector.getValue(i);null!==t&&(r=this.containsMaxSafeIntegerValues(this.idVector)?Number(t):t)}let n={coordinates:e[i],type:this.geometryVector.geometryType(i)},s={};for(let t of this.propertyVectors){if(!t)continue;let e=t.name,r=t.getValue(i);null!==r&&(s[e]=r)}t.push({id:r,geometry:n,properties:s})}return t}containsMaxSafeIntegerValues(t){return t instanceof A_||t instanceof z_||t instanceof C_||t instanceof F_}};var P_,I_,k_=class{constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}increment(){return this.value++}add(t){this.value+=t}};!function(t){t.NONE="NONE",t.DELTA="DELTA",t.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",t.RLE="RLE",t.MORTON="MORTON"}(P_||={}),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT"}(I_||={});const $_=new Uint32Array(33);$_[0]=0;for(let t=1;t<=32;t++)$_[t]=32===t?4294967295:4294967295>>>32-t;const j_=$_;function R_(t,e){return t-t%e}function O_(t){return R_(t+31,32)}function B_(t){let e=t>>>0;return((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const L_=function(t){if(!Number.isFinite(t))return 65536;let e=R_(Math.floor(t),256);return 0===e?256:e}(65536),U_=3*L_/256+L_|0;function N_(){let t=new Uint8Array(U_);return{dataToBePacked:Array(33),dataPointers:new Int32Array(33),byteContainer:t,byteContainerI32:new Int32Array(t.buffer,t.byteOffset,t.byteLength>>>2),exceptionSizes:new Int32Array(33)}}function G_(t,e,i,r,n){switch(n){case 1:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0;i[n++]=e>>>0&1,i[n++]=e>>>1&1,i[n++]=e>>>2&1,i[n++]=e>>>3&1,i[n++]=e>>>4&1,i[n++]=e>>>5&1,i[n++]=e>>>6&1,i[n++]=e>>>7&1,i[n++]=e>>>8&1,i[n++]=e>>>9&1,i[n++]=e>>>10&1,i[n++]=e>>>11&1,i[n++]=e>>>12&1,i[n++]=e>>>13&1,i[n++]=e>>>14&1,i[n++]=e>>>15&1,i[n++]=e>>>16&1,i[n++]=e>>>17&1,i[n++]=e>>>18&1,i[n++]=e>>>19&1,i[n++]=e>>>20&1,i[n++]=e>>>21&1,i[n++]=e>>>22&1,i[n++]=e>>>23&1,i[n++]=e>>>24&1,i[n++]=e>>>25&1,i[n++]=e>>>26&1,i[n++]=e>>>27&1,i[n++]=e>>>28&1,i[n++]=e>>>29&1,i[n++]=e>>>30&1,i[n++]=e>>>31&1}}(t,e,i,r);break;case 2:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0;i[n++]=e>>>0&3,i[n++]=e>>>2&3,i[n++]=e>>>4&3,i[n++]=e>>>6&3,i[n++]=e>>>8&3,i[n++]=e>>>10&3,i[n++]=e>>>12&3,i[n++]=e>>>14&3,i[n++]=e>>>16&3,i[n++]=e>>>18&3,i[n++]=e>>>20&3,i[n++]=e>>>22&3,i[n++]=e>>>24&3,i[n++]=e>>>26&3,i[n++]=e>>>28&3,i[n++]=e>>>30&3,i[n++]=r>>>0&3,i[n++]=r>>>2&3,i[n++]=r>>>4&3,i[n++]=r>>>6&3,i[n++]=r>>>8&3,i[n++]=r>>>10&3,i[n++]=r>>>12&3,i[n++]=r>>>14&3,i[n++]=r>>>16&3,i[n++]=r>>>18&3,i[n++]=r>>>20&3,i[n++]=r>>>22&3,i[n++]=r>>>24&3,i[n++]=r>>>26&3,i[n++]=r>>>28&3,i[n++]=r>>>30&3}}(t,e,i,r);break;case 3:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0;i[n++]=e>>>0&7,i[n++]=e>>>3&7,i[n++]=e>>>6&7,i[n++]=e>>>9&7,i[n++]=e>>>12&7,i[n++]=e>>>15&7,i[n++]=e>>>18&7,i[n++]=e>>>21&7,i[n++]=e>>>24&7,i[n++]=e>>>27&7,i[n++]=7&(e>>>30|(1&r)<<2),i[n++]=r>>>1&7,i[n++]=r>>>4&7,i[n++]=r>>>7&7,i[n++]=r>>>10&7,i[n++]=r>>>13&7,i[n++]=r>>>16&7,i[n++]=r>>>19&7,i[n++]=r>>>22&7,i[n++]=r>>>25&7,i[n++]=r>>>28&7,i[n++]=7&(r>>>31|(3&o)<<1),i[n++]=o>>>2&7,i[n++]=o>>>5&7,i[n++]=o>>>8&7,i[n++]=o>>>11&7,i[n++]=o>>>14&7,i[n++]=o>>>17&7,i[n++]=o>>>20&7,i[n++]=o>>>23&7,i[n++]=o>>>26&7,i[n++]=o>>>29&7}}(t,e,i,r);break;case 4:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0;i[n++]=e>>>0&15,i[n++]=e>>>4&15,i[n++]=e>>>8&15,i[n++]=e>>>12&15,i[n++]=e>>>16&15,i[n++]=e>>>20&15,i[n++]=e>>>24&15,i[n++]=e>>>28&15,i[n++]=r>>>0&15,i[n++]=r>>>4&15,i[n++]=r>>>8&15,i[n++]=r>>>12&15,i[n++]=r>>>16&15,i[n++]=r>>>20&15,i[n++]=r>>>24&15,i[n++]=r>>>28&15,i[n++]=o>>>0&15,i[n++]=o>>>4&15,i[n++]=o>>>8&15,i[n++]=o>>>12&15,i[n++]=o>>>16&15,i[n++]=o>>>20&15,i[n++]=o>>>24&15,i[n++]=o>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15}}(t,e,i,r);break;case 5:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0;i[n++]=e>>>0&31,i[n++]=e>>>5&31,i[n++]=e>>>10&31,i[n++]=e>>>15&31,i[n++]=e>>>20&31,i[n++]=e>>>25&31,i[n++]=31&(e>>>30|(7&r)<<2),i[n++]=r>>>3&31,i[n++]=r>>>8&31,i[n++]=r>>>13&31,i[n++]=r>>>18&31,i[n++]=r>>>23&31,i[n++]=31&(r>>>28|(1&o)<<4),i[n++]=o>>>1&31,i[n++]=o>>>6&31,i[n++]=o>>>11&31,i[n++]=o>>>16&31,i[n++]=o>>>21&31,i[n++]=o>>>26&31,i[n++]=31&(o>>>31|(15&a)<<1),i[n++]=a>>>4&31,i[n++]=a>>>9&31,i[n++]=a>>>14&31,i[n++]=a>>>19&31,i[n++]=a>>>24&31,i[n++]=31&(a>>>29|(3&l)<<3),i[n++]=l>>>2&31,i[n++]=l>>>7&31,i[n++]=l>>>12&31,i[n++]=l>>>17&31,i[n++]=l>>>22&31,i[n++]=l>>>27&31}}(t,e,i,r);break;case 6:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,h=t[s++]>>>0;i[n++]=e>>>0&63,i[n++]=e>>>6&63,i[n++]=e>>>12&63,i[n++]=e>>>18&63,i[n++]=e>>>24&63,i[n++]=63&(e>>>30|(15&r)<<2),i[n++]=r>>>4&63,i[n++]=r>>>10&63,i[n++]=r>>>16&63,i[n++]=r>>>22&63,i[n++]=63&(r>>>28|(3&o)<<4),i[n++]=o>>>2&63,i[n++]=o>>>8&63,i[n++]=o>>>14&63,i[n++]=o>>>20&63,i[n++]=o>>>26&63,i[n++]=a>>>0&63,i[n++]=a>>>6&63,i[n++]=a>>>12&63,i[n++]=a>>>18&63,i[n++]=a>>>24&63,i[n++]=63&(a>>>30|(15&l)<<2),i[n++]=l>>>4&63,i[n++]=l>>>10&63,i[n++]=l>>>16&63,i[n++]=l>>>22&63,i[n++]=63&(l>>>28|(3&h)<<4),i[n++]=h>>>2&63,i[n++]=h>>>8&63,i[n++]=h>>>14&63,i[n++]=h>>>20&63,i[n++]=h>>>26&63}}(t,e,i,r);break;case 7:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,h=t[s++]>>>0,u=t[s++]>>>0;i[n++]=e>>>0&127,i[n++]=e>>>7&127,i[n++]=e>>>14&127,i[n++]=e>>>21&127,i[n++]=127&(e>>>28|(7&r)<<4),i[n++]=r>>>3&127,i[n++]=r>>>10&127,i[n++]=r>>>17&127,i[n++]=r>>>24&127,i[n++]=127&(r>>>31|(63&o)<<1),i[n++]=o>>>6&127,i[n++]=o>>>13&127,i[n++]=o>>>20&127,i[n++]=127&(o>>>27|(3&a)<<5),i[n++]=a>>>2&127,i[n++]=a>>>9&127,i[n++]=a>>>16&127,i[n++]=a>>>23&127,i[n++]=127&(a>>>30|(31&l)<<2),i[n++]=l>>>5&127,i[n++]=l>>>12&127,i[n++]=l>>>19&127,i[n++]=127&(l>>>26|(1&h)<<6),i[n++]=h>>>1&127,i[n++]=h>>>8&127,i[n++]=h>>>15&127,i[n++]=h>>>22&127,i[n++]=127&(h>>>29|(15&u)<<3),i[n++]=u>>>4&127,i[n++]=u>>>11&127,i[n++]=u>>>18&127,i[n++]=u>>>25&127}}(t,e,i,r);break;case 8:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<8;e++){let e=t[s++]>>>0,r=t[s++]>>>0,o=t[s++]>>>0,a=t[s++]>>>0,l=t[s++]>>>0,h=t[s++]>>>0,u=t[s++]>>>0,c=t[s++]>>>0;i[n++]=e>>>0&255,i[n++]=e>>>8&255,i[n++]=e>>>16&255,i[n++]=e>>>24&255,i[n++]=r>>>0&255,i[n++]=r>>>8&255,i[n++]=r>>>16&255,i[n++]=r>>>24&255,i[n++]=o>>>0&255,i[n++]=o>>>8&255,i[n++]=o>>>16&255,i[n++]=o>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255}}(t,e,i,r);break;case 16:!function(t,e,i,r){let n=r,s=e;for(let e=0;e<128;e++){let e=t[s++]>>>0;i[n++]=65535&e,i[n++]=e>>>16&65535}}(t,e,i,r);break;default:!function(t,e,i,r,n){let s=j_[n]>>>0,o=e,a=0,l=t[o]>>>0,h=r;for(let e=0;e<8;e++){for(let e=0;e<32;e++)if(a+n<=32)i[h+e]=l>>>a&s,a+=n,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else{let r=32-a,u=l>>>a;o++,l=t[o]>>>0;let c=n-r;i[h+e]=(u|(l&-1>>>32-c>>>0)<<r)&s,a=c}h+=32,a=0,e<7&&(l=t[o]>>>0)}}(t,e,i,r,n)}return e+(n<<3)|0}function q_(t,e,i,r){if(i+2>e)throw Error(`FastPFOR decode: byteContainer underflow at block=${r} (need 2 bytes for [bitWidth, exceptionCount], bytePos=${i}, byteSize=${e})`);let n=t[i++],s=t[i++];if(n>32)throw Error(`FastPFOR decode: invalid bitWidth=${n} at block=${r} (expected 0..32). This likely indicates corrupted or truncated input.`);return{bitWidth:n,exceptionCount:s,bytePosIn:i}}function V_(t,e,i,r,n,s,o,a,l){let{maxBits:h,exceptionBitWidth:u,bytePosIn:c}=function(t,e,i,r,n,s){if(i+1>e)throw Error(`FastPFOR decode: exception header underflow at block=${s} (need 1 byte for maxBits, bytePos=${i}, byteSize=${e})`);let o=t[i++];if(o<r||o>32)throw Error(`FastPFOR decode: invalid maxBits=${o} at block=${s} (bitWidth=${r}, expected ${r}..32)`);let a=o-r|0;if(a<1||a>32)throw Error(`FastPFOR decode: invalid exceptionBitWidth=${a} at block=${s} (bitWidth=${r}, maxBits=${o})`);if(i+n>e)throw Error(`FastPFOR decode: exception positions underflow at block=${s} (need=${n}, have=${e-i})`);return{maxBits:o,exceptionBitWidth:a,bytePosIn:i}}(n,s,o,i,r,l);if(o=c,1===u){let s=1<<i;for(let i=0;i<r;i=i+1|0)t[n[o++]+e|0]|=s;return o}let f=a.dataToBePacked[u];if(!f)throw Error(`FastPFOR decode: missing exception stream for exceptionBitWidth=${u} (bitWidth=${i}, maxBits=${h}) at block ${l}`);let p=a.dataPointers,d=0|p[u],m=0|a.exceptionSizes[u];if(d+r>m)throw Error(`FastPFOR decode: exception stream overflow for exceptionBitWidth=${u} (ptr=${d}, need ${r}, size=${m}) at block ${l}`);for(let s=0;s<r;s=s+1|0){let r=n[o++],s=0|f[d++];t[r+e|0]|=s<<i}return p[u]=d,o}function Z_(t,e,i,r,n,s){let o=0|i,a=0|t[o];if(a<=0||o+a>t.length-1)throw Error(`FastPFOR decode: invalid whereMeta=${a} at pageStart=${o} (expected > 0 and pageStart+whereMeta < encoded.length=${t.length})`);let l=o+1|0,h=o+a|0,u=t[h]>>>0,c=u+3>>>2,f=h+1,p=f+c;if(p>=t.length)throw Error(`FastPFOR decode: invalid byteSize=${u} (metaInts=${c}, pageStart=${o}, packedEnd=${h}, byteContainerStart=${f}) causes bitmapPos=${p} out of bounds (encoded.length=${t.length})`);let d=function(t,e,i,r){r.byteContainer.length<i&&(r.byteContainer=new Uint8Array(2*i),r.byteContainerI32=void 0);let n=r.byteContainer,s=i>>>2;if(3&n.byteOffset)for(let i=0;i<s;i=i+1|0){let r=0|t[e+i|0],s=i<<2;n[s]=255&r,n[s+1|0]=r>>>8&255,n[s+2|0]=r>>>16&255,n[s+3|0]=r>>>24&255}else{let i=r.byteContainerI32;(!i||i.buffer!==n.buffer||i.byteOffset!==n.byteOffset||i.length<s)&&(i=r.byteContainerI32=new Int32Array(n.buffer,n.byteOffset,n.byteLength>>>2)),i.set(t.subarray(e,e+s))}let o=3&i;if(o>0){let i=0|t[e+s|0],r=s<<2;for(let t=0;t<o;t=t+1|0)n[r+t|0]=i>>>(t<<3)&255}return n}(t,f,u,s),m=u,_=function(t,e,i){let r=0|t[e++],n=i.dataToBePacked;for(let s=2;s<=32;s=s+1|0){if(!(r>>>s-1&1))continue;if(e>=t.length)throw Error(`FastPFOR decode: truncated exception stream header (bitWidth=${s}, streamWordIndex=${e}, needWords=1, availableWords=${t.length-e}, encodedWords=${t.length})`);let o=t[e++]>>>0,a=O_(o),l=o*s+31>>>5;if(e+l>t.length)throw Error(`FastPFOR decode: truncated exception stream (bitWidth=${s}, size=${o}, streamWordIndex=${e}, needWords=${l}, availableWords=${t.length-e}, encodedWords=${t.length})`);let h=n[s];(!h||h.length<a)&&(h=n[s]=new Uint32Array(a));let u=0;for(;u<o;u=u+32|0)W_(t,e,h,u,s),e=e+s|0;e=e-((u-o|0)*s>>>5)|0,i.exceptionSizes[s]=o}return e}(t,p,s);return s.dataPointers.fill(0),function(t,e,i,r,n,s,o,a,l,h){let u=0|i,c=0;for(let e=0;e<o;e=e+1|0){let i=q_(a,l,c,e);c=i.bytePosIn;let r=i.bitWidth,o=i.exceptionCount,f=s+256*e|0;switch(r){case 0:n.fill(0,f,f+256);break;case 32:for(let e=0;e<256;e=e+1|0)n[f+e|0]=0|t[u+e|0];u=u+256|0;break;default:u=G_(t,u,n,f,r)}o>0&&(c=V_(n,f,r,o,a,l,c,h,e))}if(u!==r)throw Error(`FastPFOR decode: packed region mismatch (pageStart=${e}, packedStart=${i}, consumedPackedEnd=${u}, expectedPackedEnd=${r}, packedWords=${r-i}, encoded.length=${t.length})`)}(t,o,l,h,e,0|r,n/256|0,d,m,s),_}function W_(t,e,i,r,n){switch(n){case 2:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0;i[n++]=s>>>0&3,i[n++]=s>>>2&3,i[n++]=s>>>4&3,i[n++]=s>>>6&3,i[n++]=s>>>8&3,i[n++]=s>>>10&3,i[n++]=s>>>12&3,i[n++]=s>>>14&3,i[n++]=s>>>16&3,i[n++]=s>>>18&3,i[n++]=s>>>20&3,i[n++]=s>>>22&3,i[n++]=s>>>24&3,i[n++]=s>>>26&3,i[n++]=s>>>28&3,i[n++]=s>>>30&3,i[n++]=o>>>0&3,i[n++]=o>>>2&3,i[n++]=o>>>4&3,i[n++]=o>>>6&3,i[n++]=o>>>8&3,i[n++]=o>>>10&3,i[n++]=o>>>12&3,i[n++]=o>>>14&3,i[n++]=o>>>16&3,i[n++]=o>>>18&3,i[n++]=o>>>20&3,i[n++]=o>>>22&3,i[n++]=o>>>24&3,i[n++]=o>>>26&3,i[n++]=o>>>28&3,i[n]=o>>>30&3}(t,e,i,r);case 3:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0;i[n++]=s>>>0&7,i[n++]=s>>>3&7,i[n++]=s>>>6&7,i[n++]=s>>>9&7,i[n++]=s>>>12&7,i[n++]=s>>>15&7,i[n++]=s>>>18&7,i[n++]=s>>>21&7,i[n++]=s>>>24&7,i[n++]=s>>>27&7,i[n++]=7&(s>>>30|(1&o)<<2),i[n++]=o>>>1&7,i[n++]=o>>>4&7,i[n++]=o>>>7&7,i[n++]=o>>>10&7,i[n++]=o>>>13&7,i[n++]=o>>>16&7,i[n++]=o>>>19&7,i[n++]=o>>>22&7,i[n++]=o>>>25&7,i[n++]=o>>>28&7,i[n++]=7&(o>>>31|(3&a)<<1),i[n++]=a>>>2&7,i[n++]=a>>>5&7,i[n++]=a>>>8&7,i[n++]=a>>>11&7,i[n++]=a>>>14&7,i[n++]=a>>>17&7,i[n++]=a>>>20&7,i[n++]=a>>>23&7,i[n++]=a>>>26&7,i[n]=a>>>29&7}(t,e,i,r);case 4:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0;i[n++]=s>>>0&15,i[n++]=s>>>4&15,i[n++]=s>>>8&15,i[n++]=s>>>12&15,i[n++]=s>>>16&15,i[n++]=s>>>20&15,i[n++]=s>>>24&15,i[n++]=s>>>28&15,i[n++]=o>>>0&15,i[n++]=o>>>4&15,i[n++]=o>>>8&15,i[n++]=o>>>12&15,i[n++]=o>>>16&15,i[n++]=o>>>20&15,i[n++]=o>>>24&15,i[n++]=o>>>28&15,i[n++]=a>>>0&15,i[n++]=a>>>4&15,i[n++]=a>>>8&15,i[n++]=a>>>12&15,i[n++]=a>>>16&15,i[n++]=a>>>20&15,i[n++]=a>>>24&15,i[n++]=a>>>28&15,i[n++]=l>>>0&15,i[n++]=l>>>4&15,i[n++]=l>>>8&15,i[n++]=l>>>12&15,i[n++]=l>>>16&15,i[n++]=l>>>20&15,i[n++]=l>>>24&15,i[n]=l>>>28&15}(t,e,i,r);case 5:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0;i[n++]=s>>>0&31,i[n++]=s>>>5&31,i[n++]=s>>>10&31,i[n++]=s>>>15&31,i[n++]=s>>>20&31,i[n++]=s>>>25&31,i[n++]=31&(s>>>30|(7&o)<<2),i[n++]=o>>>3&31,i[n++]=o>>>8&31,i[n++]=o>>>13&31,i[n++]=o>>>18&31,i[n++]=o>>>23&31,i[n++]=31&(o>>>28|(1&a)<<4),i[n++]=a>>>1&31,i[n++]=a>>>6&31,i[n++]=a>>>11&31,i[n++]=a>>>16&31,i[n++]=a>>>21&31,i[n++]=a>>>26&31,i[n++]=31&(a>>>31|(15&l)<<1),i[n++]=l>>>4&31,i[n++]=l>>>9&31,i[n++]=l>>>14&31,i[n++]=l>>>19&31,i[n++]=l>>>24&31,i[n++]=31&(l>>>29|(3&h)<<3),i[n++]=h>>>2&31,i[n++]=h>>>7&31,i[n++]=h>>>12&31,i[n++]=h>>>17&31,i[n++]=h>>>22&31,i[n]=h>>>27&31}(t,e,i,r);case 6:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0;i[n++]=s>>>0&63,i[n++]=s>>>6&63,i[n++]=s>>>12&63,i[n++]=s>>>18&63,i[n++]=s>>>24&63,i[n++]=63&(s>>>30|(15&o)<<2),i[n++]=o>>>4&63,i[n++]=o>>>10&63,i[n++]=o>>>16&63,i[n++]=o>>>22&63,i[n++]=63&(o>>>28|(3&a)<<4),i[n++]=a>>>2&63,i[n++]=a>>>8&63,i[n++]=a>>>14&63,i[n++]=a>>>20&63,i[n++]=a>>>26&63,i[n++]=l>>>0&63,i[n++]=l>>>6&63,i[n++]=l>>>12&63,i[n++]=l>>>18&63,i[n++]=l>>>24&63,i[n++]=63&(l>>>30|(15&h)<<2),i[n++]=h>>>4&63,i[n++]=h>>>10&63,i[n++]=h>>>16&63,i[n++]=h>>>22&63,i[n++]=63&(h>>>28|(3&u)<<4),i[n++]=u>>>2&63,i[n++]=u>>>8&63,i[n++]=u>>>14&63,i[n++]=u>>>20&63,i[n]=u>>>26&63}(t,e,i,r);case 7:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0;i[n++]=s>>>0&127,i[n++]=s>>>7&127,i[n++]=s>>>14&127,i[n++]=s>>>21&127,i[n++]=127&(s>>>28|(7&o)<<4),i[n++]=o>>>3&127,i[n++]=o>>>10&127,i[n++]=o>>>17&127,i[n++]=o>>>24&127,i[n++]=127&(o>>>31|(63&a)<<1),i[n++]=a>>>6&127,i[n++]=a>>>13&127,i[n++]=a>>>20&127,i[n++]=127&(a>>>27|(3&l)<<5),i[n++]=l>>>2&127,i[n++]=l>>>9&127,i[n++]=l>>>16&127,i[n++]=l>>>23&127,i[n++]=127&(l>>>30|(31&h)<<2),i[n++]=h>>>5&127,i[n++]=h>>>12&127,i[n++]=h>>>19&127,i[n++]=127&(h>>>26|(1&u)<<6),i[n++]=u>>>1&127,i[n++]=u>>>8&127,i[n++]=u>>>15&127,i[n++]=u>>>22&127,i[n++]=127&(u>>>29|(15&c)<<3),i[n++]=c>>>4&127,i[n++]=c>>>11&127,i[n++]=c>>>18&127,i[n]=c>>>25&127}(t,e,i,r);case 8:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0;i[n++]=s>>>0&255,i[n++]=s>>>8&255,i[n++]=s>>>16&255,i[n++]=s>>>24&255,i[n++]=o>>>0&255,i[n++]=o>>>8&255,i[n++]=o>>>16&255,i[n++]=o>>>24&255,i[n++]=a>>>0&255,i[n++]=a>>>8&255,i[n++]=a>>>16&255,i[n++]=a>>>24&255,i[n++]=l>>>0&255,i[n++]=l>>>8&255,i[n++]=l>>>16&255,i[n++]=l>>>24&255,i[n++]=h>>>0&255,i[n++]=h>>>8&255,i[n++]=h>>>16&255,i[n++]=h>>>24&255,i[n++]=u>>>0&255,i[n++]=u>>>8&255,i[n++]=u>>>16&255,i[n++]=u>>>24&255,i[n++]=c>>>0&255,i[n++]=c>>>8&255,i[n++]=c>>>16&255,i[n++]=c>>>24&255,i[n++]=f>>>0&255,i[n++]=f>>>8&255,i[n++]=f>>>16&255,i[n]=f>>>24&255}(t,e,i,r);case 9:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0;i[n++]=s>>>0&511,i[n++]=s>>>9&511,i[n++]=s>>>18&511,i[n++]=511&(s>>>27|(15&o)<<5),i[n++]=o>>>4&511,i[n++]=o>>>13&511,i[n++]=o>>>22&511,i[n++]=511&(o>>>31|(255&a)<<1),i[n++]=a>>>8&511,i[n++]=a>>>17&511,i[n++]=511&(a>>>26|(7&l)<<6),i[n++]=l>>>3&511,i[n++]=l>>>12&511,i[n++]=l>>>21&511,i[n++]=511&(l>>>30|(127&h)<<2),i[n++]=h>>>7&511,i[n++]=h>>>16&511,i[n++]=511&(h>>>25|(3&u)<<7),i[n++]=u>>>2&511,i[n++]=u>>>11&511,i[n++]=u>>>20&511,i[n++]=511&(u>>>29|(63&c)<<3),i[n++]=c>>>6&511,i[n++]=c>>>15&511,i[n++]=511&(c>>>24|(1&f)<<8),i[n++]=f>>>1&511,i[n++]=f>>>10&511,i[n++]=f>>>19&511,i[n++]=511&(f>>>28|(31&p)<<4),i[n++]=p>>>5&511,i[n++]=p>>>14&511,i[n]=p>>>23&511}(t,e,i,r);case 10:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0;i[n++]=s>>>0&1023,i[n++]=s>>>10&1023,i[n++]=s>>>20&1023,i[n++]=1023&(s>>>30|(255&o)<<2),i[n++]=o>>>8&1023,i[n++]=o>>>18&1023,i[n++]=1023&(o>>>28|(63&a)<<4),i[n++]=a>>>6&1023,i[n++]=a>>>16&1023,i[n++]=1023&(a>>>26|(15&l)<<6),i[n++]=l>>>4&1023,i[n++]=l>>>14&1023,i[n++]=1023&(l>>>24|(3&h)<<8),i[n++]=h>>>2&1023,i[n++]=h>>>12&1023,i[n++]=h>>>22&1023,i[n++]=u>>>0&1023,i[n++]=u>>>10&1023,i[n++]=u>>>20&1023,i[n++]=1023&(u>>>30|(255&c)<<2),i[n++]=c>>>8&1023,i[n++]=c>>>18&1023,i[n++]=1023&(c>>>28|(63&f)<<4),i[n++]=f>>>6&1023,i[n++]=f>>>16&1023,i[n++]=1023&(f>>>26|(15&p)<<6),i[n++]=p>>>4&1023,i[n++]=p>>>14&1023,i[n++]=1023&(p>>>24|(3&d)<<8),i[n++]=d>>>2&1023,i[n++]=d>>>12&1023,i[n]=d>>>22&1023}(t,e,i,r);case 11:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0;i[n++]=s>>>0&2047,i[n++]=s>>>11&2047,i[n++]=2047&(s>>>22|(1&o)<<10),i[n++]=o>>>1&2047,i[n++]=o>>>12&2047,i[n++]=2047&(o>>>23|(3&a)<<9),i[n++]=a>>>2&2047,i[n++]=a>>>13&2047,i[n++]=2047&(a>>>24|(7&l)<<8),i[n++]=l>>>3&2047,i[n++]=l>>>14&2047,i[n++]=2047&(l>>>25|(15&h)<<7),i[n++]=h>>>4&2047,i[n++]=h>>>15&2047,i[n++]=2047&(h>>>26|(31&u)<<6),i[n++]=u>>>5&2047,i[n++]=u>>>16&2047,i[n++]=2047&(u>>>27|(63&c)<<5),i[n++]=c>>>6&2047,i[n++]=c>>>17&2047,i[n++]=2047&(c>>>28|(127&f)<<4),i[n++]=f>>>7&2047,i[n++]=f>>>18&2047,i[n++]=2047&(f>>>29|(255&p)<<3),i[n++]=p>>>8&2047,i[n++]=p>>>19&2047,i[n++]=2047&(p>>>30|(511&d)<<2),i[n++]=d>>>9&2047,i[n++]=d>>>20&2047,i[n++]=2047&(d>>>31|(1023&m)<<1),i[n++]=m>>>10&2047,i[n]=m>>>21&2047}(t,e,i,r);case 12:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0;i[n++]=s>>>0&4095,i[n++]=s>>>12&4095,i[n++]=4095&(s>>>24|(15&o)<<8),i[n++]=o>>>4&4095,i[n++]=o>>>16&4095,i[n++]=4095&(o>>>28|(255&a)<<4),i[n++]=a>>>8&4095,i[n++]=a>>>20&4095,i[n++]=l>>>0&4095,i[n++]=l>>>12&4095,i[n++]=4095&(l>>>24|(15&h)<<8),i[n++]=h>>>4&4095,i[n++]=h>>>16&4095,i[n++]=4095&(h>>>28|(255&u)<<4),i[n++]=u>>>8&4095,i[n++]=u>>>20&4095,i[n++]=c>>>0&4095,i[n++]=c>>>12&4095,i[n++]=4095&(c>>>24|(15&f)<<8),i[n++]=f>>>4&4095,i[n++]=f>>>16&4095,i[n++]=4095&(f>>>28|(255&p)<<4),i[n++]=p>>>8&4095,i[n++]=p>>>20&4095,i[n++]=d>>>0&4095,i[n++]=d>>>12&4095,i[n++]=4095&(d>>>24|(15&m)<<8),i[n++]=m>>>4&4095,i[n++]=m>>>16&4095,i[n++]=4095&(m>>>28|(255&_)<<4),i[n++]=_>>>8&4095,i[n]=_>>>20&4095}(t,e,i,r);case 16:return void function(t,e,i,r){let n=r,s=t[e]>>>0,o=t[e+1]>>>0,a=t[e+2]>>>0,l=t[e+3]>>>0,h=t[e+4]>>>0,u=t[e+5]>>>0,c=t[e+6]>>>0,f=t[e+7]>>>0,p=t[e+8]>>>0,d=t[e+9]>>>0,m=t[e+10]>>>0,_=t[e+11]>>>0,g=t[e+12]>>>0,y=t[e+13]>>>0,v=t[e+14]>>>0,w=t[e+15]>>>0;i[n++]=s>>>0&65535,i[n++]=s>>>16&65535,i[n++]=o>>>0&65535,i[n++]=o>>>16&65535,i[n++]=a>>>0&65535,i[n++]=a>>>16&65535,i[n++]=l>>>0&65535,i[n++]=l>>>16&65535,i[n++]=h>>>0&65535,i[n++]=h>>>16&65535,i[n++]=u>>>0&65535,i[n++]=u>>>16&65535,i[n++]=c>>>0&65535,i[n++]=c>>>16&65535,i[n++]=f>>>0&65535,i[n++]=f>>>16&65535,i[n++]=p>>>0&65535,i[n++]=p>>>16&65535,i[n++]=d>>>0&65535,i[n++]=d>>>16&65535,i[n++]=m>>>0&65535,i[n++]=m>>>16&65535,i[n++]=_>>>0&65535,i[n++]=_>>>16&65535,i[n++]=g>>>0&65535,i[n++]=g>>>16&65535,i[n++]=y>>>0&65535,i[n++]=y>>>16&65535,i[n++]=v>>>0&65535,i[n++]=v>>>16&65535,i[n++]=w>>>0&65535,i[n]=w>>>16&65535}(t,e,i,r);case 32:for(let n=0;n<32;n=n+1|0)i[r+n|0]=0|t[e+n|0];return}let s=j_[n]>>>0,o=e,a=0,l=t[o]>>>0;for(let e=0;e<32;e++)if(a+n<=32)i[r+e]=l>>>a&s,a+=n,32===a&&(a=0,o++,31!==e&&(l=t[o]>>>0));else{let h=32-a,u=l>>>a;o++,l=t[o]>>>0,i[r+e]=(u|(l&j_[n-h]>>>0)<<h)&s,a=n-h}}function H_(t,e,i){let r=new Uint32Array(i),n=0,s=e.get();for(let e=0;e<r.length;e++){let e=t[s++],i=127&e;e<128||(e=t[s++],i|=(127&e)<<7,e<128||(e=t[s++],i|=(127&e)<<14,e<128||(e=t[s++],i|=(127&e)<<21,e<128||(e=t[s++],i|=(15&e)<<28)))),r[n++]=i}return e.set(s),r}function Y_(t,e,i){let r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=X_(t,e);return r}function X_(t,e){let i=0n,r=0,n=e.get();for(;n<t.length;){let e=t[n++];if(i|=BigInt(127&e)<<BigInt(r),!(128&e))break;if(r+=7,r>=64)throw Error("Varint too long")}return e.set(n),i}function J_(t,e){let i,r;return r=t[e.get()],e.increment(),i=127&r,r<128||(r=t[e.get()],e.increment(),i|=(127&r)<<7,r<128)||(r=t[e.get()],e.increment(),i|=(127&r)<<14,r<128)||(r=t[e.get()],e.increment(),i|=(127&r)<<21,r<128)?i:(r=t[e.get()],i|=(15&r)<<28,function(t,e,i){let r,n;if(n=e[i.get()],i.increment(),r=(112&n)>>4,n<128||(n=e[i.get()],i.increment(),r|=(127&n)<<3,n<128)||(n=e[i.get()],i.increment(),r|=(127&n)<<10,n<128)||(n=e[i.get()],i.increment(),r|=(127&n)<<17,n<128)||(n=e[i.get()],i.increment(),r|=(127&n)<<24,n<128)||(n=e[i.get()],i.increment(),r|=(1&n)<<31,n<128))return 4294967296*r+(t>>>0);throw Error("Expected varint not more than 10 bytes")}(i,t,e))}function K_(t,e,i,r){return function(t,e,i,r,n){let s=r.get();if(3&i)throw Error(`FastPFOR: invalid encodedByteLength=${i} at offset=${s} (encodedBytes.length=${t.length}; expected a multiple of 4 bytes for an int32 big-endian word stream)`);let o=i>>>2,a=function(t,e){if(e<=t.encodedWords.length)return t.encodedWords;let i=new Uint32Array(Math.max(16,2*e));return t.encodedWords=i,i}(n,o);!function(t,e,i,r){if(e<0||i<0||e+i>t.length)throw RangeError(`decodeBigEndianInt32sInto: out of bounds (offset=${e}, byteLength=${i}, bytes.length=${t.length})`);let n=Math.floor(i/4),s=i%4!=0,o=s?n+1:n;if(r.length<o)throw RangeError(`decodeBigEndianInt32sInto: out.length=${r.length} < ${o}`);if(n>0){let i=t.byteOffset+e;if(3&i)for(let i=0;i<n;i++){let n=e+4*i;r[i]=t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]}else{let e=new Uint32Array(t.buffer,i,n);for(let t=0;t<n;t++)r[t]=0|B_(e[t])}}if(s){let s=e+4*n,o=i-4*n,a=0;for(let e=0;e<o;e++)a|=t[s+e]<<24-8*e;r[n]=0|a}}(t,s,i,a);let l=function(t,e,i){let r=0,n=0,s=new Uint32Array(e),o=i??N_();if(t.length>0){let e=0|t[r];if(r=r+1|0,255&e)throw Error(`FastPFOR decode: invalid alignedLength=${e} (expected multiple of 256)`);if(n+e>s.length)throw Error(`FastPFOR decode: output buffer too small (outPos=${n}, alignedLength=${e}, out.length=${s.length})`);r=function(t,e,i,r,n,s){let o=r+R_(n,256),a=r,l=i;for(;a!==o;){let i=Math.min(L_,o-a);l=Z_(t,e,l,a,i,s),a=a+i|0}return l}(t,s,r,n,e,o),n=n+e|0}return function(t,e,i,r,n,s){if(0===s)return e;let o=0,a=e,l=e+i,h=n,u=n,c=n+s,f=0,p=0;for(;a<l&&u<c;){let e=t[a]>>>o&255;if(o+=8,a+=o>>>5,o&=31,f|=(127&e)<<p,128&e)r[u++]=0|f,f=0,p=0;else if(p+=7,p>28)throw Error(`FastPFOR VByte: unterminated value (expected MSB=1 terminator within 5 bytes; shift=${p}, partial=${f}, decoded=${u-h}/${s}, inPos=${a}, inEnd=${l})`)}if(u!==c)throw Error(`FastPFOR VByte: truncated stream (decoded=${u-h}, expected=${s}, consumedWords=${a-e}/${i}, vbyteStart=${e}, vbyteEnd=${l})`)}(t,r,t.length-r|0,s,n,e-n|0),s}(a.subarray(0,o),e,n.decoderWorkspace);return r.add(i),l}(t,e,i,r,function(t=16){if(t<0)throw RangeError(`initialEncodedWordCapacity must be >= 0, got ${t}`);let e=Math.max(16,0|t);return{encodedWords:new Uint32Array(e),decoderWorkspace:N_()}}(i>>>2))}function Q_(t){return t>>>1^-(1&t)}function tg(t){return t>>1n^-(1n&t)}function eg(t){return t%2==1?(t+1)/-2:t/2}function ig(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=t[r]}let r=new Uint32Array(i),n=0;for(let i=0;i<e;i++){let s=t[i];r.fill(t[i+e],n,n+s),n+=s}return r}function rg(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=Number(t[r])}let r=new BigUint64Array(i),n=0;for(let i=0;i<e;i++){let s=Number(t[i]);r.fill(t[i+e],n,n+s),n+=s}return r}function ng(t,e,i){let r=new Float64Array(i),n=0;for(let i=0;i<e;i++){let s=t[i];r.fill(t[i+e],n,n+s),n+=s}return r}function sg(t){let e=new Int32Array(t.length);e[0]=Q_(t[0]);let i=t.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],n=t[r+2],s=t[r+3];e[r]=Q_(t[r])+e[r-1],e[r+1]=Q_(i)+e[r],e[r+2]=Q_(n)+e[r+1],e[r+3]=Q_(s)+e[r+2]}for(;r!==t.length;++r)e[r]=Q_(t[r])+e[r-1];return e}function og(t){let e=new BigInt64Array(t.length);e[0]=tg(t[0]);let i=t.length/4*4,r=1;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],n=t[r+2],s=t[r+3];e[r]=tg(t[r])+e[r-1],e[r+1]=tg(i)+e[r],e[r+2]=tg(n)+e[r+1],e[r+3]=tg(s)+e[r+2]}for(;r!==e.length;++r)e[r]=tg(t[r])+e[r-1];return e}function ag(t){let e=t.length/4*4,i=1;if(e>=4)for(let r=t[0];i<e-4;i+=4)r=t[i]+=r,r=t[i+1]+=r,r=t[i+2]+=r,r=t[i+3]+=r;for(;i!==t.length;)t[i]+=t[i-1],++i}function lg(t){let e=new Uint32Array(t.length);e[0]=Q_(t[0])>>>0;for(let i=1;i<t.length;i++)e[i]=e[i-1]+Q_(t[i])>>>0;return e}function hg(t){let e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,tg(t[0]));for(let i=1;i<t.length;i++)e[i]=BigInt.asUintN(64,e[i-1]+tg(t[i]));return e}var ug,cg,fg,pg;!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(ug||={}),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(cg||={}),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(fg||={}),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"}(pg||={});const dg=[ug.PRESENT,ug.DATA,ug.OFFSET,ug.LENGTH],mg=[P_.NONE,P_.DELTA,P_.COMPONENTWISE_DELTA,P_.RLE,P_.MORTON],_g=[I_.NONE,I_.FAST_PFOR,I_.VARINT],gg=[cg.NONE,cg.SINGLE,cg.SHARED,cg.VERTEX,cg.MORTON,cg.FSST],yg=[fg.VERTEX,fg.INDEX,fg.STRING,fg.KEY],vg=[pg.VAR_BINARY,pg.GEOMETRIES,pg.PARTS,pg.RINGS,pg.TRIANGLES,pg.SYMBOL,pg.DICTIONARY];function wg(t,e){let i=function(t,e){let i=t[e.get()],r=dg[i>>4],n={};switch(r){case ug.DATA:n={dictionaryType:gg[15&i]};break;case ug.OFFSET:n={offsetType:yg[15&i]};break;case ug.LENGTH:n={lengthType:vg[15&i]}}e.increment();let s=t[e.get()],o=mg[s>>5],a=mg[s>>2&7],l=_g[3&s];e.increment();let h=H_(t,e,2),u=h[0];return{physicalStreamType:r,logicalStreamType:n,logicalLevelTechnique1:o,logicalLevelTechnique2:a,physicalLevelTechnique:l,numValues:u,byteLength:h[1],decompressedCount:u}}(t,e);return i.logicalLevelTechnique1===P_.MORTON?function(t,e,i){let r=H_(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:r[0],coordinateShift:r[1]}}(i,t,e):P_.RLE!==i.logicalLevelTechnique1&&P_.RLE!==i.logicalLevelTechnique2||I_.NONE===i.physicalLevelTechnique?i:function(t,e,i){let r=H_(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:r[1],runs:r[0],numRleValues:r[1]}}(i,t,e)}var bg;!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"}(bg||={});var xg=class{constructor(t,e){this.values=t,this._size=e}get(t){let e=Math.floor(t/8);return 1==(this.values[e]>>t%8&1)}set(t,e){let i=Math.floor(t/8);this.values[i]=this.values[i]|+!!e<<t%8}getInt(t){let e=Math.floor(t/8);return this.values[e]>>t%8&1}size(){return this._size}getBuffer(){return this.values}};function Dg(t,e,i){if(!e)return t;let r=e.size(),n=new(0,t.constructor)(r),s=0;for(let o=0;o<r;o++)n[o]=e.get(o)?t[s++]:i;return n}function Mg(t,e,i,r,n){let s=function(t,e,i,r){let n=new Uint8Array(e),s=0,o=r.get()+i;for(;s<e&&!(r.get()>=o);){let i=t[r.increment()];if(i<=127){let o=i+3,a=t[r.increment()],l=Math.min(s+o,e);n.fill(a,s,l),s=l}else{let o=256-i;for(let i=0;i<o&&s<e;i++)n[s++]=t[r.increment()]}}return r.set(o),n}(t,Math.ceil(e/8),i,r);return n?function(t,e,i){if(!i)return t;let r=i.size(),n=new xg(t,e),s=new xg(new Uint8Array(Math.ceil(r/8)),r),o=0;for(let t=0;t<r;t++){let e=!!i.get(t)&&n.get(o++);s.set(t,e)}return s.getBuffer()}(s,e,n):s}function Eg(t,e,i,r){let n=e.get(),s=n+i*Float32Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(n,s)).buffer,a=new Float32Array(o);return e.set(s),r?Dg(a,r,0):a}function Ag(t,e,i,r){let n=e.get(),s=n+i*Float64Array.BYTES_PER_ELEMENT,o=new Uint8Array(t.subarray(n,s)).buffer,a=new Float64Array(o);return e.set(s),r?Dg(a,r,0):a}const Fg=new TextDecoder;function Sg(t,e,i){return i-e>=12?Fg.decode(t.subarray(e,i)):function(t,e,i){let r="",n=e;for(;n<i;){let e,s,o,a=t[n],l=null,h=a>239?4:a>223?3:a>191?2:1;if(n+h>i)break;1===h?a<128&&(l=a):2===h?(e=t[n+1],128==(192&e)&&(l=(31&a)<<6|63&e,l<=127&&(l=null))):3===h?(e=t[n+1],s=t[n+2],128==(192&e)&&128==(192&s)&&(l=(15&a)<<12|(63&e)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===h&&(e=t[n+1],s=t[n+2],o=t[n+3],128==(192&e)&&128==(192&s)&&128==(192&o)&&(l=(15&a)<<18|(63&e)<<12|(63&s)<<6|63&o,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,h=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=h}return r}(t,e,i)}function Cg(t,e,i,r,n){return function(t,e,i,r){let n;switch(e.logicalLevelTechnique1){case P_.DELTA:if(e.logicalLevelTechnique2===P_.RLE){let i=e;if(!r)return function(t,e,i){let r=new Int32Array(i),n=0,s=0;for(let i=0;i<e;i++){let o=t[i],a=Q_(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,i.runs,i.numRleValues);n=sg(t=ig(t,i.runs,i.numRleValues))}else n=sg(t);break;case P_.RLE:n=function(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=t[r]}let r=new Int32Array(i),n=0;for(let i=0;i<e;i++){let s=t[i],o=t[i+e];o=Q_(o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues);break;case P_.MORTON:ag(t),n=new Int32Array(t);break;case P_.COMPONENTWISE_DELTA:n=function(t){if(t.length<2)return new Int32Array(t);let e=new Int32Array(t.length);e[0]=Q_(t[0]),e[1]=Q_(t[1]);let i=t.length/4*4,r=2;if(i>=4)for(;r<i-4;r+=4){let i=t[r+1],n=t[r+2],s=t[r+3];e[r]=Q_(t[r])+e[r-2],e[r+1]=Q_(i)+e[r-1],e[r+2]=Q_(n)+e[r],e[r+3]=Q_(s)+e[r+1]}for(;r!==t.length;r+=2)e[r]=Q_(t[r])+e[r-2],e[r+1]=Q_(t[r+1])+e[r-1];return e}(t);break;case P_.NONE:n=function(t){let e=new Int32Array(t.length);for(let i=0;i<t.length;i++)e[i]=Q_(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Dg(n,r,0):n}(Pg(t,e,i),i,0,n)}function zg(t,e,i,r,n){return function(t,e,i,r){let n;switch(e.logicalLevelTechnique1){case P_.DELTA:n=lg(e.logicalLevelTechnique2===P_.RLE?ig(t,e.runs,e.numRleValues):t);break;case P_.RLE:n=ig(t,e.runs,e.numRleValues);break;case P_.MORTON:ag(t),n=t;break;case P_.COMPONENTWISE_DELTA:n=function(t){if(t.length<2)return new Uint32Array(t);let e=new Uint32Array(t.length);e[0]=Q_(t[0])>>>0,e[1]=Q_(t[1])>>>0;for(let i=2;i<t.length;i+=2)e[i]=e[i-2]+Q_(t[i])>>>0,e[i+1]=e[i-1]+Q_(t[i+1])>>>0;return e}(t);break;case P_.NONE:n=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?Dg(n,r,0):n}(Pg(t,e,i),i,0,n)}function Tg(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===P_.DELTA&&e.logicalLevelTechnique2===P_.NONE)return function(t){let e=new Int32Array(t.length+1);e[0]=0,e[1]=Q_(t[0]);let i=e[1];for(let r=2;r!==e.length;++r)i+=Q_(t[r-1]),e[r]=e[r-1]+i;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===P_.RLE&&e.logicalLevelTechnique2===P_.NONE)return function(t,e,i){let r=new Uint32Array(i+1);r[0]=0;let n=1,s=r[0];for(let i=0;i<e;i++){let o=t[i],a=t[i+e];for(let t=n;t<n+o;t++)r[t]=a+s,s=r[t];n+=o}return r}(t,e.runs,e.numRleValues);if(e.logicalLevelTechnique1===P_.NONE&&e.logicalLevelTechnique2===P_.NONE){!function(t){let e=0;for(let i=0;i<t.length;i++)t[i]+=e,e=t[i]}(t);let i=new Uint32Array(e.numValues+1);return i[0]=0,i.set(t,1),i}if(e.logicalLevelTechnique1===P_.DELTA&&e.logicalLevelTechnique2===P_.RLE){let i=function(t,e,i){let r=new Int32Array(i+1);r[0]=0;let n=1,s=r[0];for(let i=0;i<e;i++){let o=t[i],a=t[i+e];a=Q_(a);for(let t=n;t<n+o;t++)r[t]=a+s,s=r[t];n+=o}return r}(t,e.runs,e.numRleValues);return ag(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(Pg(t,e,i),i)}function Pg(t,e,i){let r=i.physicalLevelTechnique;switch(r){case I_.FAST_PFOR:return K_(t,i.numValues,i.byteLength,e);case I_.VARINT:return H_(t,e,i.numValues);case I_.NONE:return function(t,e,i){let r=e.get(),n=i*Uint32Array.BYTES_PER_ELEMENT,s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=new Uint32Array(i);for(let t=0;t<i;t++)o[t]=s.getUint32(r+t*Uint32Array.BYTES_PER_ELEMENT,!0);return e.add(n),o}(t,e,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function Ig(t,e,i){let r=i.physicalLevelTechnique;switch(r){case I_.VARINT:return Y_(t,e,i.numValues);case I_.NONE:return function(t,e,i){let r=e.get(),n=i*BigUint64Array.BYTES_PER_ELEMENT,s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=new BigUint64Array(i);for(let t=0;t<i;t++)o[t]=s.getBigUint64(r+t*BigUint64Array.BYTES_PER_ELEMENT,!0);return e.add(n),o}(t,e,i.numValues);default:throw Error(`Specified physicalLevelTechnique ${r} is not supported (yet).`)}}function kg(t,e,i){let r=Pg(t,e,i);return 1===r.length?i.logicalLevelTechnique1===P_.DELTA?Q_(r[0]):r[0]:function(t){return t[1]}(r)}function $g(t,e,i){return function(t){if(2===t.length){let e=Q_(t[1]);return[e,e]}return[Q_(t[2]),Q_(t[3])]}(Pg(t,e,i))}function jg(t,e,i){return function(t){if(2===t.length){let e=tg(t[1]);return[e,e]}return[tg(t[2]),tg(t[3])]}(Y_(t,e,i.numValues))}function Rg(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case P_.DELTA:if(e.logicalLevelTechnique2===P_.RLE){let n=e;if(!i)return function(t,e,i){let r=new BigInt64Array(i),n=0,s=0n;for(let i=0;i<e;i++){let o=Number(t[i]),a=tg(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,n.runs,n.numRleValues);r=og(t=rg(t,n.runs,n.numRleValues))}else r=og(t);break;case P_.RLE:r=function(t,e,i){if(void 0===i){i=0;for(let r=0;r<e;r++)i+=Number(t[r])}let r=new BigInt64Array(i),n=0;for(let i=0;i<e;i++){let s=Number(t[i]),o=t[i+e];o=tg(o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues);break;case P_.NONE:r=function(t){let e=new BigInt64Array(t.length);for(let i=0;i<t.length;i++)e[i]=tg(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Dg(r,i,0n):r}(Ig(t,e,i),i,r)}function Og(t,e,i,r){return Lg(Ig(t,e,i),i,r)}function Bg(t,e,i){let r=Ig(t,e,i);return 1===r.length?i.logicalLevelTechnique1===P_.DELTA?tg(r[0]):r[0]:function(t){return t[1]}(r)}function Lg(t,e,i){let r;switch(e.logicalLevelTechnique1){case P_.DELTA:r=hg(e.logicalLevelTechnique2===P_.RLE?rg(t,e.runs,e.numRleValues):t);break;case P_.RLE:r=rg(t,e.runs,e.numRleValues);break;case P_.NONE:r=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?Dg(r,i,0n):r}function Ug(t,e,i,r,n="int32"){let s=t.logicalLevelTechnique1;if(s===P_.RLE)return 1===t.runs?bg.CONST:bg.FLAT;if(s!==P_.DELTA||t.logicalLevelTechnique2!==P_.RLE)return 1===t.numValues?bg.CONST:bg.FLAT;let o=e instanceof xg?e.size():e;if(t.numRleValues!==o)return bg.FLAT;if(1===t.runs)return bg.SEQUENCE;if(2!==t.runs)return 1===t.numValues?bg.CONST:bg.FLAT;let a=r.get();if(t.physicalLevelTechnique===I_.VARINT)return function(t,e,i){let r=new k_(e.get());if("int64"===i){let e=Y_(t,r,4);return 2n===e[2]&&2n===e[3]}let n=H_(t,r,4);return 2===n[2]&&2===n[3]}(i,r,n)?bg.SEQUENCE:1===t.numValues?bg.CONST:bg.FLAT;let l=r.get(),h=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===h[2]&&2===h[3]?bg.SEQUENCE:1===t.numValues?bg.CONST:bg.FLAT}var Ng,Gg,qg,Vg=class extends E_{getValueFromBuffer(t){return this.dataBuffer[t]}},Zg=class extends S_{constructor(t,e,i,r,n){super(t,n?BigInt64Array.of(e):BigUint64Array.of(e),i,r)}getValueFromBuffer(t){return this.dataBuffer[0]+BigInt(t)*this.delta}};function Wg(t,e,i){return{x:Hg(t,e)-i,y:Hg(t>>1,e)-i}}function Hg(t,e){let i=0;for(let r=0;r<e;r++)i|=(t&1<<2*r)>>r;return i}function Yg(t,e,i,r,n,s,o){return t===qg.MORTON?function(t,e,i,r,n,s){let o=Array(n?r+1:r);for(let n=0;n<r;n++){let r=Wg(t[e[i+n]],s.numBits,s.coordinateShift);o[n]=new f(r.x,r.y)}return n&&(o[o.length-1]=o[0]),o}(e,i,r,n,s,o):function(t,e,i,r,n){let s=Array(n?r+1:r);for(let n=0;n<2*r;n+=2){let r=2*e[i+n/2];s[n/2]=new f(t[r],t[r+1])}return n&&(s[s.length-1]=s[0]),s}(e,i,r,n,s)}function Xg(t,e,i,r){let n=Array(r?i+1:i);for(let r=0;r<2*i;r+=2)n[r/2]=new f(t[e+r],t[e+r+1]);return r&&(n[n.length-1]=n[0]),n}!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"}(Ng||={}),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(Gg||={}),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(qg||={});var Jg=class{constructor(t,e,i,r,n){this._vertexBufferType=t,this._topologyVector=e,this._vertexOffsets=i,this._vertexBuffer=r,this._mortonSettings=n}get vertexBufferType(){return this._vertexBufferType}get topologyVector(){return this._topologyVector}get vertexOffsets(){return this._vertexOffsets}get vertexBuffer(){return this._vertexBuffer}getSimpleEncodedVertex(t){let e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getVertex(t){if(this.vertexOffsets&&this.mortonSettings){let e=Wg(this.vertexBuffer[this.vertexOffsets[t]],this.mortonSettings.numBits,this.mortonSettings.coordinateShift);return[e.x,e.y]}let e=this.vertexOffsets?2*this.vertexOffsets[t]:2*t;return[this.vertexBuffer[e],this.vertexBuffer[e+1]]}getGeometries(){return function(t){let e=Array(t.numGeometries),i=1,r=1,n=1,s=0,o=0,a=0,l=t.mortonSettings,h=t.topologyVector,u=h.geometryOffsets,c=h.partOffsets,p=h.ringOffsets,d=t.vertexOffsets,m=!d||0===d.length,_=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let h=0;h<t.numGeometries;h++){let y=t.geometryType(h);switch(y){case Ng.POINT:{let h,_;if(m)h=g[o++],_=g[o++];else if(t.vertexBufferType===qg.MORTON){let t=Wg(g[d[a++]],l.numBits,l.coordinateShift);h=t.x,_=t.y}else{let t=2*d[a++];h=g[t],_=g[t+1]}e[s++]=[[new f(h,_)]],u&&n++,c&&i++,p&&r++}break;case Ng.MULTIPOINT:{let h,c=u[n]-u[n-1];if(n++,m){h=Array(c);for(let t=0;t<c;t++){let e=g[o++],i=g[o++];h[t]=new f(e,i)}}else h=Yg(t.vertexBufferType,g,d,a,c,!1,l),a+=c;e[s++]=h.map((t=>[t])),i+=c,r+=c}break;case Ng.LINESTRING:{let h,f;_?(h=p[r]-p[r-1],r++):h=c[i]-c[i-1],i++,m?(f=Xg(g,o,h,!1),o+=2*h):(f=Yg(t.vertexBufferType,g,d,a,h,!1,l),a+=h),e[s++]=[f],u&&n++}break;case Ng.POLYGON:{let h=c[i]-c[i-1];i++;let f,_=Array(h-1),y=p[r]-p[r-1];if(r++,m){f=Xg(g,o,y,!0),o+=2*y;for(let t=0;t<_.length;t++)y=p[r]-p[r-1],r++,_[t]=Xg(g,o,y,!0),o+=2*y}else{f=Yg(t.vertexBufferType,g,d,a,y,!0,l),a+=y;for(let e=0;e<_.length;e++)y=p[r]-p[r-1],r++,_[e]=Yg(t.vertexBufferType,g,d,a,y,!0,l),a+=y}e[s++]=[f].concat(_),u&&n++}break;case Ng.MULTILINESTRING:{let h=u[n]-u[n-1];n++;let f=Array(h);for(let e=0;e<h;e++){let n;if(_?(n=p[r]-p[r-1],r++):n=c[i]-c[i-1],i++,m)f[e]=Xg(g,o,n,!1),o+=2*n;else{let i=Yg(t.vertexBufferType,g,d,a,n,!1,l);f[e]=i,a+=n}}e[s++]=f}break;case Ng.MULTIPOLYGON:{let h=u[n]-u[n-1];n++;let f=Array(h);for(let e=0;e<h;e++){let n=c[i]-c[i-1];i++;let s,h=Array(n-1),u=p[r]-p[r-1];r++,m?(s=Xg(g,o,u,!0),o+=2*u):(s=Yg(t.vertexBufferType,g,d,a,u,!0,l),a+=u);for(let e=0;e<h.length;e++){let i=p[r]-p[r-1];r++,m?(h[e]=Xg(g,o,i,!0),o+=2*i):(h[e]=Yg(t.vertexBufferType,g,d,a,i,!0,l),a+=i)}f[e]=[s].concat(h)}e[s++]=f.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return e}(this)}get mortonSettings(){return this._mortonSettings}},Kg=class extends Jg{constructor(t,e,i,r,n,s,o){super(i,r,n,s,o),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsPolygonGeometry(){return this._geometryType===Ng.POLYGON||this._geometryType===Ng.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function Qg(t,e,i,r){return new ty(qg.VEC_2,t,e,i,r)}var ty=class extends Jg{constructor(t,e,i,r,n,s){super(t,i,r,n,s),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)===Ng.POLYGON||this.geometryType(t)===Ng.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},ey=class{constructor(t,e,i,r){this._triangleOffsets=t,this._indexBuffer=e,this._vertexBuffer=i,this._topologyVector=r}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 Error("Cannot convert GpuVector to coordinates without topology information");let t=new Uint32Array(this.numGeometries);for(let e=0;e<this.numGeometries;e++)t[e]=this.geometryType(e);return Qg(t,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function iy(t,e,i,r,n,s){return new ry(t,e,i,r,n,s)}var ry=class extends ey{constructor(t,e,i,r,n,s){super(i,r,n,s),this._numGeometries=t,this._geometryType=e}geometryType(t){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}};function ny(t,e,i,r,n){return new sy(t,e,i,r,n)}var sy=class extends ey{constructor(t,e,i,r,n){super(e,i,r,n),this._geometryTypes=t}geometryType(t){return this._geometryTypes[t]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}};function oy(t,e,i,r){let n,s,o,a,l=wg(t,i);if(Ug(l,r,t,i)===bg.CONST){let h,u,c,f,p=kg(t,i,l);for(let r=0;r<e-1;r++){let e=wg(t,i);switch(e.physicalStreamType){case ug.LENGTH:switch(e.logicalStreamType.lengthType){case pg.GEOMETRIES:h=Tg(t,i,e);break;case pg.PARTS:u=Tg(t,i,e);break;case pg.RINGS:c=Tg(t,i,e);break;case pg.TRIANGLES:f=Tg(t,i,e)}break;case ug.OFFSET:switch(e.logicalStreamType.offsetType){case fg.VERTEX:n=zg(t,i,e);break;case fg.INDEX:a=zg(t,i,e)}break;case ug.DATA:cg.VERTEX===e.logicalStreamType.dictionaryType?s=Cg(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},s=zg(t,i,e))}}return a?void 0!==h||void 0!==u?iy(r,p,f,a,s,{geometryOffsets:h,partOffsets:u,ringOffsets:c}):iy(r,p,f,a,s):void 0===o?function(t,e,i,r,n){return new Kg(t,e,qg.VEC_2,i,r,n)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},n,s):function(t,e,i,r,n,s){return new Kg(t,e,qg.MORTON,i,r,n,s)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},n,s,o)}let h,u,c,f,p,d,m,_=zg(t,i,l);for(let r=0;r<e-1;r++){let e=wg(t,i);switch(e.physicalStreamType){case ug.LENGTH:switch(e.logicalStreamType.lengthType){case pg.GEOMETRIES:h=zg(t,i,e);break;case pg.PARTS:u=zg(t,i,e);break;case pg.RINGS:c=zg(t,i,e);break;case pg.TRIANGLES:f=Tg(t,i,e)}break;case ug.OFFSET:switch(e.logicalStreamType.offsetType){case fg.VERTEX:n=zg(t,i,e);break;case fg.INDEX:a=zg(t,i,e)}break;case ug.DATA:cg.VERTEX===e.logicalStreamType.dictionaryType?s=Cg(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},s=zg(t,i,e))}}return h?(p=ay(_,h,2),u&&c?(d=ly(_,p,u,!1),m=function(t,e,i,r){let n=new Uint32Array(i[i.length-1]+1),s=0;n[0]=s;let o=1,a=1,l=0;for(let h=0;h<t.length;h++){let u=t[h],c=e[h+1]-e[h];if(0!==u&&3!==u)for(let t=0;t<c;t++){let t=i[o]-i[o-1];o++;for(let e=0;e<t;e++)s=n[a++]=s+r[l++]}else for(let t=0;t<c;t++)n[a++]=++s,o++}return n}(_,p,d,c)):u&&(d=function(t,e,i){let r=new Uint32Array(e[e.length-1]+1),n=0;r[0]=n;let s=1,o=0;for(let a=0;a<t.length;a++){let l=t[a],h=e[a+1]-e[a];if(4===l||1===l)for(let t=0;t<h;t++)n=r[s++]=n+i[o++];else for(let t=0;t<h;t++)r[s++]=++n}return r}(_,p,u))):u&&c?(d=ay(_,u,1),m=ly(_,d,c,!0)):u&&(d=ay(_,u,0)),a&&!d?ny(_,f,a,s):a?ny(_,f,a,s,{geometryOffsets:p,partOffsets:d,ringOffsets:m}):void 0===o?Qg(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},n,s):function(t,e,i,r,n){return new ty(qg.MORTON,t,e,i,r,n)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},n,s,o)}function ay(t,e,i){let r=new Uint32Array(t.length+1),n=0;r[0]=n;let s=0;for(let o=0;o<t.length;o++)n=r[o+1]=n+(t[o]>i?e[s++]:1);return r}function ly(t,e,i,r){let n=new Uint32Array(e[e.length-1]+1),s=0;n[0]=s;let o=1,a=0;for(let l=0;l<t.length;l++){let h=t[l],u=e[l+1]-e[l];if(5===h||2===h||r&&(4===h||1===h))for(let t=0;t<u;t++)s=n[o++]=s+i[a++];else for(let t=0;t<u;t++)n[o++]=++s}return n}var hy=class extends M_{constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}},uy=class extends E_{getValueFromBuffer(t){return this.dataBuffer[t]}},cy=class extends M_{constructor(t,e,i,r){super(t,r?BigInt64Array.of(e):BigUint64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},fy=class extends M_{constructor(t,e,i,r){super(t,i,r),this.offsetBuffer=e}},py=class extends fy{constructor(t,e,i,r){super(t,e,i,r??e.length-1)}getValueFromBuffer(t){return Sg(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}},dy=class extends fy{constructor(t,e,i,r,n){super(t,i,r,n??e.length),this.indexBuffer=e,this.indexBuffer=e}getValueFromBuffer(t){let e=this.indexBuffer[t];return Sg(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}},my=class extends fy{constructor(t,e,i,r,n,s,o,a){super(t,i,r,o??e.length),this.indexBuffer=e,this.symbolOffsetBuffer=n,this.symbolTableBuffer=s,this.sharedDictionaryCache=a}getValueFromBuffer(t){this.decodedDictionary??(this.decodedDictionary=this.sharedDictionaryCache?.decodedDictionary,this.decodedDictionary??(this.decodedDictionary=this.decodeDictionary(),this.sharedDictionaryCache&&(this.sharedDictionaryCache.decodedDictionary=this.decodedDictionary)));let e=this.indexBuffer[t];return Sg(this.decodedDictionary,this.offsetBuffer[e],this.offsetBuffer[e+1])}decodeDictionary(){return this.symbolLengthBuffer??=this.offsetToLengthBuffer(this.symbolOffsetBuffer),function(t,e,i){let r=new Uint32Array(e.length);for(let t=1;t<e.length;t++)r[t]=r[t-1]+e[t-1];let n=new Uint8Array(function(t,e){let i=0;for(let r=0;r<e.length;r++){let n=e[r];255===n?(i++,r++):i+=t[n]}return i}(e,i)),s=0;for(let o=0;o<i.length;o++){let a=i[o];if(255===a)o++,n[s++]=i[o];else{let i=e[a],o=r[a];for(;i-- >0;)n[s++]=t[o++]}}return n}(this.symbolTableBuffer,this.symbolLengthBuffer,this.dataBuffer)}offsetToLengthBuffer(t){let e=new Uint32Array(t.length-1),i=t[0];for(let r=1;r<t.length;r++){let n=t[r];e[r-1]=n-i,i=n}return e}};function _y(t,e,i,r,n){let s,o,a,l,h,u,c,f=n;for(let t=0;t<r;t++){let t=wg(e,i);switch(t.physicalStreamType){case ug.PRESENT:{let r=new xg(Mg(e,t.numValues,t.byteLength,i),t.numValues);f=n??r;break}case ug.OFFSET:o=zg(e,i,t,0,f);break;case ug.LENGTH:{let r=Tg(e,i,t);pg.DICTIONARY===t.logicalStreamType.lengthType?s=r:pg.SYMBOL===t.logicalStreamType.lengthType?l=r:u=r;break}case ug.DATA:{let r=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);let n=t.logicalStreamType.dictionaryType;cg.FSST===n?h=r:cg.SINGLE===n||cg.SHARED===n?a=r:cg.NONE===n&&(c=r);break}}}return function(t,e,i,r,n,s,o){if(e){if(!(i&&r&&n&&s))throw Error(`Incomplete FSST dictionary string column "${t}"`);return new my(t,i,r,n,s,e,o)}}(t,h,o,s,a,l,f)??function(t,e,i,r,n){if(e){if(!i||!r)throw Error(`Incomplete dictionary string column "${t}"`);return n?new dy(t,i,r,e,n):new dy(t,i,r,e)}}(t,a,o,s,f)??function(t,e,i,r,n){if(e&&i){if(r)return n?new dy(t,r,e,i,n):new dy(t,r,e,i);if(n&&n.size()!==e.length-1){let r=new Uint32Array(n.size()),s=0;for(let t=0;t<n.size();t++)r[t]=n.get(t)?s++:0;return new dy(t,r,e,i,n)}return n?new py(t,e,i,n):new py(t,e,i)}}(t,u,c,o,f)}var gy,yy,vy=class extends M_{constructor(t,e,i){super(t,new Uint8Array,i??e.length),this.values=e}getValueFromBuffer(t){return this.values[t]}};function wy(t,e,i,r,n){let s,{lengthStream:o,flattenedValues:a,presentStream:l,dictionary:h}=t,u=e*i,c=i;if(l){s=new xg(new Uint8Array(Math.ceil(i/8)),i),c=0;for(let t=0;t<i;t++)l.get(u+t)&&(s.set(t,!0),c++)}let f=r+c;if(f>o.length)throw Error("Merged map counts underflow while decoding child streams");let p=Array(i),d=r,m=n;for(let t=0;t<i;t++){if(l&&!l.get(u+t)){p[t]=null;continue}let e=m+o[d++];if(e>a.length)throw Error("Map value stream underflow while decoding feature payload");let i=by(a,m,e,h);p[t]=i.value,m=i.nextIndex}let _=0;for(let t=r;t<f;t++)_+=o[t];let g=n+_;if(m!==g)throw Error("Unused flattened map values remain after decode");return{value:p,nullabilityBuffer:s,countsEnd:f,valuesEnd:g}}function by(t,e,i,r){return i-e==1||t[e]===yy.START_LIST?Dy(t,e,i,r):xy(t,e,i,r)}function xy(t,e,i,r){let n=Object.create(null),s=e;for(;s<i;){let e=Ey(t[s++],r);if("string"!=typeof e)throw Error(`Map key dictionary index does not resolve to a string: ${e}`);let o=Dy(t,s,i,r);n[e]=o.value,s=o.nextIndex}return{value:n,nextIndex:s}}function Dy(t,e,i,r){if(e>=i)throw Error("Unexpected end of map value stream");let n=t[e];if(n===yy.FALSE)return{value:!1,nextIndex:e+1};if(n===yy.TRUE)return{value:!0,nextIndex:e+1};if(n===yy.START_MAP){let n=My(t,e,i);return{value:xy(t,e+2,n,r).value,nextIndex:n}}if(n===yy.START_LIST){let n=My(t,e,i),s=[],o=e+2;for(;o<n;){let e=Dy(t,o,n,r);s.push(e.value),o=e.nextIndex}return{value:s,nextIndex:n}}return{value:Ey(n,r),nextIndex:e+1}}function My(t,e,i){if(e+1>=i)throw Error("Missing length for nested map/list payload");let r=t[e+1];if(r<2)throw Error(`Invalid nested payload length: ${r}`);let n=e+r;if(n>i)throw Error("Nested payload exceeds containing payload bounds");return n}function Ey(t,e){let i=t-yy.COUNT;if(i<0||i>=e.length)throw Error(`Scalar dictionary index out of range: ${t}`);return e[i]}function Ay(t,e){for(let i of e)t.push(i)}function Fy(t,e,i,r,n){return"scalarType"===i.type?function(t,e,i,r,n,s){let o;if(0===t)return null;if(s.nullable){let t=wg(e,i),r=t.numValues,n=i.get(),s=Mg(e,r,t.byteLength,i);i.set(n+t.byteLength),o=new xg(s,t.numValues)}let a=o??r;switch(n.physicalType){case 4:case 3:return function(t,e,i,r,n){let s=wg(t,e),o=Ug(s,n,t,e),a=3===r.physicalType;if(o===bg.FLAT){let r=Sy(n)?n:void 0,o=a?Cg(t,e,s,0,r):zg(t,e,s,0,r);return new A_(i.name,o,n)}if(o===bg.SEQUENCE){let r=$g(t,e,s);return new C_(i.name,r[0],r[1],s.numRleValues,a)}let l=a?function(t,e,i){let r=Pg(t,e,i);return 1===r.length?Q_(r[0]):function(t){return Q_(t[1])}(r)}(t,e,s):kg(t,e,s);return new z_(i.name,l,n,a)}(e,i,s,n,a);case 9:return _y(s.name,e,i,s.nullable?t-1:t,o)??null;case 0:return function(t,e,i,r,n){let s=wg(t,e),o=s.numValues,a=e.get(),l=Sy(n)?n:void 0,h=Mg(t,o,s.byteLength,e,l);e.set(a+s.byteLength);let u=new xg(h,o);return new hy(i.name,u,n)}(e,i,s,0,a);case 6:case 5:return function(t,e,i,r,n){let s=wg(t,e),o=Ug(s,r,t,e,"int64"),a=5===n.physicalType;if(o===bg.FLAT){let n=Sy(r)?r:void 0,o=a?Rg(t,e,s,n):Og(t,e,s,n);return new Vg(i.name,o,r)}if(o===bg.SEQUENCE){let r=jg(t,e,s);return new Zg(i.name,r[0],r[1],s.numRleValues,a)}let l=a?function(t,e,i){let r=Ig(t,e,i);return 1===r.length?tg(r[0]):function(t){return tg(t[1])}(r)}(t,e,s):Bg(t,e,s);return new cy(i.name,l,r,a)}(e,i,s,a,n);case 7:return function(t,e,i,r){let n=wg(t,e),s=Sy(r)?r:void 0,o=Eg(t,e,n.numValues,s);return new uy(i.name,o,r)}(e,i,s,a);case 8:return function(t,e,i,r){let n=wg(t,e),s=Sy(r)?r:void 0,o=Ag(t,e,n.numValues,s);return new F_(i.name,o,r)}(e,i,s,a);default:throw Error(`The specified data type for the field is currently not supported: ${n}`)}}(r,t,e,n,i.scalarType,i):2===i.complexType?.physicalType?function(t,e,i,r){let n=function(t){let e="complexType"===t.type?t.complexType.children:void 0;return e&&0!==e.length?e.map((e=>t.name+(e.name??""))):[t.name]}(i);if(0===r)return n.map((t=>new vy(t,[])));let s=function(t,e,i){let r=t[e.get()];e.add(1);let n=zg(t,e,wg(t,e)),s=i-1,o=[];r&gy.STRING&&(s-=function(t,e,i){let r=t[e.get()];e.add(1);let n=_y("",t,e,r);if(n)for(let t=0;t<n.size;t++)i.push(n.getValue(t));return r}(t,e,o)),s-=function(t,e,i,r){let n=0;return i&gy.INT32?(Ay(r,Cg(t,e,wg(t,e))),n++):i&gy.INT64&&(Ay(r,Rg(t,e,wg(t,e))),n++),i&gy.UINT32?(Ay(r,zg(t,e,wg(t,e))),n++):i&gy.UINT64&&(Ay(r,Og(t,e,wg(t,e))),n++),n}(t,e,r,o),s-=function(t,e,i,r){let n=0;return i&gy.FLOAT&&(Ay(r,Eg(t,e,wg(t,e).numValues)),n++),i&gy.DOUBLE&&(Ay(r,Ag(t,e,wg(t,e).numValues)),n++),n}(t,e,r,o);let a,l=0;if(r&gy.PRESENCE){let i=function(t,e){let i=wg(t,e);if(i.physicalStreamType!==ug.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,n=e.get(),s=new xg(Mg(t,r,i.byteLength,e),r);return e.set(n+i.byteLength),{value:s,count:r}}(t,e);a=i.value,l=i.count,s--}let h=new Uint32Array;if(s>0&&(h=zg(t,e,wg(t,e)),s--),0!==s)throw Error(`Unexpected number of remaining streams while decoding map column: ${s}`);return{lengthStream:n,dictionary:o,presentStream:a,presentCount:l,flattenedValues:h}}(t,e,r),o=(s.presentStream?s.presentCount:s.lengthStream.length)/n.length,a=[],l=0,h=0;for(let t=0;t<n.length;t++){let e=wy(s,t,o,l,h);a.push(new vy(n[t],e.value,e.nullabilityBuffer)),l=e.countsEnd,h=e.valuesEnd}return a}(t,e,i,r):0===r?null:function(t,e,i){let r,n,s,o,a=!1;for(;!a;){let i=wg(t,e);switch(i.physicalStreamType){case ug.LENGTH:pg.DICTIONARY===i.logicalStreamType.lengthType?r=Tg(t,e,i):s=Tg(t,e,i);break;case ug.DATA:cg.SINGLE===i.logicalStreamType.dictionaryType||cg.SHARED===i.logicalStreamType.dictionaryType?(n=t.subarray(e.get(),e.get()+i.byteLength),a=!0):o=t.subarray(e.get(),e.get()+i.byteLength),e.add(i.byteLength)}}if("complexType"!==i.type)throw Error(`Shared dictionary column ${i.name} must be a complex (struct) column.`);if(!r||!n)throw Error(`Incomplete shared dictionary for column "${i.name}"`);let l=i.complexType.children,h=[],u=o?{}:void 0,c=0;for(let a of l){let l=H_(t,e,1)[0];if(0===l)continue;let f,p=a.name?`${i.name}${a.name}`:i.name;if("scalarField"!==a.type||9!==a.scalarField.physicalType)throw Error("Currently only scalar string fields are implemented for a struct.");if(l>1&&!a.nullable||1===l&&a.nullable)throw Error(`The number of streams for the child field ${a.name} does not match its nullability. nullibilty: ${a.nullable}, numStreams: ${l}`);if(a.nullable){let i=wg(t,e);f=new xg(Mg(t,i.numValues,i.byteLength,e),i.numValues)}let d=zg(t,e,wg(t,e),0,f);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${p}"`);h[c++]=new my(p,d,r,n,s,o,f,u)}else h[c++]=new dy(p,d,r,n,f)}return h}(t,e,i)}function Sy(t){return t instanceof xg}!function(t){t[t.STRING=1]="STRING",t[t.INT32=2]="INT32",t[t.UINT32=4]="UINT32",t[t.INT64=8]="INT64",t[t.UINT64=16]="UINT64",t[t.FLOAT=32]="FLOAT",t[t.DOUBLE=64]="DOUBLE",t[t.PRESENCE=128]="PRESENCE"}(gy||={}),function(t){t[t.FALSE=0]="FALSE",t[t.TRUE=1]="TRUE",t[t.START_MAP=2]="START_MAP",t[t.START_LIST=3]="START_LIST",t[t.COUNT=4]="COUNT"}(yy||={});function Cy(t){switch(t){case 0:case 1:case 2:case 3:return{nullable:!!(1&t),columnScope:0,type:"scalarType",scalarType:{longID:!!(2&t),type:"logicalType",logicalType:0}};case 4:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:0,children:[]}};case 30:return{nullable:!1,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:1,children:[]}};case 31:return{nullable:!0,columnScope:0,type:"complexType",complexType:{type:"physicalType",physicalType:2,children:[]}};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}return{nullable:!!(1&t),columnScope:0,type:"scalarType",scalarType:{longID:!1,type:"physicalType",physicalType:e}}}(t)}}function zy(t){return 30===t||31===t}function Ty(t){if("scalarType"===t.type){let 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){let e=t.complexType;if("physicalType"===e.type)switch(e.physicalType){case 0:case 1:case 2:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",t),!1}function Py(t){return"scalarType"===t.type&&"logicalType"===t.scalarType?.type&&0===t.scalarType.logicalType}function Iy(t){return"complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const ky=new TextDecoder,$y="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function jy(t,e){let i=H_(t,e,1)[0];if(0===i)return"";let r=e.get(),n=t.subarray(r,r+i);return e.add(i),ky.decode(n)}function Ry(t,e){let i=H_(t,e,1)[0]>>>0,r=i>=10?Cy(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let n={...r,name:jy(t,e)};if("complexType"===n.type&&zy(i)){let i=n.complexType,r=H_(t,e,1)[0]>>>0;i.children=Array(r);for(let n=0;n<r;n++)i.children[n]=Ry(t,e)}return function(t){let e=t.name,i=t.nullable;return"scalarType"===t.type?{type:"scalarField",scalarField:t.scalarType,name:e,nullable:i}:{type:"complexField",complexField:t.complexType,name:e,nullable:i}}(n)}function Oy(t,e){let i,r=H_(t,e,1)[0]>>>0,n=Cy(r);if(!n)throw Error(`Unsupported column type code ${r}. Supported: ${$y}`);if(function(t){return t>=10}(r))i=jy(t,e);else if(r<4)i="id";else{if(4!==r)throw Error(`Unsupported column type code ${r}. Supported: ${$y}`);i="geometry"}let s={...n,name:i};if("complexType"===s.type&&zy(r)){let i=H_(t,e,1)[0]>>>0,r=s.complexType;r.children=Array(i);for(let n=0;n<i;n++)r.children[n]=Ry(t,e)}return s}function By(t,e){let i={featureTables:[]},r={};if(r.name=jy(t,e),0===r.name.length)throw Error("Missing layer name");let n=H_(t,e,1)[0]>>>0,s=H_(t,e,1)[0]>>>0;r.columns=Array(s);for(let i=0;i<s;i++)r.columns[i]=Oy(t,e);return i.featureTables.push(r),[i,n]}function Ly(t,e,i,r,n,s,o=!1){let a=e.scalarType?.longID?6:4,l="number"==typeof s?void 0:s,h=Ug(n,s,t,i,6===a?"int64":"int32");if(4===a)switch(h){case bg.FLAT:return new A_(r,zg(t,i,n,0,l),s);case bg.SEQUENCE:{let e=$g(t,i,n);return new C_(r,e[0],e[1],n.numRleValues,!1)}case bg.CONST:return new z_(r,kg(t,i,n),s,!1)}switch(h){case bg.FLAT:return o?new F_(r,function(t,e,i,r){let n=function(t,e,i){if(i.physicalLevelTechnique===I_.VARINT)return function(t,e){switch(e.logicalLevelTechnique1){case P_.DELTA:return e.logicalLevelTechnique2===P_.RLE&&(t=ng(t,e.runs,e.numRleValues)),function(t){t[0]=eg(t[0]);let e=t.length/4*4,i=1;if(e>=4)for(;i<e-4;i+=4){let e=t[i+1],r=t[i+2],n=t[i+3];t[i]=eg(t[i])+t[i-1],t[i+1]=eg(e)+t[i],t[i+2]=eg(r)+t[i+1],t[i+3]=eg(n)+t[i+2]}for(;i!==t.length;++i)t[i]=eg(t[i])+t[i-1]}(t),t;case P_.RLE:return function(t,e){return ng(t,e.runs,e.numRleValues)}(t,e);case P_.NONE:return t;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}}(function(t,e,i){let r=new Float64Array(i);for(let n=0;n<i;n++)r[n]=J_(t,e);return r}(t,e,i.numValues),i);let r=Lg(Ig(t,e,i),i);return Float64Array.from(r,Number)}(t,e,i);return r?Dg(n,r,0):n}(t,i,n,l),s):new Vg(r,Og(t,i,n,l),s);case bg.SEQUENCE:{let e=jg(t,i,n);return new Zg(r,e[0],e[1],n.numRleValues,!1)}case bg.CONST:return new cy(r,Bg(t,i,n),s,!1)}throw Error("Vector type not supported for id column.")}var Uy=class{constructor(t,e){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case Ng.POINT:case Ng.MULTIPOINT:this.type=1;break;case Ng.LINESTRING:case Ng.MULTILINESTRING:this.type=2;break;case Ng.POLYGON:case Ng.MULTIPOLYGON:this.type=3;break;default:this.type=0}this.extent=e,this.id=Number(this._featureData.id)}loadGeometry(){let t=[];for(let e of this._featureData.geometry.coordinates){let i=[];for(let t of e)i.push(new f(t.x,t.y));t.push(i)}return t}},Ny=class{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 Uy(this.features[t],this.extent)}},Gy=class{constructor(t){this.layers={};let e=function(t,e,i=!0){let r=new k_(0),n=[];for(;r.get()<t.length;){let e=H_(t,r,1)[0]>>>0,s=r.get()+e;if(s>t.length)throw Error(`Block overruns tile: ${s} > ${t.length}`);let o=H_(t,r,1)[0]>>>0;if(1!==o&&2!==o){r.set(s);continue}let[a,l]=By(t,r),h=a.featureTables[0],u=null,c=null,f=[],p=0;for(let e of h.columns){let n=e.name;if(Py(e)){let s=null;if(e.nullable){let e=wg(t,r),i=r.get(),n=Mg(t,e.numValues,e.byteLength,r);r.set(i+e.byteLength),s=new xg(n,e.numValues)}let o=wg(t,r);p=s?s.size():o.decompressedCount,u=Ly(t,e,r,n,o,s??p,i)}else if(Iy(e)){let e=H_(t,r,1)[0];if(0===p){let e=r.get();p=wg(t,r).decompressedCount,r.set(e)}c=oy(t,e,r,p)}else{let i=Ty(e)?H_(t,r,1)[0]:1;if(0===i)continue;let n=Fy(t,r,e,i,p);if(n)if(Array.isArray(n))for(let t of n)f.push(t);else f.push(n)}}let d=new T_(h.name,c,u,f,l);n.push(d),r.set(s)}return n}(new Uint8Array(t));this.layers=e.reduce(((t,e)=>({...t,[e.name]:new Ny(e)})),{})}};function qy(t,e,i,r,n){return $t(t,((t,s)=>{let o=e instanceof oa?e.get(s):null;return function(t){return"object"==typeof t&&!!t&&"evaluate"in t}(o)?o.evaluate(i,r,void 0,n):o}))}function Vy(t,e){return e-t}Vo("FeatureIndex",class{constructor(t,e){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Go(st,16,0),this.grid3D=new Go(st,16,0),this.featureIndexArray=new ll,this.promoteId=e}insert(t,e,i,r,n,s){let o=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);let a=s?this.grid3D:this.grid;for(let t of e){let e=[1/0,1/0,-1/0,-1/0];for(let 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]<8192&&e[1]<8192&&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 Gy(this.rawTileData).layers:new Fc(new Fp(this.rawTileData)).layers,this.sourceLayerCoder=new x_(this.vtLayers?Object.keys(this.vtLayers).sort():[b_])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();let n=t.params,s=st/t.tileSize/t.scale,o=Gs(n.filter,"queryRenderedFeatures filter",n.globalState),a=t.queryGeometry,l=t.queryPadding*s,h=yc.fromPoints(a),u=this.grid.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l),c=yc.fromPoints(t.cameraQueryGeometry).expandBy(l),f=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,((e,i,r,n)=>Fh(t.cameraQueryGeometry,e-l,i-l,r+l,n+l)));for(let t of f)u.push(t);u.sort(Vy);let p,d={};for(let l of u){if(l===p)continue;p=l;let h=this.featureIndexArray.get(l),u=null;this.loadMatchingFeature(d,h.bucketIndex,h.sourceLayerIndex,h.featureIndex,o,n.layers,n.availableImages,e,i,r,((e,i,r)=>(u||=fh(e),i.queryIntersectsFeature({queryGeometry:a,feature:e,featureState:r,geometry:u,zoom:this.z,transform:t.transform,pixelsToTileUnits:s,pixelPosMatrix:t.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:t.getElevation}))))}return d}loadMatchingFeature(t,e,i,r,n,s,o,a,l,h,u){let c=this.bucketLayerIDs[e];if(s&&!c.some((t=>s.has(t))))return;let f=this.sourceLayerCoder.decode(i),p=this.vtLayers[f].feature(r);if(n.needGeometry){let t=ph(p,!0);if(!n.filter(new Ko(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new Ko(this.tileID.overscaledZ),p))return;let d=this.getId(p,f);for(let e of c){if(s&&!s.has(e))continue;let i=a[e];if(!i)continue;let n={};d&&h&&(n=h.getState(i.sourceLayer||"_geojsonTileLayer",d));let c=St({},l[e]);c.paint=qy(c.paint,i.paint,p,n,o),c.layout=qy(c.layout,i.layout,p,n,o);let f=!u||u(p,i,n);if(!f)continue;let m=new D_(p,this.z,this.x,this.y,d);m.layer=c;let _=t[e];void 0===_&&(_=t[e]=[]),_.push({featureIndex:r,feature:m,intersectionZ:f})}}lookupSymbolFeatures(t,e,i,r,n,s,o,a){let l={};this.loadVTLayers();let h=Gs(n.filterSpec,"queryRenderedFeatures symbol filter",n.globalState);for(let n of t)this.loadMatchingFeature(l,i,r,n,h,s,o,a,e);return l}hasLayer(t){for(let e of this.bucketLayerIDs)for(let i of e)if(t===i)return!0;return!1}getId(t,e){let i=t.id;return this.promoteId&&(i=t.properties["string"==typeof this.promoteId?this.promoteId:this.promoteId[e]],"boolean"==typeof i&&(i=Number(i)),void 0===i&&t.properties?.cluster&&this.promoteId&&(i=Number(t.properties.cluster_id))),i}},{omit:["rawTileData","sourceLayerCoder"]});const Zy="RTLPluginLoaded";var Wy=class extends Re{constructor(...t){super(...t),this.status="unavailable",this.url=null,this.dispatcher=($m||($m=new km(Im(),Me),$m.registerMessageHandler("GR",((t,e,i)=>Fe(e,i)))),$m)}_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}async setRTLTextPlugin(t,e=!1){if(this.url)throw Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=fe.resolveURL(t),!this.url)throw 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()}async _requestImport(){await this._syncState("loading"),this.status="loaded",this.fire(new $e(Zy))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let Hy=null;function Yy(){return Hy||=new Wy,Hy}var Xy=class{constructor(t,e){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=Tt(),this.uses=0,this.tileSize=e,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rttObjects=[],this.rttFingerprint={},this.expiredRequestCount=0,this.state="loading",this.featureStateRevision=-1}isRenderable(t){return this.hasData()&&(!this.fadeEndTime||0!==this.fadingDirection||this.fadeOpacity>0)&&(t||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:t,fadingDirection:e,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=t,this.fadingDirection=e,this.fadingParentID=i,this.fadeEndTime=r}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=de(),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}getRTT(t){return this.rttObjects[t]}acquireRTT(t,e,i){return this.rttObjects[e]=t.acquireRTT(i)}releaseRTT(t){if(0!==this.rttObjects.length){for(let e of this.rttObjects)e&&t.releaseRTT(e);this.rttObjects.length=0}}loadVectorData(t,e,i){if(!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){let i={};if(!e)return i;for(let r of t){let t=r.layerIds.map((t=>e.getLayer(t))).filter(Boolean);if(0!==t.length){r.layers=t,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map((e=>t.filter((t=>t.id===e))[0])));for(let e of t)i[e.id]=r}}return i}(t.buckets,e),this.hasSymbolBuckets=!1;for(let t in this.buckets){let e=this.buckets[t];if(e instanceof Ud){if(this.hasSymbolBuckets=!0,!i)break;e.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(let t in this.buckets){let e=this.buckets[t];if(e instanceof Ud&&e.hasRTLText){this.hasRTLText=!0,Yy().lazyLoad();break}}this.queryPadding=0;for(let t in this.buckets){let i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new Ka;else this.state="loaded"}unloadVectorData(){for(let 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(let e in this.buckets){let i=this.buckets[e];i.uploadPending()&&i.upload(t)}let e=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new au(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new au(t,this.glyphAtlasImage,e.ALPHA),null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,e,i,r,n,s,o,a,l,h,u){return this.latestFeatureIndex?.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:s,tileSize:this.tileSize,pixelPosMatrix:h,transform:a,params:o,queryPadding:this.queryPadding*l,getElevation:u},t,e,i):{}}querySourceFeatures(t,e){let i=this.latestFeatureIndex;if(!i?.rawTileData)return;let r=i.loadVTLayers(),n=e?.sourceLayer?e.sourceLayer:"",s=r._geojsonTileLayer||r[n];if(!s)return;let o=Gs(e?.filter,`querySourceFeatures[${n}].filter`,e?.globalState),{z:a,x:l,y:h}=this.tileID.canonical,u={z:a,x:l,y:h};for(let e=0;e<s.length;e++){let r=s.feature(e);if(o.needGeometry){let t=ph(r,!0);if(!o.filter(new Ko(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new Ko(this.tileID.overscaledZ),r))continue;let c=new D_(r,a,l,h,i.getId(r,n));c.tile=u,t.push(c)}}hasData(){return"loaded"===this.state||"reloading"===this.state||"expired"===this.state}patternsLoaded(){return this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){let e=this.expirationTime;if(t.cacheControl){let e=function(t){let e={};if(t.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,((t,i,r,n)=>{let s=r||n;return e[i]=!s||s.toLowerCase(),""})),e["max-age"]){let t=parseInt(e["max-age"],10);isNaN(t)?delete e["max-age"]:e["max-age"]=t}return e}(t.cacheControl);e["max-age"]&&(this.expirationTime=Date.now()+1e3*e["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){let t=Date.now(),i=!1;if(this.expirationTime>t)i=!1;else if(e)if(this.expirationTime<e)i=!0;else{let r=this.expirationTime-e;r?this.expirationTime=t+Math.max(r,3e4):i=!0}else i=!0;i?(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(),2**31-1)}setFeatureState(t,e,i){if(!this.latestFeatureIndex?.rawTileData||0===Object.keys(t).length||this.featureStateRevision===i)return;this.featureStateRevision=i;let r=this.latestFeatureIndex.loadVTLayers();for(let i in this.buckets){if(!e.hasLayer(i))continue;let n=this.buckets[i],s=n.layers[0].sourceLayer||"_geojsonTileLayer",o=r[s],a=t[s];if(!o||!a||0===a.length)continue;n.update(a,o,this.imageAtlas?.patternPositions||{},this.dashPositions||{});let l=e.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(n)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<de()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=de()+t}setDependencies(t,e){let i={};for(let t of e)i[t]=!0;this.dependencies[t]=i}hasDependency(t,e){for(let i of t){let t=this.dependencies[i];if(t)for(let i of e)if(t[i])return!0}return!1}},Jy=class{constructor(t,e){this.max=t,this.onRemove=e,this.reset()}reset(){for(let t in this.data)for(let e of this.data[t])e.timeout&&clearTimeout(e.timeout),this.onRemove(e.value);return this.data={},this.order=[],this}add(t,e,i){let r=t.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);let n={value:e,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout((()=>{this.remove(t,n)}),i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){let 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){let 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){let 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;let i=t.wrapped().key,r=void 0===e?0:this.data[i].indexOf(e),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){let t=this._getAndRemoveByKey(this.order[0]);t&&this.onRemove(t)}return this}filter(t){let e=[];for(let i in this.data)for(let r of this.data[i])t(r.value)||e.push(r);for(let t of e)this.remove(t.value.tileID,t)}};function Ky(t){let e=[];for(let i in t)e.push({id:i,state:t[i]});return e}var Qy=class{constructor(){this.state={},this.stateChanges={},this.deletedStates={},this.revision=0}updateState(t,e,i){let r=String(e);if(this.stateChanges[t]||={},this.stateChanges[t][r]||={},St(this.stateChanges[t][r],i),null===this.deletedStates[t]){this.deletedStates[t]={};for(let e in this.state[t])if(e===r){this.deletedStates[t][r]={};for(let n in this.state[t][e])void 0===i[n]&&(this.deletedStates[t][r][n]=null)}else this.deletedStates[t][e]=null}else if(null===this.deletedStates[t]?.[r]){this.deletedStates[t][r]={};for(let e in this.state[t][r])void 0===i[e]&&(this.deletedStates[t][r][e]=null)}else for(let e in i)null===this.deletedStates[t]?.[r]?.[e]&&delete this.deletedStates[t][r][e]}removeFeatureState(t,e,i){if(null===this.deletedStates[t])return;let r=String(e);if(this.deletedStates[t]||={},i&&void 0!==e)null!==this.deletedStates[t][r]&&(this.deletedStates[t][r]||={},this.deletedStates[t][r][i]=null);else if(void 0!==e)if(this.stateChanges[t]?.[r])for(i in this.deletedStates[t][r]={},this.stateChanges[t][r])this.deletedStates[t][r][i]=null;else this.deletedStates[t][r]=null;else this.deletedStates[t]=null}getState(t,e){let i=String(e),r=St({},(this.state[t]||{})[i],(this.stateChanges[t]||{})[i]);if(null===this.deletedStates[t])return{};if(this.deletedStates[t]){let i=this.deletedStates[t][e];if(null===i)return{};for(let t in i)delete r[t]}return r}initializeTileState(t,e){let i={};for(let t in this.state)i[t]=Ky(this.state[t]);t.setFeatureState(i,e,this.revision)}coalesceChanges(t,e){let i={};for(let t in this.stateChanges){this.state[t]||={},i[t]||={};for(let e in this.stateChanges[t])this.state[t][e]||={},St(this.state[t][e],this.stateChanges[t][e]),i[t][e]=this.state[t][e]}for(let t in this.deletedStates)if(this.state[t]||={},i[t]||={},null===this.deletedStates[t])for(let e in this.state[t])this.state[t][e]={},i[t][e]={};else for(let e in this.deletedStates[t]){if(null===this.deletedStates[t][e])this.state[t][e]={};else for(let i of Object.keys(this.deletedStates[t][e]))delete this.state[t][e][i];i[t][e]=this.state[t][e]}if(this.stateChanges={},this.deletedStates={},0===Object.keys(i).length)return;this.revision++;let r={};for(let t in i)r[t]=Ky(i[t]);t.setFeatureState(r,e,this.revision)}},tv=class t{constructor(t,e){this.min=t,this.max=e,this.center=O([],j([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=I(this.min),n=I(this.max);for(let t=0;t<i.length;t++)r[t]=i[t]?this.min[t]:this.center[t],n[t]=i[t]?this.center[t]:this.max[t];return n[2]=this.max[2],new t(r,n)}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(let i of t.planes){let 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 r=0;r<3;r++)t[r]>0?(e+=t[r]*this.min[r],i+=t[r]*this.max[r]):(i+=t[r]*this.min[r],e+=t[r]*this.max[r]);return e>=0?2:i<0?0:1}},ev=class t{constructor(t,e,i){this.points=t,this.planes=e,this.aabb=i}static fromInvProjectionMatrix(e,i=1,r=0,n,s){let o=s?[[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=2**r,l=[[-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((t=>function(t,e,i,r){let n=Y([],t,e),s=1/n[3]/i*r;return 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}(n,n,[s,s,1/n[3],s])}(t,e,i,a)));n&&function(t,e,i,r){let n=r?4:0,s=r?0:4,o=0,a=[],l=[];for(let e=0;e<4;e++){let i=W([],t[e+s],t[e+n]),r=k(i);O(i,i,1/r),a.push(r),l.push(i)}for(let e=0;e<4;e++){let r=_t(t[e+n],l[e],i);o=null!==r&&r>=0?Math.max(o,r):Math.max(o,a[e])}let h=function(t,e){let i=[0,0,0,0];return L(i,N([],W([],t[e[0]],t[e[1]]),W([],t[e[2]],t[e[1]]))),i[3]=-U(i,t[e[0]]),i}(t,e),u=function(t,e){let i=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,1/H(t)),r=W([],e,O([],i,U(e,i))),n=H(r);if(n>0){let t=Math.sqrt(1-i[3]*i[3]);return dt(e,j([],O([],i,-i[3]),O([],r,t/n)))}return null}(i,h);if(null!==u){let t=u/U(l[0],h);o=Math.min(o,t)}for(let e=0;e<4;e++){let i=Math.min(o,a[e]);t[e+s]=[t[e+n][0]+l[e][0]*i,t[e+n][1]+l[e][1]*i,t[e+n][2]+l[e][2]*i,1]}}(l,o[0],n,s);let h=o.map((t=>{let e=L([],N([],W([],l[t[0]],l[t[1]]),W([],l[t[2]],l[t[1]]))),i=-U(e,l[t[1]]);return e.concat(i)})),u=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];for(let t of l)for(let e=0;e<3;e++)u[e]=Math.min(u[e],t[e]),c[e]=Math.max(c[e],t[e]);return new t(l,h,new tv(u,c))}};function iv(t,e,i){let r=e.intersectsFrustum(t);if(!i||0===r)return r;let n=e.intersectsPlane(i);return 0===n?0:2===r&&2===n?2:1}function rv(t,e,i){let r=0,n=(i-e)/10;for(let s=0;s<10;s++)r+=n*Math.cos(e+(s+.5)/10*(i-e))**+t;return r}function nv(t,e){return function(i,r,n,s,o){let a=2*((t-1)/It(Math.cos(Ht(Bc-o))/Math.cos(Ht(Bc)))-1),l=Math.acos(n/s),h=2*rv(a-1,0,Ht(o/2)),u=Math.min(Ht(Bc),l+Ht(o/2)),c=rv(a-1,Math.min(u,l-Ht(o/2)),u),f=Math.atan(r/n),p=i;return p+=It(s/Math.hypot(r,n)/Math.max(.5,Math.cos(Ht(o/2)))),p+=a*It(Math.cos(f))/2,p-=It(Math.max(1,c/h/e))/2,p}}const sv=nv(9.314,3);function ov(t,e){let i=(e.roundZoom?Math.round:Math.floor)(t.zoom+It(t.tileSize/e.tileSize));return Math.max(0,i)}function av(t,e,i){let r=t.planes[1],n=t.points.map((t=>{if(Math.abs(r[0]*t[0]+r[1]*t[1]+r[2]*t[2]+r[3])>1e-6)return t;let n=[t[0]-i[0],t[1]-i[1],t[2]-i[2]],s=r[0]*n[0]+r[1]*n[1]+r[2]*n[2];if(s>=-1e-9)return t;let o=e/-s;return[t[0]+n[0]*o,t[1]+n[1]*o,t[2]+n[2]*o,t[3]]})),s=t.planes.map(((t,i)=>1===i?[t[0],t[1],t[2],t[3]+e]:t)),o=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];for(let t of n)for(let e=0;e<3;e++)o[e]=Math.min(o[e],t[e]),a[e]=Math.max(a[e],t[e]);return new ev(n,s,new tv(o,a))}function lv(t,e){let i=t.getCameraFrustum(),r=t.getClippingPlane();r&&e.maxContentElevation>0&&({frustum:i,plane:r}=function(t,e,i,r){let n=Math.hypot(e[0],e[1],e[2]);if(0===n)return{frustum:t,plane:e};let s=1+r/Sc,o=At(-e[3]/n,-1,1),a=Math.cos(Math.acos(o)+Math.acos(1/s));return{frustum:av(t,Math.sqrt(s*s-1),i),plane:[e[0],e[1],e[2],-a*n]}}(i,r,t.cameraPosition,e.maxContentElevation));let n=t.getCoveringTilesDetailsProvider(),s=n.getCenter(t),o=function(t,e=t.center){let i=kc(1,e.lat)*t.worldSize;return Vc(e,t.elevation,t.pitch,t.bearing,t.cameraToCenterDistance/i)}(t,s),a=Oc.fromLngLat(s,t.elevation),l=function(t,e){let i=At((15-(Bc-t.pitch-t.fov/2))/15,0,1),r=Math.max(500,e??0);return t.elevation+i*r}(t,e.maxContentElevation),h=n.allowVariableZoom(t,e),u=ov(t,e),c=e.minzoom||0,f=void 0===e.maxzoom?t.maxZoom:e.maxzoom,p=Math.min(Math.max(0,u),f),d=2**p,m=[d*o.x,d*o.y,0],_=[d*a.x,d*a.y,0],g=Math.hypot(a.x-o.x,a.y-o.y),y=Math.abs(a.z-o.z),v=Math.hypot(g,y),w=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),b=[],x=[];if(t.renderWorldCopies&&n.allowWorldCopies())for(let t=1;t<=3;t++)b.push(w(-t)),b.push(w(t));for(b.push(w(0));b.length>0;){let s=b.pop(),d=s.x,g=s.y,w=s.fullyVisible,D={x:d,y:g,z:s.zoom},M=n.getTileBoundingVolume(D,s.wrap,l,e);if(!w){let t=iv(i,M,r);if(0===t)continue;w=2===t}let E=n.distanceToTile2d(o.x,o.y,D,M),A=u;h&&(A=(e.calculateTileZoom||sv)(t.zoom+It(t.tileSize/e.tileSize),E,y,v,t.fov)),A=(e.roundZoom?Math.round:Math.floor)(A),A=Math.max(0,A);let F=Math.min(A,f);if(s.wrap=n.getWrap(a,D,s.wrap),s.zoom>=F){if(s.zoom<c)continue;let t=p-s.zoom,i=m[0]-.5-(d<<t),r=m[1]-.5-(g<<t),n=e.reparseOverscaled?Math.max(s.zoom,A):s.zoom;x.push({tileID:new Hm(s.zoom===f?n:s.zoom,s.wrap,s.zoom,d,g),distanceSq:nt([_[0]-.5-d,_[1]-.5-g]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let t=0;t<4;t++)b.push({zoom:s.zoom+1,x:(d<<1)+t%2,y:(g<<1)+(t>>1),wrap:s.wrap,fullyVisible:w})}return x.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}function hv(t){return"raster"===t||"image"===t||"video"===t}function uv(t,e,i,r,n,s,o){if(!e.hasData())return!1;let{tileID:a,fadingRole:l,fadingDirection:h,fadingParentID:u}=e;if(0===l&&1===h&&u)return i[u.key]=u,!0;let c=Math.max(a.overscaledZ-n,s);for(let n=a.overscaledZ-1;n>=c;n--){let s=a.scaledTo(n),l=t.getLoadedTile(s);if(l)return e.setCrossFadeLogic({fadingRole:0,fadingDirection:1,fadingParentID:l.tileID,fadeEndTime:r+o}),l.setCrossFadeLogic({fadingRole:1,fadingDirection:0,fadeEndTime:r+o}),i[s.key]=s,!0}return!1}function cv(t,e,i,r,n,s){if(!e.hasData())return!1;let o=e.tileID.children(n),a=fv(t,e,o,i,r,n,s);if(a)return!0;for(let l of o)fv(t,e,l.children(n),i,r,n,s)&&(a=!0);return a}function fv(t,e,i,r,n,s,o){if(i[0].overscaledZ>s)return!1;let a=!1;for(let s of i){let i=t.getLoadedTile(s);if(!i)continue;let{fadingRole:l,fadingDirection:h,fadingParentID:u}=i;(0!==l||0!==h||!u)&&(i.setCrossFadeLogic({fadingRole:0,fadingDirection:0,fadingParentID:e.tileID,fadeEndTime:n+o}),e.setCrossFadeLogic({fadingRole:1,fadingDirection:1,fadeEndTime:n+o})),r[s.key]=s,a=!0}return a}function pv(t,e,i,r){let n=t.tileID;return!!t.selfFading||!t.hasData()&&(!!e.has(n)&&(t.setSelfFadeLogic(i+r),!0))}function dv(t,e){t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.needsColorReliefPrepare=!0;let i=e.tileID.canonical.x-t.tileID.canonical.x,r=e.tileID.canonical.y-t.tileID.canonical.y,n=2**t.tileID.canonical.z,s=e.tileID.key;(0!==i||0!==r)&&(Math.abs(r)>1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),e.dem&&t.dem&&(t.dem.backfillBorder(e.dem,i,r),t.neighboringTiles?.[s]&&(t.neighboringTiles[s].backfilled=!0))))}var mv=class{constructor(){this._tiles={}}handleWrapJump(t){let e={};for(let i in this._tiles){let r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e}setFeatureState(t,e,i){for(let r in this._tiles)this._tiles[r].setFeatureState(t,e,i)}getAllTiles(){return Object.values(this._tiles)}getAllIds(t=!1){return t?Object.values(this._tiles).map((t=>t.tileID)).sort(Km).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){let e=this.getTileById(t.key);return e?.hasData()?e:null}isIdRenderable(t,e=!1){return this.getTileById(t)?.isRenderable(e)}getRenderableIds(t=0,e){let i=[];for(let t of this.getAllIds())this.isIdRenderable(t,e)&&i.push(this.getTileById(t));return e?i.sort(((e,i)=>{let r=e.tileID,n=i.tileID,s=new f(r.canonical.x,r.canonical.y)._rotate(-t),o=new f(n.canonical.x,n.canonical.y)._rotate(-t);return r.overscaledZ-n.overscaledZ||o.y-s.y||o.x-s.x})).map((t=>t.tileID.key)):i.map((t=>t.tileID)).sort(Km).map((t=>t.key))}},_v=class t extends Re{static{this.maxUnderzooming=10}static{this.maxOverzooming=3}constructor(t,e,i){super(),this._maxContentElevationSeen=0,this.id=t,this.dispatcher=i,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,r)=>{let n=new((t=>{switch(t){case"geojson":return a_;case"image":return __;case"raster":return qm;case"raster-dem":return Qm;case"vector":return Gm;case"video":return y_;case"canvas":return v_}return w_[t]})(e.type))(t,e,i,r);if(n.id!==t)throw Error(`Expected Source id to be ${t} instead of ${n.id}`);return n})(t,e,i,this),this._inViewTiles=new mv,this._outOfViewCache=new Jy(0,(t=>this._unloadTile(t))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Qy,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source?.onAdd&&this._source.onAdd(t)}onRemove(t){for(let t of this._inViewTiles.getAllTiles())t.unloadVectorData();this.clearTiles(),this._source?.onRemove&&this._source.onRemove(t),this._inViewTiles=new mv}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!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(let 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;let t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}async _loadTile(t,e,i,r){try{let n=await this._source.loadTile(t);this._tileLoaded(t,e,i,r,n)}catch(e){t.state="errored",404===e.status?this.update(this.transform,this.terrain):this._source.fire(new je(at(e),{tile:t}))}}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new Ne("dataabort",{tile:t,coord:t.tileID}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._inViewTiles,this.style);for(let e of this._inViewTiles.getAllTiles())e.upload(t),e.prepare(this.map.style.imageManager)}getIds(){return this._inViewTiles.getAllIds(!0)}getRenderableIds(t){return this._inViewTiles.getRenderableIds(this.transform?.bearingInRadians,t)}hasRenderableParent(t){let e=t.overscaledZ-1;if(e>=this._source.minzoom){let 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(let i of this._inViewTiles.getAllIds()){let r=this._inViewTiles.getTileById(i);(!e||this._source.shouldReloadTile(r,e))&&(t?this._reloadTile(i,"errored"===r.state?"loading":"expired"):"errored"!==r.state&&this._reloadTile(i,"reloading"))}}}async _reloadTile(t,e){let i=this._inViewTiles.getTileById(t);if(!i)return;let r=i.hasData();"loading"!==i.state&&(i.state=e),await this._loadTile(i,t,e,r)}_tileLoaded(t,e,i,r,n){r||(t.timeAdded=de(),t.selfFading&&(t.fadeEndTime=t.timeAdded+this._rasterFadeDuration)),"expired"===i&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(e,t),!n?.unmodified&&("raster-dem"===this.getSource().type&&t.dem&&function(t,e){let i=e.getRenderableIds();for(let r of i){if(!t.neighboringTiles?.[r])continue;let i=e.getTileById(r);t.neighboringTiles[r].backfilled||dv(t,i),!i.neighboringTiles?.[t.tileID.key]?.backfilled&&dv(i,t)}}(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.style),t.aborted||this._source.fire(new Ne("data",{tile:t,coord:t.tileID})))}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._inViewTiles.getTileById(t)}_retainLoadedChildren(e,i){let r=this._getLoadedDescendents(i),n=new Set;for(let s of i){let i=r[s.key];if(!i?.length){n.add(s);continue}let o=s.overscaledZ+t.maxOverzooming,a=i.filter((t=>t.tileID.overscaledZ<=o));if(!a.length){n.add(s);continue}let l=Math.min(...a.map((t=>t.tileID.overscaledZ))),h=a.filter((t=>t.tileID.overscaledZ===l)).map((t=>t.tileID));for(let t of h)e[t.key]=t;this._areDescendentsComplete(h,l,s.overscaledZ)||n.add(s)}return n}_getLoadedDescendents(t){let e={};for(let i of this._inViewTiles.getAllTiles().filter((t=>t.hasData())))for(let r of t)i.tileID.isChildOf(r)&&(e[r.key]||=[],e[r.key].push(i));return e}_areDescendentsComplete(t,e,i){return 1===t.length&&t[0].isOverscaled()?t[0].overscaledZ===e:4**(e-i)===t.length}getLoadedTile(t){return this._inViewTiles.getLoadedTile(t)}updateCacheSize(t){let e=(Math.ceil(t.width/this._source.tileSize)+1)*(Math.ceil(t.height/this._source.tileSize)+1),i=Math.floor(e*(null===this._maxTileCacheZoomLevels?xe.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),r="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,i):i;this._outOfViewCache.setMaxSize(r)}handleWrapJump(t){let e=Math.round((t-(void 0===this._prevLng?t:this._prevLng))/360);this._prevLng=t,e&&(this._inViewTiles.handleWrapJump(e),this._resetTileReloadTimers())}_updateMaxContentElevation(){let t=this._maxContentElevationSeen,e=this.map?.style?._layers;if(!e)return t;let i=this._inViewTiles.getAllTiles();for(let r in e){let n=e[r];if("symbol"!==n.type||n.source!==this.id||n.isHidden(this.transform.zoom))continue;let s=n;if(!s.layout)continue;let o=s.layout.get("symbol-height-offset");if(t=Math.max(t,o.constantOr(0)),!o.isConstant())for(let e of i){let i=e.getBucket(n);i&&i.maxHeightOffset>t&&(t=i.maxHeightOffset)}}return this._maxContentElevationSeen=t,t}update(t,e){if(!this._sourceLoaded||this._paused)return;let i;this.transform=t,this.terrain=e,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?i=t.getVisibleUnwrappedCoordinates(this._source.tileID).map((t=>new Hm(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=lv(t,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?Math.max(this._source.maxzoom,t.maxZoom-this.map._zoomLevelsToOverscale):this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:e,calculateTileZoom:this._source.calculateTileZoom,maxContentElevation:this._updateMaxContentElevation()}),this._source.hasTile&&(i=i.filter((t=>this._source.hasTile(t))))):i=[],this.usedForTerrain&&(i=this._addTerrainIdealTiles(i));let r=0===i.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new Ne("data",{sourceDataType:"idle",sourceId:this.id}));let n=ov(t,this._source),s=this._updateRetainedTiles(i,n),o=hv(this._source.type);o&&this._rasterFadeDuration>0&&!e&&function(t,e,i,r,n,s,o){let a=de(),l=function(t){if(!t.length)return new Set;let e=Math.max(...t.map((t=>t.canonical.z))),i=1/0,r=-1/0,n=1/0,s=-1/0,o=[];for(let a of t){let{x:t,y:l,z:h}=a.canonical,u=2**(e-h),c=t*u,f=l*u;o.push({id:a,x:c,y:f}),c<i&&(i=c),c>r&&(r=c),f<n&&(n=f),f>s&&(s=f)}let a=new Set;for(let t of o)(t.x===i||t.x===r||t.y===n||t.y===s)&&a.add(t.id);return a}(e);for(let h of e){let e=t.getTileById(h.key);(0===e.fadingDirection||0===e.fadeOpacity)&&e.resetFadeLogic(),!uv(t,e,i,a,r,n,o)&&(cv(t,e,i,a,s,o)||pv(e,l,a,o)||e.resetFadeLogic())}}(this._inViewTiles,i,s,this._maxFadingAncestorLevels,this._source.minzoom,this._source.maxzoom,this._rasterFadeDuration),o?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(t){for(let e of this._inViewTiles.getAllIds())t[e]||this._removeTile(e)}_cleanUpVectorTiles(t){for(let e of this._inViewTiles.getAllIds()){let 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){let e=[];for(let i of t)if(i.canonical.z>this._source.minzoom){let t=i.scaledTo(i.canonical.z-1);e.push(t);let r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));e.push(r)}return t.concat(e)}releaseSymbolFadeTiles(){for(let t of this._inViewTiles.getAllIds())this._inViewTiles.getTileById(t).holdingForSymbolFade()&&this._removeTile(t)}_updateRetainedTiles(e,i){let r=new Set;for(let t of e)this._addTile(t).hasData()||r.add(t);let n=e.reduce(((t,e)=>(t[e.key]=e,t)),{}),s=this._retainLoadedChildren(n,r),o={},a=Math.max(i-t.maxUnderzooming,this._source.minzoom);for(let t of s){let e=this._inViewTiles.getTileById(t.key),i=e?.wasRequested();for(let r=t.overscaledZ-1;r>=a;--r){let s=t.scaledTo(r);if(o[s.key])break;if(o[s.key]=!0,e=this.getTile(s),!e&&i&&(e=this._addTile(s)),e){let t=e.hasData();if((t||!this.map?.cancelPendingTileRequestsWhileZooming||i)&&(n[s.key]=s),i=e.wasRequested(),t)break}}}return n}_addTile(t){let e=this._inViewTiles.getTileById(t.key);if(e)return e;e=this._outOfViewCache.getAndRemove(t),e&&(e.resetFadeLogic(),this._setTileReloadTimer(t.key,e),e.tileID=t,this._state.initializeTileState(e,this.style));let i=e;return e||(e=new Xy(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(e,t.key,e.state,!1)),e.uses++,this._inViewTiles.setTile(t.key,e),i||this._source.fire(new Ne("dataloading",{tile:e,coord:e.tileID})),e}_setTileReloadTimer(t,e){this._clearTileReloadTimer(t);let i=e.getExpiryTimeout();i&&(this._timers[t]=setTimeout((()=>{this._reloadTile(t,"expired"),delete this._timers[t]}),i))}_clearTileReloadTimer(t){let e=this._timers[t];e&&(clearTimeout(e),delete this._timers[t])}_resetTileReloadTimers(){for(let t in this._timers)clearTimeout(this._timers[t]),delete this._timers[t];for(let t of this._inViewTiles.getAllIds()){let e=this._inViewTiles.getTileById(t);this._setTileReloadTimer(t,e)}}refreshTiles(t){for(let e of this._inViewTiles.getAllIds()){let 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){let 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){if("source"===t.dataType){if("metadata"===t.sourceDataType)return void(this._sourceLoaded=!0);"content"===t.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(t.sourceDataChanged,t.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}}resetMaxContentElevation(){this._maxContentElevationSeen=0}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1,this.resetMaxContentElevation();for(let t of this._inViewTiles.getAllIds())this._removeTile(t);this._outOfViewCache.reset()}tilesIn(t,e,i){let r=[],n=this.transform;if(!n)return r;let s=n.getCoveringTilesDetailsProvider().allowWorldCopies(),o=i?n.getCameraQueryGeometry(t):t,a=t=>n.screenPointToMercatorCoordinate(t,this.terrain),l=this.transformBbox(t,a,!s),h=this.transformBbox(o,a,!s),u=this.getIds(),c=yc.fromPoints(h);for(let t of u){let i=this._inViewTiles.getTileById(t);if(i.holdingForSymbolFade())continue;let o=s?[i.tileID]:[i.tileID.unwrapTo(-1),i.tileID.unwrapTo(0)],a=2**(n.zoom-i.tileID.overscaledZ),u=e*i.queryPadding*st/i.tileSize/a;for(let t of o){let e=c.map((e=>t.getTilePoint(new Oc(e.x,e.y))));if(e.expandBy(u),e.intersects(vc)){let e=l.map((e=>t.getTilePoint(e))),n=h.map((e=>t.getTilePoint(e)));r.push({tile:i,tileID:s?t:t.unwrapTo(0),queryGeometry:e,cameraQueryGeometry:n,scale:a})}}}return r}transformBbox(t,e,i){let r=t.map(e);if(i){let i=yc.fromPoints(t);i.shrinkBy(.001*Math.min(i.width(),i.height()));let n=i.map(e);yc.fromPoints(r).covers(n)||(r=r.map((t=>t.x>.5?new Oc(t.x-1,t.y,t.z):t)))}return r}getVisibleCoordinates(t){let e=this.getRenderableIds(t).map((t=>this._inViewTiles.getTileById(t).tileID));return this.transform&&this.transform.populateCache(e),e}hasTransition(){return!!this._source.hasTransition()||hv(this._source.type)&&function(t,e){if(e<=0)return!1;let i=de();for(let e of t.getAllTiles())if(e.fadeEndTime>=i)return!0;return!1}(this._inViewTiles,this._rasterFadeDuration)}setRasterFadeDuration(t){this._rasterFadeDuration=t}setFeatureState(t,e,i){t||=b_,this._state.updateState(t,e,i)}removeFeatureState(t,e,i){t||=b_,this._state.removeFeatureState(t,e,i)}getFeatureState(t,e){return t||=b_,this._state.getState(t,e)}setDependencies(t,e,i){let r=this._inViewTiles.getTileById(t);r&&r.setDependencies(e,i)}reloadTilesForDependencies(t,e){for(let 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(let t of this._inViewTiles.getAllTiles())if("loaded"!==t.state&&"errored"!==t.state)return!1;return!0}},gv=class{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=At(t,0,1);let e=1,i=this._distances[e],r=t*this.paddedLength+this.padding;for(;i<r&&e<this._distances.length;)i=this._distances[++e];let n=e-1,s=this._distances[n],o=i-s,a=o>0?(r-s)/o:0;return this.points[n].mult(1-a).add(this.points[e].mult(a))}};function yv(t,e,i,r,n){return n?t?t(e,i)+r:0===r?void 0:r:r}function vv(t,e){let i=!0;return"always"===t||("never"===t||"never"===e)&&(i=!1),i}var wv=class{constructor(t,e,i){let r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(t/i),this.yCellCount=Math.ceil(e/i);for(let t=0;t<this.xCellCount*this.yCellCount;t++)r.push([]),n.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,r,n){this._forEachCell(e,i,r,n,this._insertBoxCell,this.boxUid++),this.boxKeys.push(t),this.bboxes.push(e),this.bboxes.push(i),this.bboxes.push(r),this.bboxes.push(n)}insertCircle(t,e,i,r){this._forEachCell(e-r,i-r,e+r,i+r,this._insertCircleCell,this.circleUid++),this.circleKeys.push(t),this.circles.push(e),this.circles.push(i),this.circles.push(r)}_insertBoxCell(t,e,i,r,n,s){this.boxCells[n].push(s)}_insertCircleCell(t,e,i,r,n,s){this.circleCells[n].push(s)}_query(t,e,i,r,n,s,o){if(i<0||t>this.width||r<0||e>this.height)return[];let a=[];if(t<=0&&e<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:t,y1:e,x2:i,y2:r}];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++){let e=this.circles[3*t],i=this.circles[3*t+1],r=this.circles[3*t+2];a.push({key:this.circleKeys[t],x1:e-r,y1:i-r,x2:e+r,y2:i+r})}}else this._forEachCell(t,e,i,r,this._queryCell,a,{hitTest:n,overlapMode:s,seenUids:{box:{},circle:{}}},o);return a}query(t,e,i,r){return this._query(t,e,i,r,!1,null)}hitTest(t,e,i,r,n,s){return this._query(t,e,i,r,!0,n,s).length>0}hitTestCircle(t,e,i,r,n){let s=t-i,o=t+i,a=e-i,l=e+i;if(o<0||s>this.width||l<0||a>this.height)return!1;let h=[];return this._forEachCell(s,a,o,l,this._queryCellCircle,h,{hitTest:!0,overlapMode:r,circle:{x:t,y:e,radius:i},seenUids:{box:{},circle:{}}},n),h.length>0}_queryCell(t,e,i,r,n,s,o,a){let{seenUids:l,hitTest:h,overlapMode:u}=o,c=this.boxCells[n],f=1e-6;if(null!==c){let n=this.bboxes;for(let o of c)if(!l.box[o]){l.box[o]=!0;let c=4*o,p=this.boxKeys[o];if(t<=n[c+2]+f&&e<=n[c+3]+f&&i>=n[c+0]-f&&r>=n[c+1]-f&&(!a||a(p))&&(!h||!vv(u,p.overlapMode))&&(s.push({key:p,x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]}),h))return!0}}let p=this.circleCells[n];if(null!==p){let n=this.circles;for(let o of p)if(!l.circle[o]){l.circle[o]=!0;let c=3*o,f=this.circleKeys[o];if(this._circleAndRectCollide(n[c],n[c+1],n[c+2],t,e,i,r)&&(!a||a(f))&&(!h||!vv(u,f.overlapMode))){let t=n[c],e=n[c+1],i=n[c+2];if(s.push({key:f,x1:t-i,y1:e-i,x2:t+i,y2:e+i}),h)return!0}}}return!1}_queryCellCircle(t,e,i,r,n,s,o,a){let{circle:l,seenUids:h,overlapMode:u}=o,c=this.boxCells[n];if(null!==c){let t=this.bboxes;for(let e of c)if(!h.box[e]){h.box[e]=!0;let i=4*e,r=this.boxKeys[e];if(this._circleAndRectCollide(l.x,l.y,l.radius,t[i+0],t[i+1],t[i+2],t[i+3])&&(!a||a(r))&&!vv(u,r.overlapMode))return s.push(!0),!0}}let f=this.circleCells[n];if(null!==f){let t=this.circles;for(let e of f)if(!h.circle[e]){h.circle[e]=!0;let i=3*e,r=this.circleKeys[e];if(this._circlesCollide(t[i],t[i+1],t[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!vv(u,r.overlapMode))return s.push(!0),!0}}}_forEachCell(t,e,i,r,n,s,o,a){let l=this._convertToXCellCoord(t),h=this._convertToYCellCoord(e),u=this._convertToXCellCoord(i),c=this._convertToYCellCoord(r);for(let f=l;f<=u;f++)for(let l=h;l<=c;l++)if(n.call(this,t,e,i,r,this.xCellCount*l+f,s,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,r,n,s){let o=r-t,a=n-e,l=i+s;return l*l>o*o+a*a}_circleAndRectCollide(t,e,i,r,n,s,o){let a=(s-r)/2,l=Math.abs(t-(r+a));if(l>a+i)return!1;let h=(o-n)/2,u=Math.abs(e-(n+h));if(u>h+i)return!1;if(l<=a||u<=h)return!0;let c=l-a,f=u-h;return c*c+f*f<=i*i}};function bv(t,e){let i=1/(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]),r=1/(e[8]*e[8]+e[9]*e[9]+e[10]*e[10]),n=e[0]*i,s=e[4]*i,o=e[8]*r,a=e[1]*i,l=e[5]*i,h=e[9]*r,u=e[2]*i,c=e[6]*i,f=e[10]*r;t[0]=n,t[1]=s,t[2]=o,t[4]=a,t[5]=l,t[6]=h,t[8]=u,t[9]=c,t[10]=f;let p=e[12],d=e[13],m=e[14];return t[12]=-n*p-a*d-u*m,t[13]=-s*p-l*d-c*m,t[14]=-o*p-h*d-f*m,t[3]=0,t[7]=0,t[11]=0,t[15]=1,t}const xv=w();function Dv(t,e,i){let r=w();if(!t){let{vecSouth:t,vecEast:i}=Ev(e),n=y();n[0]=i[0],n[1]=i[1],n[2]=t[0],n[3]=t[1],function(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i*s-n*r;o&&(t[0]=s*(o=1/o),t[1]=-r*o,t[2]=-n*o,t[3]=i*o)}(n,n),r[0]=n[0],r[1]=n[1],r[4]=n[2],r[5]=n[3]}return A(r,r,[1/i,1/i,1]),r}function Mv(t,e,i,r){if(t){let t=w();if(!e){let{vecSouth:e,vecEast:r}=Ev(i);t[0]=r[0],t[1]=r[1],t[4]=e[0],t[5]=e[1]}return A(t,t,[r,r,1]),t}return i.pixelsToClipSpaceMatrix}function Ev(t){let e=Math.cos(t.rollInRadians),i=Math.sin(t.rollInRadians),r=Math.cos(t.pitchInRadians),n=Math.cos(t.bearingInRadians),s=Math.sin(t.bearingInRadians),o=Q();o[0]=-n*r*i-s*e,o[1]=-s*r*i+n*e;let a=it(o);a<1e-9?rt(o):et(o,o,1/a);let l=Q();l[0]=n*r*e-s*i,l[1]=s*r*e+n*i;let h=it(l);return h<1e-9?rt(l):et(l,l,1/h),{vecEast:l,vecSouth:o}}function Av(t,e,i){return yv(t.getElevation,e,i,t.heightOffset??0,t.heightAnchorGround??!0)}function Fv(t,e,i,r){let n;null==r?(n=[t,e,0,1],qv(n,n,i)):(n=[t,e,r,1],Y(n,n,i));let s=n[3];return{point:new f(n[0]/s,n[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Sv(t,e){return.5+t/e*.5}function Cv(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function zv(t,e,i,r,n,s,o,a,l,h,u,c,p){let d=i?t.textSizeData:t.iconSizeData,m=nd(d,e.frameRenderContext.transform.zoom),_=[256/e.width*2+1,256/e.height*2+1],g=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;g.clear();let y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,w=e.frameRenderContext.transform.width/e.frameRenderContext.transform.height,b=!1;for(let i=0;i<v.length;i++){let x=v.get(i);if(x.hidden||2===x.writingMode&&!b){Gv(x.numGlyphs,g);continue}b=!1;let D=new f(x.anchorX,x.anchorY),M={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.frameRenderContext.transform,tileAnchorPoint:D,unwrappedTileID:l,width:h,height:u,translation:c},E=Ov(x.anchorX,x.anchorY,M);if(!Cv(E.point,_)){Gv(x.numGlyphs,g);continue}let A=Sv(e.frameRenderContext.transform.cameraToCenterDistance,E.signedDistanceFromCamera),F=rd(d,m,x),S=s?F*e.frameRenderContext.transform.getPitchedTextCorrection(x.anchorX,x.anchorY,l)/A:F*A,C=Iv({projectionContext:M,pitchedLabelPlaneMatrixInverse:n,symbol:x,fontSize:S,flip:!1,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a});b=C.useVertical,(C.notEnoughRoom||b||C.needsFlipping&&Iv({projectionContext:M,pitchedLabelPlaneMatrixInverse:n,symbol:x,fontSize:S,flip:!0,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a}).notEnoughRoom)&&Gv(x.numGlyphs,g)}i?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function Tv(t,e,i,r,n,s,o,a){let l=s.glyphStartIndex+s.numGlyphs,h=s.lineStartIndex,u=s.lineStartIndex+s.lineLength,c=e.getoffsetX(s.glyphStartIndex),f=e.getoffsetX(l-1),p=Uv(t*c,i,r,n,s.segment,h,u,a,o);if(!p)return null;let d=Uv(t*f,i,r,n,s.segment,h,u,a,o);return!d||a.projectionCache.anyProjectionOccluded?null:{first:p,last:d}}function Pv(t,e,i,r){return 1===t&&Math.abs(i.y-e.y)>Math.abs(i.x-e.x)*r?{useVertical:!0}:(2===t?e.y<i.y:e.x>i.x)?{needsFlipping:!0}:null}function Iv(t){let e,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:s,flip:o,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:h,aspectRatio:u,rotateToLine:c}=t,p=s/24,d=n.lineOffsetX*p,m=n.lineOffsetY*p;if(n.numGlyphs>1){let t=n.glyphStartIndex+n.numGlyphs,s=n.lineStartIndex,h=n.lineStartIndex+n.lineLength,f=Tv(p,l,d,m,o,n,c,i);if(!f)return{notEnoughRoom:!0};let _=Rv(f.first.point.x,f.first.point.y,i,r),g=Rv(f.last.point.x,f.last.point.y,i,r);if(a&&!o){let t=Pv(n.writingMode,_,g,u);if(t)return t}e=[f.first];for(let r=n.glyphStartIndex+1;r<t-1;r++){let t=Uv(p*l.getoffsetX(r),d,m,o,n.segment,s,h,i,c);if(!t)return{notEnoughRoom:!0};e.push(t)}e.push(f.last)}else{if(a&&!o){let t=jv(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,e=n.lineStartIndex+n.segment+1,s=new f(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),o=jv(s.x,s.y,i),a=o.signedDistanceFromCamera>0?o.point:kv(i.tileAnchorPoint,s,t,1,i),l=Rv(t.x,t.y,i,r),h=Rv(a.x,a.y,i,r),c=Pv(n.writingMode,l,h,u);if(c)return c}let t=Uv(p*l.getoffsetX(n.glyphStartIndex),d,m,o,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,c);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};e=[t]}for(let t of e)Rd(h,t.point,t.angle);return{}}function kv(t,e,i,r,n){let s=t.add(t.sub(e)._unit()),o=jv(s.x,s.y,n).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function $v(t,e,i){let r=e.projectionCache;if(r.projections[t])return r.projections[t];let n=new f(e.lineVertexArray.getx(t),e.lineVertexArray.gety(t)),s=jv(n.x,n.y,e);if(s.signedDistanceFromCamera>0)return r.projections[t]=s.point,r.anyProjectionOccluded||=s.isOccluded,s.point;let o=t-i.direction;return kv(0===i.distanceFromAnchor?e.tileAnchorPoint:new f(e.lineVertexArray.getx(o),e.lineVertexArray.gety(o)),n,i.previousVertex,i.absOffsetX-i.distanceFromAnchor+1,e)}function jv(t,e,i){let r,n=t+i.translation[0],s=e+i.translation[1];return i.pitchWithMap?(r=Fv(n,s,i.pitchedLabelPlaneMatrix,Av(i,n,s)),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(n,s,i.unwrappedTileID,Av(i,n,s)),r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height),r}function Rv(t,e,i,r){if(i.pitchWithMap){let n=[t,e,0,1];Y(n,n,r);let s=n[0]/n[3],o=n[1]/n[3];return i.transform.projectTileCoordinates(s,o,i.unwrappedTileID,Av(i,s,o)).point}return{x:t/i.width*2-1,y:1-e/i.height*2}}function Ov(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,Av(i,t,e))}function Bv(t,e,i){return t._unit()._perp()._mult(e*i)}function Lv(t,e,i,r,n,s,o,a,l){if(a.projectionCache.offsets[t])return a.projectionCache.offsets[t];let h=i.add(e);if(t+l.direction<r||t+l.direction>=n)return a.projectionCache.offsets[t]=h,h;let u=$v(t+l.direction,a,l),c=Bv(u.sub(i),o,l.direction),f=i.add(c),p=u.add(c);return a.projectionCache.offsets[t]=Nt(s,h,f,p)||h,a.projectionCache.offsets[t]}function Uv(t,e,i,r,n,s,o,a,l){let h=r?t-e:t+e,u=h>0?1:-1,c=0;r&&(u*=-1,c=Math.PI),u<0&&(c+=Math.PI);let f,p=u>0?s+n:s+n+1;a.projectionCache.cachedAnchorPoint?f=a.projectionCache.cachedAnchorPoint:(f=jv(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=f);let d,m,_,g=f,y=f,v=0,w=0,b=Math.abs(h),x=[];for(;v+w<=b;){if(p+=u,p<s||p>=o)return null;v+=w,y=g,m=d;let t={absOffsetX:b,direction:u,distanceFromAnchor:v,previousVertex:y};if(g=$v(p,a,t),0===i)x.push(y),_=g.sub(y);else{let e,r=g.sub(y);e=0===r.mag()?Bv($v(p+u,a,t).sub(g),i,u):Bv(r,i,u),m||=y.add(e),d=Lv(p,e,g,s,o,m,i,a,t),x.push(m),_=d.sub(m)}w=_.mag()}let D=_._mult((b-v)/w)._add(m||y),M=c+Math.atan2(g.y-y.y,g.x-y.x);return x.push(D),{point:D,angle:l?M:0,path:x}}const Nv=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Gv(t,e){for(let i=0;i<t;i++){let t=e.length;e.resize(t+4),e.float32.set(Nv,3*t)}}function qv(t,e,i){let r=e[0],n=e[1];return t[0]=i[0]*r+i[4]*n+i[12],t[1]=i[1]*r+i[5]*n+i[13],t[3]=i[3]*r+i[7]*n+i[15],t}var Vv=class{constructor(t,e=new wv(t.width+200,t.height+200,25),i=new wv(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+100,this.screenBottomBoundary=t.height+100,this.gridRightBoundary=t.width+200,this.gridBottomBoundary=t.height+200,this.perspectiveRatioCutoff=.6}placeCollisionBox(t,e,i,r,n,s,o,a,l,h,u,c,f=0,p=!0){let d,m=t.anchorPointX+a[0],_=t.anchorPointY+a[1],g=this.projectAndGetPerspectiveRatio(m,_,n,yv(h,m,_,f,p),c),y=i*g.perspectiveRatio;if(s||o)d=this._projectCollisionBox(t,y,r,n,s,o,a,g,h,u,c,f,p);else{let e=g.x+(u?u.x*y:0),i=g.y+(u?u.y*y:0);d={allPointsOccluded:!1,box:[e+t.x1*y,i+t.y1*y,e+t.x2*y,i+t.y2*y]}}let[v,w,b,x]=d.box,D=s?d.allPointsOccluded:g.isOccluded,M=D;return M||=g.perspectiveRatio<this.perspectiveRatioCutoff,M||=!this.isInsideGrid(v,w,b,x),M||"always"!==e&&this.grid.hitTest(v,w,b,x,e,l)?{box:[v,w,b,x],placeable:!1,offscreen:!1,occluded:D}:{box:[v,w,b,x],placeable:!0,offscreen:this.isOffscreen(v,w,b,x),occluded:D}}placeCollisionCircles(t,e,i,r,n,s,o,a,l,h,u,c,p,d){let m=[],_=new f(e.anchorX,e.anchorY),g=this.getPerspectiveRatio(_.x,_.y,s,d?.(_.x,_.y)),y=(l?n*this.transform.getPitchedTextCorrection(e.anchorX,e.anchorY,s)/g:n*g)/24,v={getElevation:d,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:l,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:this.transform,tileAnchorPoint:_,unwrappedTileID:s,width:this.transform.width,height:this.transform.height,translation:p},w=Tv(y,r,e.lineOffsetX*y,e.lineOffsetY*y,!1,e,!1,v),b=!1,x=!1,D=!0;if(w){let e=.5*u*g+c,i=new f(-100,-100),r=new f(this.screenRightBoundary,this.screenBottomBoundary),n=new gv,s=w.first,o=w.last,p=[];for(let t=s.path.length-1;t>=1;t--)p.push(s.path[t]);for(let t=1;t<o.path.length;t++)p.push(o.path[t]);let d=2.5*e;if(l){let t=this.projectPathToScreenSpace(p,v);p=t.some((t=>t.signedDistanceFromCamera<=0))?[]:t.map((t=>t.point))}let _=[];if(p.length>0){let t=p[0].clone(),e=p[0].clone();for(let i=1;i<p.length;i++)t.x=Math.min(t.x,p[i].x),t.y=Math.min(t.y,p[i].y),e.x=Math.max(e.x,p[i].x),e.y=Math.max(e.y,p[i].y);_=t.x>=i.x&&e.x<=r.x&&t.y>=i.y&&e.y<=r.y?[p]:e.x<i.x||t.x>r.x||e.y<i.y||t.y>r.y?[]:pd([p],i.x,i.y,r.x,r.y)}for(let i of _){n.reset(i,.25*e);let r=0;r=n.length<=.5*e?1:Math.ceil(n.paddedLength/d)+1;for(let i=0;i<r;i++){let s=i/Math.max(r-1,1),o=n.lerp(s),l=o.x+100,u=o.y+100;m.push(l,u,e,0);let c=l-e,f=u-e,p=l+e,d=u+e;if(D&&=this.isOffscreen(c,f,p,d),x||=this.isInsideGrid(c,f,p,d),"always"!==t&&this.grid.hitTestCircle(l,u,e,t,h)&&(b=!0,!a))return{circles:[],offscreen:!1,collisionDetected:b}}}}return{circles:!a&&b||!x||g<this.perspectiveRatioCutoff?[]:m,offscreen:D,collisionDetected:b}}projectPathToScreenSpace(t,e){return function(t){let e=0,i=0,r=0,n=0;for(let s=0;s<t.length;s++)t[s].isOccluded?(r=s+1,n=0):(n++,n>i&&(i=n,e=r));return t.slice(e,e+i)}(function(t,e){let i=xv;return function(t,e){let 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=>{let r=Fv(t.x,t.y,i,Av(e,t.x,t.y)),n=e.transform.projectTileCoordinates(r.point.x,r.point.y,e.unwrappedTileID,Av(e,r.point.x,r.point.y));return n.point.x=(.5*n.point.x+.5)*e.width,n.point.y=(.5*-n.point.y+.5)*e.height,n}))}(t,e))}queryRenderedSymbols(t){if(0===t.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};let e=[],i=new yc;for(let r of t){let t=new f(r.x+100,r.y+100);i.extend(t),e.push(t)}let{minX:r,minY:n,maxX:s,maxY:o}=i,a=this.grid.query(r,n,s,o).concat(this.ignoredGrid.query(r,n,s,o)),l={},h={};for(let t of a){let i=t.key;void 0===l[i.bucketInstanceId]&&(l[i.bucketInstanceId]={}),!l[i.bucketInstanceId][i.featureIndex]&&gh(e,[new f(t.x1,t.y1),new f(t.x2,t.y1),new f(t.x2,t.y2),new f(t.x1,t.y2)])&&(l[i.bucketInstanceId][i.featureIndex]=!0,void 0===h[i.bucketInstanceId]&&(h[i.bucketInstanceId]=[]),h[i.bucketInstanceId].push(i.featureIndex))}return h}insertCollisionBox(t,e,i,r,n,s){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:e},t[0],t[1],t[2],t[3])}insertCollisionCircles(t,e,i,r,n,s){let o=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:s,overlapMode:e};for(let e=0;e<t.length;e+=4)o.insertCircle(a,t[e],t[e+1],t[e+2])}projectAndGetPerspectiveRatio(t,e,i,r,n){if(n){let i;null==r?(i=[t,e,0,1],qv(i,i,n)):(i=[t,e,r,1],Y(i,i,n));let s=i[3];return{x:(i[0]/s+1)/2*this.transform.width+100,y:(-i[1]/s+1)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/s*.5,isOccluded:!1,signedDistanceFromCamera:s}}{let n=this.transform.projectTileCoordinates(t,e,i,r);return{x:(n.point.x+1)/2*this.transform.width+100,y:(1-n.point.y)/2*this.transform.height+100,perspectiveRatio:.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5,isOccluded:n.isOccluded,signedDistanceFromCamera:n.signedDistanceFromCamera}}}getPerspectiveRatio(t,e,i,r){let n=this.transform.projectTileCoordinates(t,e,i,r);return.5+this.transform.cameraToCenterDistance/n.signedDistanceFromCamera*.5}isOffscreen(t,e,i,r){return i<100||t>=this.screenRightBoundary||r<100||e>this.screenBottomBoundary}isInsideGrid(t,e,i,r){return i>=0&&t<this.gridRightBoundary&&r>=0&&e<this.gridBottomBoundary}getViewportMatrix(){let t=x([]);return E(t,t,[-100,-100,0]),t}_projectCollisionBox(t,e,i,r,n,s,o,a,l,h,u,c=0,p=!0){let d=1,m=0,_=0,g=1,y=t.anchorPointX+o[0],v=t.anchorPointY+o[1];if(s&&!n){let t=this.projectAndGetPerspectiveRatio(y+1,v,r,yv(l,y+1,v,c,p),u),e=t.x-a.x,i=Math.atan((t.y-a.y)/e)+(e<0?Math.PI:0),n=Math.sin(i),s=Math.cos(i);d=s,m=n,_=-n,g=s}else if(!s&&n){let t=Ev(this.transform);d=t.vecEast[0],m=t.vecEast[1],_=t.vecSouth[0],g=t.vecSouth[1]}let w=a.x,b=a.y,x=e;n&&(w=y,b=v,x=2**-(this.transform.zoom-i.overscaledZ),x*=this.transform.getPitchedTextCorrection(y,v,r),!h)&&(x*=At(.5+a.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),h&&(w+=d*h.x*x+_*h.y*x,b+=m*h.x*x+g*h.y*x);let D=t.x1*x,M=t.x2*x,E=(D+M)/2,A=t.y1*x,F=t.y2*x,S=(A+F)/2,C=[{offsetX:D,offsetY:A},{offsetX:E,offsetY:A},{offsetX:M,offsetY:A},{offsetX:M,offsetY:S},{offsetX:M,offsetY:F},{offsetX:E,offsetY:F},{offsetX:D,offsetY:F},{offsetX:D,offsetY:S}],z=[];for(let{offsetX:t,offsetY:e}of C)z.push(new f(w+d*t+_*e,b+m*t+g*e));let T=!1;if(n){let t=z.map((t=>this.projectAndGetPerspectiveRatio(t.x,t.y,r,yv(l,t.x,t.y,c,p),u)));T=t.some((t=>!t.isOccluded)),z=t.map((t=>new f(t.x,t.y)))}else T=!0;return{box:Dt(z),allPointsOccluded:!T}}},Zv=class{constructor(t,e,i,r){this.opacity=t?Math.max(0,Math.min(1,t.opacity+(t.placed?e:-e))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}},Wv=class{constructor(t,e,i,r,n){this.text=new Zv(t?t.text:null,e,i,n),this.icon=new Zv(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Hv=class{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}},Yv=class{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}},Xv=class{constructor(t){this.crossSourceCollisions=t,this.maxGroupID=0,this.collisionGroups={}}get(t){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[t]){let e=++this.maxGroupID;this.collisionGroups[t]={ID:e,predicate:t=>t.collisionGroupID===e}}return this.collisionGroups[t]}};function Jv(t,e,i,r,n){let{horizontalAlign:s,verticalAlign:o}=Up(t);return new f(-(s-.5)*e+r[0]*n,-(o-.5)*i+r[1]*n)}const Kv=Af.members.find((t=>"crossTileID"===t.name)).offset/4;var Qv=class{constructor(t,e,i,r,n){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new Vv(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Xv(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.lastOpacityInputs=new WeakMap,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(t){let e=this.terrain;if(e)return(i,r)=>e.getElevation(t,i,r)}getBucketParts(t,e,i,r){let n=i.getBucket(e),s=i.latestFeatureIndex;if(!n||!s||e.id!==n.layerIds[0])return;let o=i.collisionBoxArray,a=n.layers[0].layout,l=n.layers[0].paint,h=2**(this.transform.zoom-i.tileID.overscaledZ),u=i.tileSize/st,c=i.tileID.toUnwrapped(),f="map"===a.get("text-rotation-alignment"),p=ot(i,1,this.transform.zoom),d=pt(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=pt(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=Dv(f,this.transform,p);this.retainedQueryData[n.bucketInstanceId]=new Yv(n.bucketInstanceId,s,n.sourceLayerIndex,n.index,i.tileID);let g={bucket:n,layout:a,translationText:d,translationIcon:m,unwrappedTileID:c,pitchedLabelPlaneMatrix:_,scale:h,textPixelRatio:u,holdingForFade:i.holdingForSymbolFade(),collisionBoxArray:o,partiallyEvaluatedTextSize:nd(n.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(n.sourceID)};if(r)for(let e of n.sortKeyRanges){let{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:g})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:n.symbolInstances.length,parameters:g})}attemptAnchorPlacement(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y,v,w,b){let x=Ed[t.textAnchor],D=[t.textOffset0,t.textOffset1],M=Jv(x,i,r,D,n),E=this.collisionIndex.placeCollisionBox(e,c,a,l,h,o,s,m,u.predicate,y,M,v,w,b);if((!g||this.collisionIndex.placeCollisionBox(g,c,a,l,h,o,s,_,u.predicate,y,M,v,w,b).placeable)&&E.placeable){let t;if(this.prevPlacement?.variableOffsets[f.crossTileID]&&this.prevPlacement?.placements[f.crossTileID]?.text&&(t=this.prevPlacement.variableOffsets[f.crossTileID].anchor),0===f.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[f.crossTileID]={textOffset:D,width:i,height:r,anchor:x,textBoxScale:n,prevAnchor:t},this.markUsedJustification(p,x,f,d),p.allowVerticalPlacement&&(this.markUsedOrientation(p,d,f),this.placedOrientations[f.crossTileID]=d),{shift:M,placedGlyphBoxes:E}}}placeLayerBucketPart(t,e,i){let{bucket:r,layout:n,translationText:s,translationIcon:o,unwrappedTileID:a,pitchedLabelPlaneMatrix:l,textPixelRatio:h,holdingForFade:u,collisionBoxArray:c,partiallyEvaluatedTextSize:f,collisionGroup:p}=t.parameters,d=n.get("text-optional"),m=n.get("icon-optional"),_=kd(n,"text-overlap","text-allow-overlap"),g="always"===_,y=kd(n,"icon-overlap","icon-allow-overlap"),v="always"===y,w="map"===n.get("text-rotation-alignment"),b="map"===n.get("text-pitch-alignment"),x="none"!==n.get("icon-text-fit"),D="viewport-y"===n.get("symbol-z-order"),M="ground"===n.get("symbol-height-anchor"),E=g&&(v||!r.hasIconData()||m),A=v&&(g||!r.hasTextData()||d);!r.collisionArrays&&c&&r.deserializeCollisionBoxes(c);let F=this.retainedQueryData[r.bucketInstanceId].tileID,S=this._getTerrainElevationFunc(F),C=this.transform.getFastPathSimpleProjectionMatrix(F),z=(t,c,v)=>{if(e[t.crossTileID])return;if(u)return void(this.placements[t.crossTileID]=new Hv(!1,!1,!1));let D=t.heightOffset,z=!1,T=!1,P=!0,I=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},$={placeable:!1},j=null,R=null,O=null,B=0,L=0,U=0;c.textFeatureIndex?B=c.textFeatureIndex:t.useRuntimeCollisionCircles&&(B=t.featureIndex),c.verticalTextFeatureIndex&&(L=c.verticalTextFeatureIndex);let N=c.textBox;if(N){let e=e=>{let i=1;if(r.allowVerticalPlacement&&!e&&this.prevPlacement){let e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,i=e,this.markUsedOrientation(r,i,t))}return i},n=(e,i)=>{if(r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&c.verticalTextBox){for(let t of r.writingModes)if(2===t?(k=i(),$=k):k=e(),k?.placeable)break}else k=e()},l=t.textAnchorOffsetStartIndex,u=t.textAnchorOffsetEndIndex;if(u===l){let i=(e,i)=>{let n=this.collisionIndex.placeCollisionBox(e,_,h,F,a,b,w,s,p.predicate,S,void 0,C,D,M);return n?.placeable&&(this.markUsedOrientation(r,i,t),this.placedOrientations[t.crossTileID]=i),n};n((()=>i(N,1)),(()=>{let e=c.verticalTextBox;return r.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&e?i(e,2):{box:null,offscreen:null}})),e(k?.placeable)}else{let f=Ed[this.prevPlacement?.variableOffsets[t.crossTileID]?.anchor],d=(e,n,c)=>{let d=e.x2-e.x1,m=e.y2-e.y1,g=t.textBoxScale,v=x&&"never"===y?n:null,E=null,A="never"===_?1:2,T="never";f&&A++;for(let i=0;i<A;i++){for(let i=l;i<u;i++){let n=r.textAnchorOffsets.get(i);if(f&&n.textAnchor!==f)continue;let l=this.attemptAnchorPlacement(n,e,d,m,g,w,b,h,F,a,p,T,t,r,c,s,o,v,S,C,D,M);if(l&&(E=l.placedGlyphBoxes,E?.placeable))return z=!0,I=l.shift,E}f?f=null:T=_}return i&&!E&&(E={box:this.collisionIndex.placeCollisionBox(N,"always",h,F,a,b,w,s,p.predicate,S,void 0,C,D,M).box,offscreen:!1,placeable:!1,occluded:!1}),E};n((()=>d(N,c.iconBox,1)),(()=>{let e=c.verticalTextBox,i=k?.placeable;return r.allowVerticalPlacement&&!i&&t.numVerticalGlyphVertices>0&&e?d(e,c.verticalIconBox,2):{box:null,occluded:!0,offscreen:null}})),k&&(z=k.placeable,P=k.offscreen);let m=e(k?.placeable);if(!z&&this.prevPlacement){let e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(r,e.anchor,t,m))}}}if(j=k,z=j?.placeable,P=j?.offscreen,t.useRuntimeCollisionCircles&&t.centerJustifiedTextSymbolIndex>=0){let e=r.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex),o=rd(r.textSizeData,f,e),h=n.get("text-padding");R=this.collisionIndex.placeCollisionCircles(_,e,r.lineVertexArray,r.glyphOffsetArray,o,a,l,i,b,p.predicate,t.collisionCircleDiameter,h,s,S),R.circles.length&&R.collisionDetected&&!i&&Lt("Collisions detected, but collision boxes are not shown"),z=g||R.circles.length>0&&!R.collisionDetected,P&&=R.offscreen}if(c.iconFeatureIndex&&(U=c.iconFeatureIndex),c.iconBox){let t=t=>this.collisionIndex.placeCollisionBox(t,y,h,F,a,b,w,o,p.predicate,S,x&&I?I:void 0,C,D,M);$&&$.placeable&&c.verticalIconBox?(O=t(c.verticalIconBox),T=O.placeable):(O=t(c.iconBox),T=O.placeable),P&&=O.offscreen}let G=d||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,q=m||0===t.numIconVertices;G||q?q?G||(T&&=z):z=T&&z:T=z=T&&z;let V=T&&O.placeable;if(z&&j.placeable&&this.collisionIndex.insertCollisionBox(j.box,_,n.get("text-ignore-placement"),r.bucketInstanceId,$&&$.placeable&&L?L:B,p.ID),V&&this.collisionIndex.insertCollisionBox(O.box,y,n.get("icon-ignore-placement"),r.bucketInstanceId,U,p.ID),R&&z&&this.collisionIndex.insertCollisionCircles(R.circles,_,n.get("text-ignore-placement"),r.bucketInstanceId,B,p.ID),i&&this.storeCollisionData(r.bucketInstanceId,v,c,j,O,R),0===t.crossTileID)throw Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw Error("bucket.bucketInstanceId can't be 0");this.placements[t.crossTileID]=new Hv((z||E)&&!j?.occluded,(T||A)&&!O?.occluded,P||r.justReloaded),e[t.crossTileID]=!0};if(D){if(0!==t.symbolInstanceStart)throw Error("bucket.bucketInstanceId should be 0");let e=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let t=e.length-1;t>=0;--t){let i=e[t];z(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let e=t.symbolInstanceStart;e<t.symbolInstanceEnd;e++)z(r.symbolInstances.get(e),r.collisionArrays[e],e);r.justReloaded=!1}storeCollisionData(t,e,i,r,n,s){if(i.textBox||i.iconBox){let s,o;this.collisionBoxArrays.has(t)?s=this.collisionBoxArrays.get(t):(s=new Map,this.collisionBoxArrays.set(t,s)),s.has(e)?o=s.get(e):(o={text:null,icon:null},s.set(e,o)),i.textBox&&(o.text=r.box),i.iconBox&&(o.icon=n.box)}if(s){let e=this.collisionCircleArrays[t];void 0===e&&(e=this.collisionCircleArrays[t]=[]);for(let t=0;t<s.circles.length;t+=4)e.push(s.circles[t+0]-100),e.push(s.circles[t+1]-100),e.push(s.circles[t+2]),e.push(+!!s.collisionDetected)}}markUsedJustification(t,e,i,r){let n;n=2===r?i.verticalPlacedTextSymbolIndex:{left:i.leftJustifiedTextSymbolIndex,center:i.centerJustifiedTextSymbolIndex,right:i.rightJustifiedTextSymbolIndex}[Cd(e)];let s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex,i.verticalPlacedTextSymbolIndex];for(let e of s)e>=0&&(t.text.placedSymbolArray.get(e).crossTileID=n>=0&&e!==n?0:i.crossTileID)}markUsedOrientation(t,e,i){let r=1===e||3===e?e:0,n=2===e?e:0,s=[i.leftJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.rightJustifiedTextSymbolIndex];for(let e of s)t.text.placedSymbolArray.get(e).placedOrientation=r;i.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).placedOrientation=n)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;let e=this.prevPlacement,i=!1;this.prevZoomAdjustment=e?e.zoomAdjustment(this.transform.zoom):0;let r=e?e.symbolFadeChange(t):1,n=e?e.opacities:{},s=e?e.variableOffsets:{},o=e?e.placedOrientations:{};for(let t in this.placements){let e=this.placements[t],s=n[t];s?(this.opacities[t]=new Wv(s,r,e.text,e.icon),i||=e.text!==s.text.placed,i||=e.icon!==s.icon.placed):(this.opacities[t]=new Wv(null,r,e.text,e.icon,e.skipFade),i||=e.text||e.icon)}for(let t in n){let e=n[t];if(!this.opacities[t]){let n=new Wv(e,r,!1,!1);n.isHidden()||(this.opacities[t]=n,i||=e.text.placed,i||=e.icon.placed)}}for(let t in s)!this.variableOffsets[t]&&this.opacities[t]&&!this.opacities[t].isHidden()&&(this.variableOffsets[t]=s[t]);for(let 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 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){let i={};for(let r of e){let e=r.getBucket(t);if(!e||!r.latestFeatureIndex||t.id!==e.layerIds[0])continue;let{duplicates:n,changed:s}=this._markDuplicates(e,i),o=!!e.hasDebugData()||e.bucketInstanceId in this.collisionCircleArrays;(s||o)&&this.updateBucketOpacities(e,r.tileID,n,r.collisionBoxArray),e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder)}}_markDuplicates(t,e){let i=t.symbolInstances.length,r=this.lastOpacityInputs.get(t),n=!1;r||(r={crossTileIDs:Array(i).fill(0),duplicates:Array(i).fill(!1)},this.lastOpacityInputs.set(t,r),n=!0);let{crossTileIDs:s,duplicates:o}=r,a=t.symbolInstances.uint32,l=t.symbolInstances.bytesPerElement/4;for(let t=0;t<i;t++){let i=a[t*l+Kv],r=!!e[i];e[i]=!0,(s[t]!==i||o[t]!==r)&&(s[t]=i,o[t]=r,n=!0)}return{duplicates:o,changed:n}}updateBucketOpacities(t,e,i,r){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();let n=t.layers[0],s=n.layout,o=new Wv(null,0,!1,!1,!0),a=s.get("text-allow-overlap"),l=s.get("icon-allow-overlap"),h=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),u="map"===s.get("text-rotation-alignment"),c="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),d=new Wv(null,0,a&&(l||!t.hasIconData()||s.get("icon-optional")),l&&(a||!t.hasTextData()||s.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);let m=(t,e,i)=>{for(let r=0;r<e/4;r++)t.opacityVertexArray.emplaceBack(i);t.hasVisibleVertices||=0!==i},_=this.collisionBoxArrays.get(t.bucketInstanceId);for(let e=0;e<t.symbolInstances.length;e++){let r=t.symbolInstances.get(e),{numHorizontalGlyphVertices:n,numVerticalGlyphVertices:s,crossTileID:a}=r,l=this.opacities[a];i[e]?l=o:l||(l=d,this.opacities[a]=l);let g=r.numIconVertices>0,y=this.placedOrientations[r.crossTileID],v=2===y,w=1===y||3===y;if(n>0||s>0){let e=sw(l.text);m(t.text,n,v?0:e),m(t.text,s,w?0:e);let i=l.text.isHidden(),o=[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex];for(let e of o)e>=0&&(t.text.placedSymbolArray.get(e).hidden=i||v?1:0);r.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||w?1:0);let a=this.variableOffsets[r.crossTileID];a&&this.markUsedJustification(t,a.anchor,r,y);let h=this.placedOrientations[r.crossTileID];h&&(this.markUsedJustification(t,"left",r,h),this.markUsedOrientation(t,h,r))}if(g){let e=sw(l.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(t.icon,r.numIconVertices,i?e:0),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=l.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,r.numVerticalIconVertices,i?0:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=l.icon.isHidden())}let b=_?.has(e)?_.get(e):{text:null,icon:null};if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){let i=t.collisionArrays[e];if(i){let e=new f(0,0);if(i.textBox||i.verticalTextBox){let r=!0;if(h){let t=this.variableOffsets[a];t?(e=Jv(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),u&&e._rotate(c?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(i.textBox||i.verticalTextBox){let n;i.textBox&&(n=v),i.verticalTextBox&&(n=w),tw(t.textCollisionBox.collisionVertexArray,l.text.placed,!r||n,b.text,e.x,e.y)}}if(i.iconBox||i.verticalIconBox){let r,n=!(w||!i.verticalIconBox);i.iconBox&&(r=n),i.verticalIconBox&&(r=!n),tw(t.iconCollisionBox.collisionVertexArray,l.icon.placed,r,b.icon,p?e.x:0,p?e.y:0)}}}}if(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 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 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){let i=this.zoomAtLastRecencyCheck===e?1-this.zoomAdjustment(e):1;return this.zoomAtLastRecencyCheck=e,this.commitTime+this.fadeDuration*i>t}setStale(){this.stale=!0}};function tw(t,e,i,r,n,s){(!r||0===r.length)&&(r=[0,0,0,0]);let o=r[0]-100,a=r[1]-100,l=r[2]-100,h=r[3]-100;t.emplaceBack(+!!e,+!!i,n||0,s||0,o,a),t.emplaceBack(+!!e,+!!i,n||0,s||0,l,a),t.emplaceBack(+!!e,+!!i,n||0,s||0,l,h),t.emplaceBack(+!!e,+!!i,n||0,s||0,o,h)}const ew=2**25,iw=2**24,rw=2**17,nw=65536;function sw(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return ow;let e=+!!t.placed,i=Math.floor(127*t.opacity);return i*ew+e*iw+i*rw+e*nw+512*i+256*e+2*i+e}const ow=4294967295;var aw=class{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,r,n){let s=this._bucketParts;for(;this._currentTileIndex<t.length;)if(e.getBucketParts(s,r,t[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,n())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,s.sort(((t,e)=>t.sortKey-e.sortKey)));this._currentPartIndex<s.length;)if(e.placeLayerBucketPart(s[this._currentPartIndex],this._seenCrossTileIDs,i),this._currentPartIndex++,n())return!0;return!1}},lw=class{constructor(t,e,i,r,n,s,o,a){this.placement=new Qv(t,e,s,o,a),this._currentPlacementIndex=i.length-1,this._forceFullPlacement=r,this._showCollisionBoxes=n,this._done=!1}isDone(){return this._done}continuePlacement(t,e,i){let r=de(),n=()=>!this._forceFullPlacement&&de()-r>2;for(;this._currentPlacementIndex>=0;){let r=e[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(Zd(r)&&r.layout&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||=new aw(r),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}};const hw=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],uw=new Uint32Array(96);var cw=class t{static from(e){if(!e||void 0===e.byteLength||e.buffer)throw Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");let[i,r]=new Uint8Array(e,0,2);if(219!==i)throw Error("Data does not appear to be in a KDBush format.");let n=r>>4;if(1!==n)throw Error(`Got v${n} data when expected v1.`);let s=hw[15&r];if(!s)throw Error("Unrecognized array type.");let[o]=new Uint16Array(e,2,1),[a]=new Uint32Array(e,4,1);return new t(a,o,s,void 0,e)}constructor(t,e=64,i=Float64Array,r=ArrayBuffer,n){if(isNaN(t)||t<0)throw Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let s=hw.indexOf(this.ArrayType),o=2*t*this.ArrayType.BYTES_PER_ELEMENT,a=t*this.IndexArrayType.BYTES_PER_ELEMENT,l=(8-a%8)%8;if(s<0)throw Error(`Unexpected typed array class: ${i}.`);if(n)this.data=n,this.ids=new this.IndexArrayType(n,8,t),this.coords=new i(n,8+a+l,2*t),this._pos=2*t,this._finished=!0;else{let n=this.data=new r(8+o+a+l);this.ids=new this.IndexArrayType(n,8,t),this.coords=new i(n,8+a+l,2*t),this._pos=0,this._finished=!1,new Uint8Array(n,0,2).set([219,16+s]),new Uint16Array(n,2,1)[0]=e,new Uint32Array(n,4,1)[0]=t}}add(t,e){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=e,i}finish(){let t=this._pos>>1;if(t!==this.numItems)throw Error(`Added ${t} items when expected ${this.numItems}.`);return fw(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,e,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;uw[0]=0,uw[1]=n.length-1,uw[2]=0;let a=3,l=[];for(;a>0;){let h=uw[--a],u=uw[--a],c=uw[--a];if(u-c<=o){for(let o=c;o<=u;o++){let a=s[2*o],h=s[2*o+1];a>=t&&a<=i&&h>=e&&h<=r&&l.push(n[o])}continue}let f=c+u>>1,p=s[2*f],d=s[2*f+1];p>=t&&p<=i&&d>=e&&d<=r&&l.push(n[f]),(0===h?t<=p:e<=d)&&(uw[a++]=c,uw[a++]=f-1,uw[a++]=1-h),(0===h?i>=p:r>=d)&&(uw[a++]=f+1,uw[a++]=u,uw[a++]=1-h)}return l}within(t,e,i){let r=[];return this.withinInto(t,e,i,r),r}withinInto(t,e,i,r){if(!this._finished)throw Error("Data not yet indexed - call index.finish().");let{ids:n,coords:s,nodeSize:o}=this;uw[0]=0,uw[1]=n.length-1,uw[2]=0;let a=3,l=0,h=i*i;for(;a>0;){let u=uw[--a],c=uw[--a],f=uw[--a];if(c-f<=o){for(let i=f;i<=c;i++)_w(s[2*i],s[2*i+1],t,e)<=h&&(r[l++]=n[i]);continue}let p=f+c>>1,d=s[2*p],m=s[2*p+1];_w(d,m,t,e)<=h&&(r[l++]=n[p]),(0===u?t-i<=d:e-i<=m)&&(uw[a++]=f,uw[a++]=p-1,uw[a++]=1-u),(0===u?t+i>=d:e+i>=m)&&(uw[a++]=p+1,uw[a++]=c,uw[a++]=1-u)}return l}};function fw(t,e,i,r,n,s){if(n-r<=i)return;let o=r+n>>1;pw(t,e,o,r,n,s),fw(t,e,i,r,o-1,1-s),fw(t,e,i,o+1,n,1-s)}function pw(t,e,i,r,n,s){for(;n>r;){if(n-r>600){let o=n-r+1,a=i-r+1,l=Math.log(o),h=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*h*(o-h)/o)*(a-o/2<0?-1:1);pw(t,e,i,Math.max(r,Math.floor(i-a*h/o+u)),Math.min(n,Math.floor(i+(o-a)*h/o+u)),s)}let o=e[2*i+s],a=r,l=n;for(dw(t,e,r,i),e[2*n+s]>o&&dw(t,e,r,n);a<l;){for(dw(t,e,a,l),a++,l--;e[2*a+s]<o;)a++;for(;e[2*l+s]>o;)l--}e[2*r+s]===o?dw(t,e,r,l):(l++,dw(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function dw(t,e,i,r){mw(t,i,r),mw(e,2*i,2*r),mw(e,2*i+1,2*r+1)}function mw(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function _w(t,e,i,r){let n=t-i,s=e-r;return n*n+s*s}const gw=.03125;var yw=class{constructor(t,e,i){this.tileID=t,this.bucketInstanceId=i,this._symbolsByKey={};let r=new Map;for(let t=0;t<e.length;t++){let i=e.get(t),n=i.key,s=r.get(n);s?s.push(i):r.set(n,[i])}for(let[t,e]of r){let i={positions:e.map((t=>({x:Math.floor(t.anchorX*gw),y:Math.floor(t.anchorY*gw)}))),crossTileIDs:e.map((t=>t.crossTileID))};if(i.positions.length>128){let t=new cw(i.positions.length,16,Uint16Array);for(let{x:e,y:r}of i.positions)t.add(e,r);t.finish(),delete i.positions,i.index=t}this._symbolsByKey[t]=i}}getScaledCoordinates(t,e){let{x:i,y:r,z:n}=this.tileID.canonical,{x:s,y:o,z:a}=e.canonical,l=gw/2**(a-n),h=(o*st+t.anchorY)*l,u=r*st*gw;return{x:Math.floor((s*st+t.anchorX)*l-i*st*gw),y:Math.floor(h-u)}}findMatches(t,e,i){let r=this.tileID.canonical.z<e.canonical.z?1:2**(this.tileID.canonical.z-e.canonical.z);for(let n=0;n<t.length;n++){let s=t.get(n);if(s.crossTileID)continue;let o=this._symbolsByKey[s.key];if(!o)continue;let a=this.getScaledCoordinates(s,e);o.index?this.findMatchesForIndexedEntry(o,s,a,r,i):o.positions&&this.findMatchesForNonIndexedEntry(o,s,a,r,i)}}findMatchesForIndexedEntry(t,e,i,r,n){let s=t.index.range(i.x-r,i.y-r,i.x+r,i.y+r),o=1/0;for(let e of s)e<o&&!n[t.crossTileIDs[e]]&&(o=e);if(o!==1/0){let i=t.crossTileIDs[o];n[i]=!0,e.crossTileID=i}}findMatchesForNonIndexedEntry(t,e,i,r,n){for(let s=0;s<t.positions.length;s++){let o=t.positions[s],a=t.crossTileIDs[s];if(Math.abs(o.x-i.x)<=r&&Math.abs(o.y-i.y)<=r&&!n[a]){n[a]=!0,e.crossTileID=a;break}}}getCrossTileIDsLists(){return Object.values(this._symbolsByKey).map((({crossTileIDs:t})=>t))}},vw=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},ww=class{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){let e=Math.round((t-this.lng)/360);if(0!==e)for(let t in this.indexes){let i=this.indexes[t],r={};for(let t in i){let n=i[t];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+e),r[n.tileID.key]=n}this.indexes[t]=r}this.lng=t}addBucket(t,e,i){if(this.indexes[t.overscaledZ]?.[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;this.usedCrossTileIDs[t.overscaledZ]||={};let r=this.usedCrossTileIDs[t.overscaledZ];for(let i in this.indexes){let n=this.indexes[i];if(Number(i)>t.overscaledZ)for(let i in n){let s=n[i];s.tileID.isChildOf(t)&&s.findMatches(e.symbolInstances,t,r)}else{let s=n[t.scaledTo(Number(i)).key];s&&s.findMatches(e.symbolInstances,t,r)}}for(let t=0;t<e.symbolInstances.length;t++){let n=e.symbolInstances.get(t);n.crossTileID||(n.crossTileID=i.generate(),r[n.crossTileID]=!0)}return void 0===this.indexes[t.overscaledZ]&&(this.indexes[t.overscaledZ]={}),this.indexes[t.overscaledZ][t.key]=new yw(t,e.symbolInstances,e.bucketInstanceId),!0}removeBucketCrossTileIDs(t,e){for(let i of e.getCrossTileIDsLists())for(let e of i)delete this.usedCrossTileIDs[t][e]}removeStaleBuckets(t){let e=!1;for(let i in this.indexes){let r=this.indexes[i];for(let n in r)t[r[n].bucketInstanceId]||(this.removeBucketCrossTileIDs(i,r[n]),delete r[n],e=!0)}return e}},bw=class{constructor(){this.layerIndexes={},this.crossTileIDs=new vw,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new ww);let n=!1,s={};r.handleWrapJump(i);for(let i of e){let e=i.getBucket(t);t.id===e?.layerIds[0]&&(e.bucketInstanceId||=(this.maxBucketInstanceId+=1,this.maxBucketInstanceId),r.addBucket(i.tileID,e,this.crossTileIDs)&&(n=!0),s[e.bucketInstanceId]=!0)}return r.removeStaleBuckets(s)&&(n=!0),n}pruneUnusedLayers(t){let e={};for(let i of t)e[i]=!0;for(let t in this.layerIndexes)e[t]||delete this.layerIndexes[t]}},xw="void main() {fragColor=vec4(1.0);}";const Dw={prelude:Mw("#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;layout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};","#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 uint packedOpacity) {return vec2(float(packedOpacity >> 1u)/127.0,float(packedOpacity & 1u));}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 highp sampler2D u_depth;layout(std140) uniform TerrainUBO {highp mat4 u_terrain_matrix;highp vec4 u_terrain_unpack;highp float u_terrain_dim;highp float u_terrain_exaggeration;};\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(ivec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texelFetch(u_terrain,pos,0)*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.5;vec2 f=fract(coord);ivec2 c=ivec2(floor(coord));ivec2 hi=textureSize(u_terrain,0)-1;float tl=ele(clamp(c,ivec2(0),hi));float tr=ele(clamp(c+ivec2(1,0),ivec2(0),hi));float bl=ele(clamp(c+ivec2(0,1),ivec2(0),hi));float br=ele(clamp(c+ivec2(1,1),ivec2(0),hi));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;\n#define PROJECTION_UBO\nlayout(std140) uniform ProjectionUBO {highp mat4 u_projection_matrix;highp mat4 u_projection_fallback_matrix;highp vec4 u_projection_tile_mercator_coords;highp vec4 u_projection_clipping_plane;highp float u_projection_transition;highp int u_projection_clip_antimeridian;};layout(std140) uniform FrameUBO {highp vec2 u_units_to_pixels;highp vec2 u_world_size;highp float u_camera_to_center_distance;highp float u_symbol_fade_change;highp float u_aspect_ratio;highp float u_device_pixel_ratio;highp vec2 u_viewport_size;highp vec2 u_pixel_extrude_scale;highp float u_pitch;};"),projectionMercator:Mw("\nvoid clipAntimeridian() {}","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:Mw("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}","#define GLOBE_RADIUS 6371008.8\n#ifndef PROJECTION_UBO\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;\n#endif\nout highp float v_projection_tile_x;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 t=exp(PI-(mercator_pos_y*PI*2.0));return (2.0*t)/(t*t+1.0);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY);if (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;float spherical_x=mercator_pos.x*PI*2.0+PI;float t=exp(PI-(mercator_pos.y*PI*2.0));float t2=t*t;float denom=t2+1.0;float sin_sy=(t2-1.0)/denom;float cos_sy=(2.0*t)/denom;vec3 pos=vec3(sin(spherical_x)*cos_sy,sin_sy,cos(spherical_x)*cos_sy\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) {v_projection_tile_x=posInTile.x;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) {v_projection_tile_x=posInTile.x;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:Mw("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}","layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),backgroundPattern:Mw("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;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos,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:Mw("in vec3 v_data;flat in float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: 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 vec2 u_translate;layout(location=0) in ivec2 a_pos;out vec3 v_data;flat out float v_visibility;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define mediump float radius\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 stroke_color\n#pragma maplibre: define mediump float stroke_width\n#pragma maplibre: define lowp float stroke_opacity\nvoid main(void) {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump float radius\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 stroke_color\n#pragma maplibre: initialize mediump float stroke_width\n#pragma maplibre: initialize lowp float stroke_opacity\nivec2 pos_raw=a_pos+32768;vec2 extrude=vec2(pos_raw & 7)/7.0*2.0-1.0;vec2 circle_center=vec2(pos_raw >> 3)+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:Mw(xw,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),heatmap:Mw("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma maplibre: 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;layout(location=0) in ivec2 a_pos;out vec2 v_extrude;\n#pragma maplibre: define highp float weight\n#pragma maplibre: 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 maplibre: initialize highp float weight\n#pragma maplibre: initialize mediump float radius\nivec2 pos_raw=a_pos+32768;vec2 unscaled_extrude=vec2(pos_raw & 7)/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=vec2(pos_raw >> 3);\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:Mw("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;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Mw("flat in float v_placed;flat 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;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;flat out float v_placed;flat 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:Mw("flat in float v_radius;in vec2 v_extrude;flat 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;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;flat out float v_radius;out vec2 v_extrude;flat 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:Mw("#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) {vec4 data=texelFetch(u_elevation_stops,ivec2(stop,0),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;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.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:Mw("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);}","layout(location=0) 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:Mw(xw,"layout(location=0) 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:Mw("#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;layout(location=0) in vec2 a_pos;\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Mw("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: 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_fill_translate;layout(location=0) in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define highp vec4 outline_color\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 outline_color\n#pragma maplibre: initialize lowp float opacity\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Mw("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;uniform bool u_sdf_pattern;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 maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: 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);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*alpha*opacity;} else {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_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;layout(location=0) 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 maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 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_size;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Mw("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform bool u_sdf_pattern;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: 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);if (u_sdf_pattern) {highp float sdf_edge=(256.0-64.0)/256.0;highp float sdf_gamma_a=max(fwidth(color1.a)*0.5,1.0/255.0/16.0);highp float sdf_gamma_b=max(fwidth(color2.a)*0.5,1.0/255.0/16.0);float sdf_alpha_a=smoothstep(sdf_edge-sdf_gamma_a,sdf_edge+sdf_gamma_a,color1.a);float sdf_alpha_b=smoothstep(sdf_edge-sdf_gamma_b,sdf_edge+sdf_gamma_b,color2.a);fragColor=mix(color*sdf_alpha_a,color*sdf_alpha_b,u_fade)*opacity;} else {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;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}vec2 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:Mw("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;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma maplibre: define highp float base\n#pragma maplibre: define highp float height\n#pragma maplibre: define highp vec4 color\nvoid main() {\n#pragma maplibre: initialize highp float base\n#pragma maplibre: initialize highp float height\n#pragma maplibre: initialize highp vec4 color\nvec3 normal=vec3(a_normal_ed.xyz);float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);\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=float(a_normal_ed.x & 1);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.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_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:Mw("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 maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: 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;layout(location=0) in vec2 a_pos;layout(location=1) in ivec4 a_normal_ed;\n#ifdef TERRAIN3D\nlayout(location=2) in 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 maplibre: define lowp float base\n#pragma maplibre: define lowp float height\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float base\n#pragma maplibre: initialize lowp float height\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: 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=vec3(a_normal_ed.xyz);float edgedistance=float(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;float gradient_base=max(0.0,base);float gradient_height=max(0.0,height);\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=float(a_normal_ed.x & 1);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=a_normal_ed.x==1 && a_normal_ed.y==0 && a_normal_ed.z==16384\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.z==0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+gradient_base)*pow(gradient_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:Mw("#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(ivec2 texel) {vec4 data=texelFetch(u_image,texel,0)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {ivec2 pos=ivec2(gl_FragCoord.xy)+ivec2(1);float tileSize=u_dimension.x-4.0;float a=getElevation(pos+ivec2(-1,-1));float b=getElevation(pos+ivec2(0,-1));float c=getElevation(pos+ivec2(1,-1));float d=getElevation(pos+ivec2(-1,0));float e=getElevation(pos);float f=getElevation(pos+ivec2(1,0));float g=getElevation(pos+ivec2(-1,1));float h=getElevation(pos+ivec2(0,1));float i=getElevation(pos+ivec2(1,1));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+128.0/255.0,deriv.y/8.0+128.0/255.0,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;layout(location=0) in vec2 a_pos;layout(location=1) 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:Mw("uniform sampler2D u_image;in highp 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() {highp vec2 size=vec2(textureSize(u_image,0));highp vec2 texturePos=(v_pos*(size-2.0)+1.0)/size;vec4 pixel=texture(u_image,texturePos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=(pixel.rg-128.0/255.0)*8.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;layout(location=0) 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:Mw("flat in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);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\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat 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 maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);v_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*2.0;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:Mw("uniform sampler2D u_image;flat 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 maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();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);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\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_image_height;out vec2 v_normal;flat 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 maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);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=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:Mw("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;flat in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;flat in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\nclipAntimeridian();vec2 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\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;out vec2 v_normal;flat out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;flat out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define lowp vec4 pattern_from\n#pragma maplibre: define lowp vec4 pattern_to\n#pragma maplibre: define lowp float pixel_ratio_from\n#pragma maplibre: define lowp float pixel_ratio_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 pattern_from\n#pragma maplibre: initialize mediump vec4 pattern_to\n#pragma maplibre: initialize lowp float pixel_ratio_from\n#pragma maplibre: initialize lowp float pixel_ratio_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:Mw("uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;flat 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 maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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 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\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;uniform vec2 u_translation;uniform mediump float u_ratio;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;flat 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 maplibre: define highp vec4 color\n#pragma maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize highp vec4 color\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*LINE_DISTANCE_SCALE;vec2 pos=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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:Mw("uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;flat 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 maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nclipAntimeridian();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);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\nlayout(location=0) in ivec2 a_pos_normal;layout(location=1) in uvec4 a_data;layout(location=2) in vec2 a_offset_normal;layout(location=3) in float a_uv_x;layout(location=4) in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;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;flat 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 maplibre: define lowp float blur\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define mediump float gapwidth\n#pragma maplibre: define lowp float offset\n#pragma maplibre: define mediump float width\n#pragma maplibre: define lowp float floorwidth\n#pragma maplibre: define mediump vec4 dasharray_from\n#pragma maplibre: define mediump vec4 dasharray_to\nvoid main() {\n#pragma maplibre: initialize lowp float blur\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize mediump float gapwidth\n#pragma maplibre: initialize lowp float offset\n#pragma maplibre: initialize mediump float width\n#pragma maplibre: initialize lowp float floorwidth\n#pragma maplibre: initialize mediump vec4 dasharray_from\n#pragma maplibre: initialize mediump vec4 dasharray_to\nif (opacity < 0.01) {gl_Position=vec4(-2.0,-2.0,-2.0,1.0);return;}float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=vec2(ivec2(a_data.xy)-128);float a_linesofar=float((a_data.z >> 2u)+a_data.w*64u)*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=vec2(a_pos_normal >> 1);mediump vec2 normal=vec2(a_pos_normal & 1);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 vec2 offset2=offset*a_offset_normal*scale*normal.y;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);}"),layerOpacity:Mw("uniform sampler2D u_image;uniform float u_opacity;in vec2 v_pos;void main() {fragColor=texture(u_image,v_pos)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:Mw("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec3 v_pos0;in vec3 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.xy/v_pos0.z);vec4 color1=texture(u_image1,v_pos1.xy/v_pos1.z);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 vec3 u_image_warp;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;layout(location=0) in vec2 a_pos;out vec3 v_pos0;out vec3 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 topLeft=u_coords_top.xy;vec2 topRight=u_coords_top.zw;vec2 bottomLeft=u_coords_bottom.xy;vec2 bottomRight=u_coords_bottom.zw;vec2 bilinearPos=mix(mix(topLeft,topRight,fractionalPos.x),mix(bottomLeft,bottomRight,fractionalPos.x),fractionalPos.y);float denominator=dot(u_image_warp.xy,fractionalPos)+1.0;vec2 acrossTop=topRight-topLeft+u_image_warp.x*topRight;vec2 downLeft=bottomLeft-topLeft+u_image_warp.y*bottomLeft;vec2 projectivePos=(acrossTop*fractionalPos.x+downLeft*fractionalPos.y+topLeft)/denominator;vec2 position=mix(projectivePos,bilinearPos,u_image_warp.z);gl_Position=projectTile(position,position);vec2 texturePos=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {texturePos.y=0.0;}if (a_pos.y > 32766.5) {texturePos.y=1.0;}\n#endif\nfloat perspectiveRatio=mix(1.0/denominator,1.0,u_image_warp.z);v_pos0=vec3(texturePos*perspectiveRatio,perspectiveRatio);vec2 parentPos=(texturePos*u_scale_parent)+u_tl_parent;v_pos1=vec3(parentPos*perspectiveRatio,perspectiveRatio);}"),symbolIcon:Mw("uniform sampler2D u_texture;in vec2 v_tex;flat 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}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;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;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_tex;flat out float v_total_opacity;\n#pragma maplibre: define lowp float opacity\nvoid main() {\n#pragma maplibre: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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);if (!u_is_offset) {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:Mw("#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 bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: 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}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec4 a_pixeloffset;layout(location=3) in vec3 a_projected_pos;layout(location=4) in uint a_fade_opacity;layout(location=5) in float a_height_offset;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 bool u_rotate_symbol;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec2 v_data0;out vec3 v_data1;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);vec2 a_pxoffset=a_pixeloffset.xy/16.0;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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);if (!u_is_offset) {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:Mw("#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;in vec4 v_data0;in vec3 v_data1;flat in float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nfloat total_opacity=v_data1[2];if (v_is_sdf==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}","layout(location=0) in vec4 a_pos_offset;layout(location=1) in uvec4 a_data;layout(location=2) in vec3 a_projected_pos;layout(location=3) in uint a_fade_opacity;layout(location=4) in float a_height_offset;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_rotate_symbol;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;uniform bool u_is_offset;uniform bool u_height_anchor_ground;out vec4 v_data0;out vec3 v_data1;flat out float v_is_sdf;\n#pragma maplibre: define highp vec4 fill_color\n#pragma maplibre: define highp vec4 halo_color\n#pragma maplibre: define lowp float opacity\n#pragma maplibre: define lowp float halo_width\n#pragma maplibre: define lowp float halo_blur\nvoid main() {\n#pragma maplibre: initialize highp vec4 fill_color\n#pragma maplibre: initialize highp vec4 halo_color\n#pragma maplibre: initialize lowp float opacity\n#pragma maplibre: initialize lowp float halo_width\n#pragma maplibre: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=vec2(a_data.xy);vec2 a_size=vec2(a_data.zw);float a_size_min=float(a_data.z >> 1u);float is_sdf=float(a_data.z & 1u);float ele=a_height_offset+(u_height_anchor_ground ? get_elevation(a_pos) : 0.0);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_symbol_fade_change :-u_symbol_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);if (!u_is_offset) {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=vec3(gamma_scale,size,total_opacity);v_is_sdf=is_sdf;}"),terrain:Mw("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;}}","layout(location=0) 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:Mw("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);}","layout(location=0) 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;}"),terrainHeight:Mw("in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}","layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}"),atmosphere:Mw("#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;}","layout(location=0) 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:Mw("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;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;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;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}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(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function Mw(t,e){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=e.match(/in ([\w]+) ([\w]+)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=s?s.concat(n):n,a=r?r.length:0,l={};return t=t.replace(i,((t,e,i,r,n)=>(l[n]=!0,"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`))),e=e.replace(i,((t,e,i,r,n)=>{let s="float"===r?"vec2":"vec4",o=n.match(/color/)?"color":s;return l[n]?"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nlayout(location = ${a++}) in ${i} ${s} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===e?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nlayout(location = ${a++}) in ${i} ${s} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===o?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${o}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`})),{fragmentSource:t,vertexSource:e,staticAttributes:r,staticUniforms:o}}const Ew="#define PROJECTION_MERCATOR",Aw="mercator";var Fw=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Aw}get shaderDefine(){return Ew}get shaderPreludeCode(){return Dw.projectionMercator}get vertexShaderPreludeCode(){return Dw.projectionMercator.vertexSource}get subdivisionGranularity(){return tc.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(t,e,i,r,n){if(this._cachedMesh)return this._cachedMesh;let s=new hl;s.emplaceBack(0,0),s.emplaceBack(st,0),s.emplaceBack(0,st),s.emplaceBack(st,st);let o=t.createVertexBuffer(s,d_.members),a=zl.simpleSegment(0,0,4,2),l=new Al;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let h=t.createIndexBuffer(l);return this._cachedMesh=new p_(o,h,a),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Sw=class t{constructor(t=0,e=0,i=0,r=0){if(isNaN(t)||t<0||isNaN(e)||e<0||isNaN(i)||i<0||isNaN(r)||r<0)throw 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=r}interpolate(t,e,i){return null!=e.top&&null!=t.top&&(this.top=Sr.number(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=Sr.number(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=Sr.number(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=Sr.number(t.right,e.right,i)),this}getCenter(t,e){return new f(At((this.left+t-this.right)/2,0,t),At((this.top+e-this.bottom)/2,0,e))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new t(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function Cw(t,e){if(!t.renderWorldCopies||t.lngRange)return;let i=e.lng-t.center.lng;e.lng+=i>180?-360:i<-180?360:0}function zw(t){return Math.max(0,Math.floor(t))}var Tw=class{constructor(t,e){this.applyConstrain=(t,e)=>null===this._constrainOverride?this._callbacks.defaultConstrain(t,e):this._constrainOverride(t,e),this._callbacks=t,this._tileSize=512,this._renderWorldCopies=void 0===e?.renderWorldCopies||!!e?.renderWorldCopies,this._minZoom=e?.minZoom||0,this._maxZoom=e?.maxZoom||22,this._minPitch=null==e?.minPitch?0:e?.minPitch,this._maxPitch=null==e?.maxPitch?60:e?.maxPitch,this._constrainOverride=e?.constrainOverride??null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new Cc(0,0),this._elevation=0,this._zoom=0,this._tileZoom=zw(this._zoom),this._scale=Pt(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Sw,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,e){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=zw(this._zoom),this._scale=Pt(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 Sw(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=t.autoCalculateNearFarZ,e&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){t!==this._minElevationForCurrentTile&&(this._minElevationForCurrentTile=t,this._calcMatrices())}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){if(this._minZoom===t)return;this._minZoom=t;let e=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=e}get maxZoom(){return this._maxZoom}setMaxZoom(t){if(this._maxZoom===t)return;this._maxZoom=t;let e=this._unmodified;this.setZoom(this.applyConstrain(this._center,this.zoom).zoom),this._unmodified=e}get minPitch(){return this._minPitch}setMinPitch(t){if(this._minPitch===t)return;this._minPitch=t;let e=this._unmodified;this.setPitch(Math.max(this.pitch,t)),this._unmodified=e}get maxPitch(){return this._maxPitch}setMaxPitch(t){if(this._maxPitch===t)return;this._maxPitch=t;let e=this._unmodified;this.setPitch(Math.min(this.pitch,t)),this._unmodified=e}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 f(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){let e=Ft(t,-180,180)*Math.PI/180;this._bearingInRadians!==e&&(this._unmodified=!1,this._bearingInRadians=e,this._calcMatrices(),this._rotationMatrix=y(),function(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=Math.sin(i),l=Math.cos(i);t[0]=r*l+s*a,t[1]=n*l+o*a,t[2]=r*-a+s*l,t[3]=n*-a+o*l}(this._rotationMatrix,this._rotationMatrix,-this._bearingInRadians))}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(t){let e=At(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==e&&(this._unmodified=!1,this._pitchInRadians=e,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(t){let e=t/180*Math.PI;this._rollInRadians!==e&&(this._unmodified=!1,this._rollInRadians=e,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return Yt(this._fovInRadians)}setFov(t){t=At(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=Ht(t),this._calcMatrices())}get zoom(){return this._zoom}setZoom(t){let e=this.applyConstrain(this._center,t).zoom;this._zoom!==e&&(this._unmodified=!1,this._zoom=e,this._tileZoom=Math.max(0,Math.floor(e)),this._scale=Pt(e),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.constrainInternal(),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(){return 2!==this._latRange?.length||2!==this._lngRange?.length?null:new Um([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=[-85.051129,Qt])}getCameraQueryGeometry(t,e){if(1===e.length)return[e[0],t];{let{minX:i,minY:r,maxX:n,maxY:s}=yc.fromPoints(e).extend(t);return[new f(i,r),new f(n,r),new f(n,s),new f(i,s),new f(i,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;let 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._pixelPerMeter=kc(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=x(new Float64Array(16));A(t,t,[this._width/2,-this._height/2,1]),E(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=x(new Float64Array(16)),A(t,t,[1,-1,1]),E(t,t,[-1,-1,0]),A(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,e,i,r){let n=void 0===i?this.bearing:i,s=r=void 0===r?this.pitch:r,{distanceToCenter:o,clampedElevation:a}=this._distanceToCenterFromAltElevationPitch(e,this.elevation,s),{x:l,y:h}=Zc(s,n),u=Oc.fromLngLat(t,e),{centerMercator:c,dMercator:f}=this._centerAlongView(u,l,h,o,Rc(1,u.y));return{center:c.toLngLat(),elevation:a,zoom:It(this.height/2/Math.tan(this.fovInRadians/2)/f/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;let e=this.pitch,i=this.bearing,{x:r,y:n,z:s}=Zc(e,i),o=Oc.fromLngLat(this.center,this.elevation),a=1/kc(1,this.center.lat),l=this.cameraToCenterDistance/this.worldSize,h=new Oc(o.x-r*l,o.y-n*l,o.z+s*l),{distanceToCenter:u,clampedElevation:c}=this._distanceToCenterFromAltElevationPitch(h.z*a,t,e),{centerMercator:f,dMercator:p}=this._centerAlongView(h,r,n,u,a),d=f.toLngLat(),m=It(this.cameraToCenterDistance/p/this.tileSize);this._elevation=c,this._center=d;let _=this._zoom;this.setZoom(m),this._zoom===_&&(this._unmodified=!1,this.constrainInternal(),this._calcMatrices())}_centerAlongView(t,e,i,r,n){let s=r/n,o=new Oc(t.x+e*s,t.y+i*s),a=1/0;for(let l=1;l<10;l++){let l=1/o.meterInMercatorCoordinateUnits(),h=Math.abs(l-n);if(h<=1e-12*n||h>=a)break;a=h,s=r/(n=l),o=new Oc(t.x+e*s,t.y+i*s)}return{centerMercator:o,dMercator:s}}_distanceToCenterFromAltElevationPitch(t,e,i){let r,n=-Math.cos(Ht(i)),s=t-e,o=e;return n*s>=0||Math.abs(n)<Math.cos(Ht(89.25))?(r=1e4,o=t+r*n):r=-s/n,{distanceToCenter:r,clampedElevation:o}}getCameraPoint(){let t=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new f(t*Math.sin(this.rollInRadians),t*Math.cos(this.rollInRadians)))}getMercatorTileCoordinates(t){if(!t)return[0,0,1,1];let e=t.canonical.z>=0?1<<t.canonical.z:2**t.canonical.z;return[t.canonical.x/e,t.canonical.y/e,1/e/st,1/e/st]}},Pw=class{getCenter(t){return t.center}distanceToTile2d(t,e,i,r){let n=r,s=n.distanceX([t,e]),o=n.distanceY([t,e]);return Math.hypot(s,o)}getWrap(t,e,i){return i}getTileBoundingVolume(t,e,i,r){let n=Math.min(0,i),s=Math.max(0,i);if(r?.terrain){let i=new Hm(t.z,e,t.z,t.x,t.y),o=r.terrain.getMinMaxElevation(i);n=o.minElevation??n,s=o.maxElevation??s}let o=1<<t.z;return new tv([e+t.x/o,t.y/o,n],[e+(t.x+1)/o,(t.y+1)/o,s])}allowVariableZoom(t,e){let i=At(78.5-t.fov*(Math.abs(Math.cos(t.rollInRadians))*t.height+Math.abs(Math.sin(t.rollInRadians))*t.width)/t.height/2,0,60);return!!e.terrain||t.pitch>i}allowWorldCopies(){return!0}prepareNextFrame(){}};const Iw=st*(1-1e-12),kw={covered:!1,demLoaded:!1,elevation:0};var $w=class{constructor(t,e){this.tileManager=t,this.exaggeration=e,this._samplerCache=new Map}reset(){this._samplerCache.clear(),this._index=void 0,this._ownDemIndex=void 0}getIndex(t=!1){return t?(void 0===this._ownDemIndex&&(this._ownDemIndex=this._build(!0)),this._ownDemIndex):(void 0===this._index&&(this._index=this._build(!1)),this._index)}sample(t,e=!1){let i=this.getIndex(e);if(!i)return;let r=Oc.fromLngLat(t),n=jw(i,this.exaggeration,r.x,r.y);return n.demLoaded?n.elevation:void 0}getSampler(t){let e=t.key,i=this._samplerCache.get(e);if(i)return i;let r=this._createElevationSampler(t);return r&&this._samplerCache.set(e,r),r}_createElevationSampler(t){let e=this.tileManager.getSourceTile(t,!0),i=e?.dem;if(!e||!i)return null;let r=t.canonical.z-e.tileID.canonical.z,n=1<<r,s=i.dim/(st*n),o=(t.canonical.x-(t.canonical.x>>r<<r))/n*i.dim-.5,a=(t.canonical.y-(t.canonical.y>>r<<r))/n*i.dim-.5;return(t,e,r)=>{let n=8192===r?1:st/r;return i.sampleBilinear(t*n*s+o,e*n*s+a)}}_build(t){let{tileManager:e}=this,i=[],r=new Map,n=0,s=0;for(let o of e.getRenderableTiles()){if(!o)continue;let{canonical:a,wrap:l}=o.tileID;i.includes(a.z)||i.push(a.z);let h=t&&!e.getSourceTile(o.tileID)?.dem?null:this.getSampler(o.tileID);r.set(`${l}/${a.z}/${a.x}/${a.y}`,h);let u=e.getSourceTile(o.tileID,!0)?.dem;n=Math.min(n,(u?.min??0)*this.exaggeration),s=Math.max(s,(u?.max??0)*this.exaggeration)}return 0===r.size?null:(i.sort(((t,e)=>e-t)),{zooms:i,samplerPerTile:r,minElevation:n-10,maxElevation:s+10})}};function jw(t,e,i,r){if(r<0||r>=1)return kw;let n=Math.floor(i),s=i-n;for(let i of t.zooms){let o=1<<i,a=s*o,l=r*o,h=Math.floor(a),u=Math.floor(l),c=`${n}/${i}/${h}/${u}`;if(!t.samplerPerTile.has(c))continue;let f=t.samplerPerTile.get(c);return f?{covered:!0,demLoaded:!0,elevation:f(Math.min((a-h)*st,Iw),Math.min((l-u)*st,Iw),st)*e}:{covered:!0,demLoaded:!1,elevation:0}}return kw}function Rw(t,e){return t.covered&&e<=t.elevation+1e-6}function Ow(t,e,i,r,n){for(let s=0;s<40&&r-i>n;s++){let n=(i+r)/2;e(t,n)?r=n:i=n}return{lo:i,hi:r}}var Bw=class t{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){}constructor(t,e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,e)=>{e=At(+e,this.minZoom,this.maxZoom);let i={center:new Cc(t.lng,t.lat),zoom:e},r=this._helper._lngRange;!this._helper._renderWorldCopies&&null===r&&(r=[-179.9999999999,180-1e-10]);let n=this.tileSize*Pt(i.zoom),s=0,o=n,a=0,l=n,h=0,u=0,{top:c=0,bottom:p=0,left:d=0,right:m=0}=this.padding,_=this.width-d-m,g=this.height-c-p;if(this._helper._latRange){let t=this._helper._latRange;s=Ic(t[1])*n,o=Ic(t[0])*n,o-s<g&&(h=g/(o-s))}r&&(a=Ft(Pc(r[0])*n,0,n),l=Ft(Pc(r[1])*n,0,n),l<a&&(l+=n),l-a<_&&(u=_/(l-a)));let y,v,{x:w,y:b}=Uc(n,t),x=Math.max(u||0,h||0);if(x)return i.center=Nc(n,new f(u?(l+a)/2:w,h?(o+s)/2:b)).wrap(),i.zoom+=It(x),i;if(this._helper._latRange){let t=g/2;b-t<s&&(v=s+t),b+t>o&&(v=o-t)}if(r){let t=(a+l)/2,e=w;this._helper._renderWorldCopies&&(e=Ft(w,t-n/2,t+n/2));let i=_/2;e-i<a&&(y=a+i),e+i>l&&(y=l-i)}return(void 0!==y||void 0!==v)&&(i.center=Nc(n,new f(y??w,v??b)).wrap()),i},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=e??new Tw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Pw}clone(){let e=new t;return e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e)}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){let e=[new Wm(0,t)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new f(0,0)),r=this.screenPointToMercatorCoordinate(new f(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new f(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new f(0,this._helper._height)),o=Math.floor(Math.min(i.x,r.x,n.x,s.x)),a=Math.floor(Math.max(i.x,r.x,n.x,s.x));for(let i=o-1;i<=a+1;i++)0!==i&&e.push(new Wm(i,t))}return e}getCameraFrustum(){return ev.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){for(let e=0;e<3;e++){let e=t&&this._terrainPointPastMaxZoom(t)||this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLat(e,this):0;if(this.pitch<90&&i>=this.getCameraAltitude()||(this._helper.recalculateZoomAndCenter(i),!t||Math.abs(t.getElevationForLngLat(this.center,this)-this.elevation)<=1e-4))return}}setLocationAtPoint(t,e,i=this.elevation){let r=this.screenPointToMercatorCoordinateAtZ(e,i-this.elevation),n=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=Oc.fromLngLat(t),o=new Oc(s.x-(r.x-n.x),s.y-(r.y-n.y));this.setCenter(o?.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(t,e){return e?this.coordinatePoint(Oc.fromLngLat(t),e.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(Oc.fromLngLat(t))}screenPointToLocation(t,e){return this.screenPointToMercatorCoordinate(t,e)?.toLngLat()}screenPointToLocationAtElevation(t,e){return this.screenPointToMercatorCoordinateAtZ(t,e-this.elevation)?.toLngLat()}screenPointToMercatorCoordinate(t,e){if(e){let i=this.screenTerrainPointToMercatorCoordinate(t,e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(t)}_terrainPointPastMaxZoom(t){let e=t.getCoverageIndex();if(!e)return null;let{near:i,far:r}=this.getRaySegmentFromPixel(this.centerPoint,-1),n=this.cameraToCenterDistance*Pt(this.zoom-this.maxZoom),s=function(t,e,i,r){var n=e[0],s=e[1],o=e[2];return t[0]=n+r*(i[0]-n),t[1]=s+r*(i[1]-s),t[2]=o+r*(i[2]-o),t}([],i,r,Math.max(0,(n-this.nearZ)/(this.farZ-this.nearZ)));return Rw(jw(e,t.exaggeration,s[0]/this.worldSize,s[1]/this.worldSize),s[2])?null:this._raycastTerrain(s,r,t)?.toLngLat()??null}screenTerrainPointToMercatorCoordinate(t,e){let{near:i,far:r}=this.getRaySegmentFromPixel(t,-1);return this._raycastTerrain(i,r,e)}_raycastTerrain(t,e,i){let r=i.getCoverageIndex();if(!r)return null;let n=this.worldSize,s=e[0]-t[0],o=e[1]-t[1],a=e[2]-t[2],l={index:r,exaggeration:i.exaggeration,near:t,dx:s,dy:o,dz:a,worldSize:n},h=0,u=1;if(0===a){if(t[2]>r.maxElevation||t[2]<r.minElevation)return null}else{let e=(r.maxElevation-t[2])/a,i=(r.minElevation-t[2])/a;if(h=Math.max(h,Math.min(e,i)),u=Math.min(u,Math.max(e,i)),h>u)return null}let c=Math.hypot(s,o),f=At(Math.ceil(c*(u-h)/4),1,512),p=0,d=!Uw(l,0);for(let e=0;e<=f;e++){let i=h+(u-h)*e/f;if(d){if(Uw(l,i)){let{lo:e,hi:r}=Ow(l,Uw,p,i,.001/c),h=Lw(l,e),u=Lw(l,r),f=t[2]+e*a-h.elevation,d=t[2]+r*a-u.elevation,m=h.covered&&f>d?At(e+f*(r-e)/(f-d),e,r):r;return new Oc((t[0]+m*s)/n,(t[1]+m*o)/n,Lw(l,m).elevation)}}else d=!Uw(l,i);p=i}return null}getRaySegmentFromPixel(t,e=0){let i=[t.x,t.y,e,1],r=[t.x,t.y,1,1];Y(i,i,this._pixelMatrixInverse),Y(r,r,this._pixelMatrixInverse);let n=i[3],s=r[3],o=this.elevation;return{near:[i[0]/n,i[1]/n,i[2]/n+o],far:[r[0]/s,r[1]/s,r[2]/s+o]}}screenPointToMercatorCoordinateAtZ(t,e){let i=e||0,{near:r,far:n}=this.getRaySegmentFromPixel(t),s=r[2]===n[2]?0:(i+this.elevation-r[2])/(n[2]-r[2]);return new Oc(Sr.number(r[0],n[0],s)/this.worldSize,Sr.number(r[1],n[1],s)/this.worldSize,i)}coordinatePoint(t,e=0,i=this._pixelMatrix){let r=this._coordinateClipPoint(t,e,i),n=r[3];return n>0?new f(r[0]/n,r[1]/n):this._offScreenPointBehindCamera(r[0],r[1],n)}_coordinateClipPoint(t,e,i){let r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return Y(r,r,i)}_offScreenPointBehindCamera(t,e,i){let r=this.width/2,n=this.height/2,s=t-r*i,o=e-n*i;0===s&&0===o&&(o=1);let a=n+this.height,l=Math.min(0===s?1/0:(r+this.width)/Math.abs(s),0===o?1/0:a/Math.abs(o));return new f(r+s*l,n+o*l)}getBounds(){let t=Math.max(0,this._helper._height/2-Gc(this));return(new Um).extend(this.screenPointToLocation(new f(0,t))).extend(this.screenPointToLocation(new f(this._helper._width,t))).extend(this.screenPointToLocation(new f(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new f(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=this.screenTerrainPointToMercatorCoordinate(t,e):t.y>this.centerPoint.y-Gc(this)}calculatePosMatrix(t,e=!1,i=!1){let r=t.key??Ym(t.wrap,t.canonical.z,t.canonical.z,t.canonical.x,t.canonical.y),n=e?this._alignedPosMatrixCache:this._posMatrixCache;if(n.has(r)){let t=n.get(r);return i?t.f32:t.f64}let s=qc(t,this.worldSize);M(s,e?this._alignedProjMatrix:this._viewProjMatrix,s);let o={f64:s,f32:new Float32Array(s)};return n.set(r,o),i?o.f32:o.f64}calculateFogMatrix(t){let e=t.key,i=this._fogMatrixCacheF32;if(i.has(e))return i.get(e);let r=qc(t,this.worldSize);return M(r,this._fogMatrix,r),i.set(e,new Float32Array(r)),i.get(e)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}calculateCameraOptionsFromTo(t,e,i,r){let n=Oc.fromLngLat(t,e),s=Oc.fromLngLat(i,r),o=s.x-n.x,a=s.y-n.y,l=s.z-n.z,h=Math.hypot(o,a,l);if(0===h)throw Error("Can't calculate camera options with same From and To");let u=Math.hypot(o,a),c=It(this.cameraToCenterDistance/h/this.tileSize),f=Yt(Math.atan2(o,-a)),p=Yt(Math.acos(u/h));return p=l<0?90-p:90+p,{center:s.toLngLat(),elevation:r,zoom:c,pitch:p,bearing:f}}_calculateNearFarZ(t,e,i){let r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),n=t-r*this._helper._pixelPerMeter/Math.cos(e),s=r<0?n:t,o=Math.PI/2+this.pitchInRadians,a=Ht(this.fov)*(Math.abs(Math.cos(Ht(this.roll)))*this.height+Math.abs(Math.sin(Ht(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(a)*s/Math.sin(At(Math.PI-o-a,.01,Math.PI-.01)),h=Gc(this),u=Math.atan(h/this._helper.cameraToCenterDistance),c=Ht(.75),f=u>c?2*u*(.5+i.y/(2*h)):c,p=Math.sin(f)*s/Math.sin(At(Math.PI-o-f,.01,Math.PI-.01)),d=Math.min(l,p);this._helper._farZ=1.01*(Math.cos(Math.PI/2-e)*d+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let e,i=this.centerOffset,r=Uc(this.worldSize,this.center),n=r.x,s=r.y,o=Ht(Math.min(this.pitch,Bc)),a=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));t&&this._calculateNearFarZ(a,o,i),e=new Float64Array(16),z(e,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),function(t,e){t[0]=1/e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1/e[5],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=0,t[11]=1/e[14],t[12]=0,t[13]=0,t[14]=-1,t[15]=e[10]/e[14]}(this._invProjMatrix,e),e[8]=2*-i.x/this._helper._width,e[9]=2*i.y/this._helper._height,this._projectionMatrix=b(e),A(e,e,[1,-1,1]),E(e,e,[0,0,-this._helper.cameraToCenterDistance]),C(e,e,-this.rollInRadians),F(e,e,this.pitchInRadians),C(e,e,-this.bearingInRadians),E(e,e,[-n,-s,0]),this._mercatorMatrix=A([],e,[this.worldSize,this.worldSize,this.worldSize]),A(e,e,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=M(new Float64Array(16),this.clipSpaceToPixelsMatrix,e),E(e,e,[0,0,-this.elevation]),this._viewProjMatrix=e,this._invViewProjMatrix=D([],e);let l=[0,0,-1,1];Y(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),z(this._fogMatrix,this.fovInRadians,this.width/this.height,a,this._helper._farZ),this._fogMatrix[8]=2*-i.x/this.width,this._fogMatrix[9]=2*i.y/this.height,A(this._fogMatrix,this._fogMatrix,[1,-1,1]),E(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),C(this._fogMatrix,this._fogMatrix,-this.rollInRadians),F(this._fogMatrix,this._fogMatrix,this.pitchInRadians),C(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),E(this._fogMatrix,this._fogMatrix,[-n,-s,0]),A(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),E(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=M(new Float64Array(16),this.clipSpaceToPixelsMatrix,e);let h=this._helper._width%2/2,u=this._helper._height%2/2,c=Math.cos(this.bearingInRadians),f=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+c*h+f*u,d=s-Math.round(s)+c*u+f*h,m=new Float64Array(e);if(E(m,m,[p>.5?p-1:p,d>.5?d-1:d,0]),this._alignedProjMatrix=m,e=D(new Float64Array(16),this._pixelMatrix),!e)throw Error("failed to invert matrix");this._pixelMatrixInverse=e,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new f(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return Y(e,e,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this.cameraToCenterDistance/this.pixelsPerMeter+this.elevation}getCameraLngLat(){let t=kc(1,this.center.lat)*this.worldSize;return Vc(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}getProjectionData(t){let e,{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=t,s=this._helper.getMercatorTileCoordinates(i),o=i?this.calculatePosMatrix(i,r,!0):null;return e=i?.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:o||ft(),{mainMatrix:e,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:e,clipAntimeridian:!1}}isLocationOccluded(t,e,i){if(!e?.getCoverageIndex())return!1;let r=Oc.fromLngLat(t);i??=e.getElevationForLngLat(t,this);let n=this._coordinateClipPoint(r,i,this._pixelMatrix3D),s=n[3];if(s<=0||n[2]>s)return!0;let o=new f(n[0]/s,n[1]/s),a=this.screenTerrainPointToMercatorCoordinate(o,e);if(null==a)return!1;let l=this.getRaySegmentFromPixel(o,-1),h=Nw(l,r.x*this.worldSize,r.y*this.worldSize,i);return Nw(l,a.x*this.worldSize,a.y*this.worldSize,a.z)<.99*h}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return I(t)}getRayDirectionFromPixel(t){throw Error("Not implemented.")}projectTileCoordinates(t,e,i,r){let n,s=this.calculatePosMatrix(i);null==r?(n=[t,e,0,1],qv(n,n,s)):(n=[t,e,r,1],Y(n,n,s));let o=n[3];return{point:new f(n[0]/o,n[1]/o),signedDistanceFromCamera:o,isOccluded:!1}}populateCache(t){for(let e of t)this.calculatePosMatrix(e)}getProjectionDataForCustomLayer(t=!0){let e=new Hm(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:e,applyGlobeMatrix:t}),r=qc(e,this.worldSize);M(r,this._viewProjMatrix,r);let n=[st,st,this.worldSize/this._helper.pixelsPerMeter],s=ut();return A(s,r,n),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function Lw(t,e){return jw(t.index,t.exaggeration,(t.near[0]+e*t.dx)/t.worldSize,(t.near[1]+e*t.dy)/t.worldSize)}function Uw(t,e){return Rw(Lw(t,e),t.near[2]+e*t.dz)}function Nw({near:t,far:e},i,r,n){let s=e[0]-t[0],o=e[1]-t[1],a=e[2]-t[2];return((i-t[0])*s+(r-t[1])*o+(n-t[2])*a)/(s*s+o*o+a*a)}function Gw(){Lt("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function qw(t){if(t.useSlerp)if(t.k<1){let e=Kt(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),i=Kt(t.endEulerAngles.roll,t.endEulerAngles.pitch,t.endEulerAngles.bearing),r=new Float64Array(4);!function(t,e,i,r){var n,s,o,a,l=e[0],h=e[1],u=e[2],c=e[3],f=i[0],p=i[1],d=i[2],m=i[3],_=l*f+h*p+u*d+c*m;_<0&&(_=-_,f=-f,p=-p,d=-d,m=-m),1-_>1e-6?(n=Math.acos(_),s=Math.sin(n),o=Math.sin((1-r)*n)/s,a=Math.sin(r*n)/s):(o=1-r,a=r),t[0]=o*l+a*f,t[1]=o*h+a*p,t[2]=o*u+a*d,t[3]=o*c+a*m}(r,e,i,t.k);let n=function(t){let e=new Float64Array(9);!function(t,e){var i=e[0],r=e[1],n=e[2],s=e[3],o=i+i,a=r+r,l=n+n,h=i*o,u=r*o,c=r*a,f=n*o,p=n*a,d=n*l,m=s*o,_=s*a,g=s*l;t[0]=1-c-d,t[3]=u-g,t[6]=f+_,t[1]=u+g,t[4]=1-h-d,t[7]=p-m,t[2]=f-_,t[5]=p+m,t[8]=1-h-c}(e,t);let i,r,n=Yt(-Math.asin(At(e[2],-1,1)));return Math.hypot(e[5],e[8])<.001?(i=0,r=-Yt(Math.atan2(e[3],e[4]))):(i=Yt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),r=Yt(0===e[1]&&0===e[0]?0:Math.atan2(e[1],e[0]))),{roll:i,pitch:n+90,bearing:r}}(r);t.tr.setRoll(n.roll),t.tr.setPitch(n.pitch),t.tr.setBearing(n.bearing)}else t.tr.setRoll(t.endEulerAngles.roll),t.tr.setPitch(t.endEulerAngles.pitch),t.tr.setBearing(t.endEulerAngles.bearing);else t.tr.setRoll(Sr.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(Sr.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(Sr.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function Vw(t,e,i,r,n,s){let o=Uc(s.worldSize,r.getNorthWest()),a=Uc(s.worldSize,r.getNorthEast()),l=Uc(s.worldSize,r.getSouthEast()),h=Uc(s.worldSize,r.getSouthWest()),u=Ht(-n),c=o.rotate(u),p=a.rotate(u),d=l.rotate(u),m=h.rotate(u),_=new f(Math.max(c.x,p.x,m.x,d.x),Math.max(c.y,p.y,m.y,d.y)),g=new f(Math.min(c.x,p.x,m.x,d.x),Math.min(c.y,p.y,m.y,d.y)),y=_.sub(g),v=(s.width-(i.left+i.right+e.left+e.right))/y.x,w=(s.height-(i.top+i.bottom+e.top+e.bottom))/y.y;if(w<0||v<0)return void Gw();let b=Math.min(It(s.scale*Math.min(v,w)),t.maxZoom),x=f.convert(t.offset),D=new f((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(Ht(n)),M=x.add(D).mult(s.scale/Pt(b));return{center:Nc(s.worldSize,o.add(l).div(2).sub(M)),zoom:b,bearing:n}}var Zw=class{get useGlobeControls(){return!1}handlePanInertia(t,e){let i=t.mag(),r=Math.abs(Gc(e));return{easingOffset:t.mult(Math.min(.75*r/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,t.aroundElevation)}cameraForBoxAndBearing(t,e,i,r,n,s){return Vw(t,e,i,r,n,s)}handleJumpToCenterZoom(t,e){t.zoom!==(void 0===e.zoom?t.zoom:+e.zoom)&&t.setZoom(+e.zoom),void 0!==e.center&&t.setCenter(Cc.convert(e.center))}handleEaseTo(t,e){let i=t.zoom,r=t.padding,n={roll:t.roll,pitch:t.pitch,bearing:t.bearing},s={roll:void 0===e.roll?t.roll:e.roll,pitch:void 0===e.pitch?t.pitch:e.pitch,bearing:void 0===e.bearing?t.bearing:e.bearing},o=void 0!==e.zoom,a=!t.isPaddingEqual(e.padding),l=!1,h=o?+e.zoom:t.zoom,u=t.centerPoint.add(e.offsetAsPoint),c=t.screenPointToLocation(u),{center:f,zoom:p}=t.applyConstrain(Cc.convert(e.center||c),h??i);Cw(t,f);let d=Uc(t.worldSize,c),m=Uc(t.worldSize,f).sub(d),_=Pt(p-i);l=p!==i;let g=this._transformAtAnimationEnd(t,p,s,e.padding);return e.around?g.setLocationAtPoint(e.around,e.aroundPoint):g.setLocationAtPoint(f,g.centerPoint.add(e.offsetAsPoint)),{easeFunc:o=>{if(l&&t.setZoom(Sr.number(i,p,o)),Xt(n,s)||qw({startEulerAngles:n,endEulerAngles:s,tr:t,k:o,useSlerp:n.roll!=s.roll}),a&&(t.interpolatePadding(r,e.padding,o),u=t.centerPoint.add(e.offsetAsPoint)),e.around)t.setLocationAtPoint(e.around,e.aroundPoint);else{let e=Pt(t.zoom-i),r=(p>i?Math.min(2,_):Math.max(.5,_))**(1-o),n=Nc(t.worldSize,d.add(m.mult(o*r)).mult(e));t.setLocationAtPoint(t.renderWorldCopies?n.wrap():n,u)}},isZooming:l,elevationCenter:g.center}}handleFlyTo(t,e){let i=void 0!==e.zoom,r=t.zoom,n=t.applyConstrain(Cc.convert(e.center||e.locationAtOffset),i?+e.zoom:r),s=n.center,o=n.zoom;Cw(t,s);let a=t.worldSize,l=Uc(a,e.locationAtOffset),h=Uc(a,s).sub(l),u=h.mag(),c=Pt(o-r),f=Math.max(void 0===e.minZoom?t.minZoom:+e.minZoom,t.minZoom),p=Math.min(f,r,o),d=Pt(t.applyConstrain(s,p).zoom-r),m=this._transformAtAnimationEnd(t,o,{roll:e.roll,pitch:e.pitch,bearing:e.bearing},e.padding);return m.setLocationAtPoint(s,m.centerPoint.add(e.offsetAsPoint)),{easeFunc:(e,i,n,u)=>{t.setZoom(1===e?o:r+It(i));let c=1===e?s:Nc(a,l.add(h.mult(n)));t.setLocationAtPoint(t.renderWorldCopies?c.wrap():c,u)},scaleOfZoom:c,targetCenter:m.center,scaleOfMinZoom:d,pixelPathLength:u}}_transformAtAnimationEnd(t,e,i,r){let n=t.clone();return n.setZoom(e),n.setRoll(i.roll),n.setPitch(i.pitch),n.setBearing(i.bearing),n.setPadding(r),n}};let Ww;const Hw=new tc({fill:new Qu(128,2),line:new Qu(512,0),tile:new Qu(128,32),stencil:new Qu(128,1),circle:3});var Yw=class{constructor(){this._tileMeshCache={}}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 Dw.projectionGlobe}get vertexShaderPreludeCode(){return Dw.projectionMercator.vertexSource}get subdivisionGranularity(){return Hw}get useGlobeControls(){return!0}destroy(){}_getMeshKey(t){return`${t.granularity.toString(36)}_${t.generateBorders?"b":""}${t.extendToNorthPole?"n":""}${t.extendToSouthPole?"s":""}`}getMeshFromTileID(t,e,i,r,n){let s=("stencil"===n?Hw.stencil:Hw.tile).getGranularityForZoomLevel(e.z);return this._getMesh(t,{granularity:s,generateBorders:i,extendToNorthPole:0===e.y&&r,extendToSouthPole:e.y===(1<<e.z)-1&&r})}_getMesh(t,e){let i=this._getMeshKey(e);if(i in this._tileMeshCache)return this._tileMeshCache[i];let r=m_(t,e);return this._tileMeshCache[i]=r,r}recalculate(t){}hasTransition(){return!1}},Xw=class extends Re{constructor(t,e){super(),this._transitionable=new ea(Ww||=new da({type:new ha(Ke.projection.type,"type")}),"projection",e),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new Ko(0)),this._mercatorProjection=new Fw,this._verticalPerspectiveProjection=new Yw}get transitionState(){let 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 mr){if(t.from===t.to)return"mercator"===t.from?0:1;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 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()}getMeshFromTileID(t,e,i,r,n){return this.currentProjection.getMeshFromTileID(t,e,i,r,n)}setProjection(t){this._transitionable.setValue("type",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)}};function Jw(t){let e=tb(t.worldSize,t.center.lat);return 2*Math.PI*e}function Kw(t,e,i,r,n){let s=1/(1<<n),o=e/st*s+r*s,a=wt((t/st*s+i*s)*Math.PI*2+Math.PI,2*Math.PI),l=2*Math.atan(Math.exp(Math.PI-o*Math.PI*2))-.5*Math.PI,h=Math.cos(l),u=new Float64Array(3);return u[0]=Math.sin(a)*h,u[1]=Math.sin(l),u[2]=Math.cos(a)*h,u}function Qw(t){return function(t,e){let i=Math.cos(e),r=new Float64Array(3);return r[0]=Math.sin(t)*i,r[1]=Math.sin(e),r[2]=Math.cos(t)*i,r}(t.lng*Math.PI/180,t.lat*Math.PI/180)}function tb(t,e){return t/(2*Math.PI)/sb(e)}function eb(t){let e=Y(lt(),[0,0,0,1],t.modelViewProjectionMatrix);return Y(e,e,t.inverseProjectionMatrix),[e[0]/e[3],e[1]/e[3],e[2]/e[3]]}function ib(t){let e=Math.asin(t[1])/Math.PI*180,i=Math.sqrt(t[0]*t[0]+t[2]*t[2]);if(i>1e-6){let r=t[0]/i,n=Math.acos(t[2]/i);return new Cc(Ft((r>0?n:-n)/Math.PI*180,-180,180),e)}return new Cc(0,e)}const rb=.98*Math.PI;function nb(t,e){let i=t.cameraPosition,r=k(i);if(r<=1)return t.screenPointToLocation(e);let n=ht();L(n,i);let s=t.getRayDirectionFromPixel(e),o=-U(s,n),a=ht();B(a,s,n,o);let l=k(a);if(l<1e-9)return t.screenPointToLocation(e);let h=Math.atan2(l,o),u=.9*Math.asin(1/r);if(h<u)return t.screenPointToLocation(e);let c=r*Math.sin(u),f=Math.asin(At(c,-1,1))-u,p=r*Math.cos(u)/Math.sqrt(Math.max(1-c*c,1e-12))-1,d=rb-f,m=h-u,_=f+p*m*d/(d+p*m),g=ht();O(g,a,1/l);let y=ht();return O(y,n,Math.cos(At(_,0,rb))),B(y,y,g,Math.sin(At(_,0,rb))),L(y,y),ib(y)}function sb(t){return Math.cos(Math.min(Math.abs(t),Qt)*Math.PI/180)}function ob(t,e){let i=sb(t);return It(sb(e)/i)}function ab(t){let e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function lb(t,e,i,r){let n=At(t.lat+i*r,-90,90),s=At(t.lat,-85.051129,Qt),o=At(t.lat+i,-85.051129,Qt);if(Math.abs(o-s)>1){let i=(Math.sign(o)===Math.sign(s)?Math.abs(s):-Math.abs(s))*Math.PI/180,a=Math.abs(o)*Math.PI/180,l=ab(i+r*(a-i)),h=ab(i),u=ab(a);return new Cc(t.lng+e*((l-h)/(u-h)),n)}return new Cc(t.lng+e*r,n)}function hb(t,e,i=1){let r=U(t,e),n=i*i,s=ht(),o=ht();O(o,e,r),W(s,t,o);let a=n-U(s,s);if(a<0)return null;let l=U(t,t)-n,h=-r+(r<0?1:-1)*Math.sqrt(a),u=l/h,c=h,f=Math.max(u,c);return f<0?null:{tMin:Math.min(u,c),tMax:f}}function ub(t,e){let i=.01569612305760477*e,r=At((t-i)/(9*i),0,1);return r*r*(3-2*r)}var cb=class{constructor(t){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=t}swapBuffers(){if(!this._hadAnyChanges)return;let t=this._cachePrevious;this._cachePrevious=this._cache,this._cache=t,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(t,e,i,r){let n=`${t.z}_${t.x}_${t.y}_${r?.terrain?"t":""}_${Math.round(i)}`,s=this._cache.get(n);if(s)return s;let o=this._cachePrevious.get(n);if(o)return this._cache.set(n,o),o;let a=this._boundingVolumeFactory(t,e,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}},fb=class t{constructor(t,e,i,r){this.min=i,this.max=r,this.points=t,this.planes=e}static fromAabb(e,i){let r=[];for(let t=0;t<8;t++)r.push([1&~t?e[0]:i[0],1==(t>>1&1)?i[1]:e[1],1==(t>>2&1)?i[2]:e[2]]);return new t(r,[[-1,0,0,i[0]],[1,0,0,-e[0]],[0,-1,0,i[1]],[0,1,0,-e[1]],[0,0,-1,i[2]],[0,0,1,-e[2]]],e,i)}static fromCenterSizeAngles(e,i,r){let n=J([],r[0],r[1],r[2]),s=G([],[i[0],0,0],n),o=G([],[0,i[1],0],n),a=G([],[0,0,i[2]],n),l=[...e],h=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){let r=e[i]+s[i]*(1&~t?-1:1)+o[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],r),h[i]=Math.max(h[i],r)}let u=[];for(let t=0;t<8;t++){let i=[...e];j(i,i,O([],s,1&~t?-1:1)),j(i,i,O([],o,1==(t>>1&1)?1:-1)),j(i,i,O([],a,1==(t>>2&1)?1:-1)),u.push(i)}return new t(u,[[...s,-U(s,u[0])],[...o,-U(o,u[0])],[...a,-U(a,u[0])],[-s[0],-s[1],-s[2],-U(s,u[7])],[-o[0],-o[1],-o[2],-U(o,u[7])],[-a[0],-a[1],-a[2],-U(a,u[7])]],l,h)}intersectsFrustum(t){let e=!0,i=this.points.length,r=this.planes.length,n=t.planes.length,s=t.points.length;for(let r=0;r<n;r++){let n=t.planes[r],s=0;for(let t=0;t<i;t++){let e=this.points[t];n[0]*e[0]+n[1]*e[1]+n[2]*e[2]+n[3]>=0&&s++}if(0===s)return 0;s<i&&(e=!1)}if(e)return 2;for(let e=0;e<r;e++){let i=this.planes[e],r=0;for(let e=0;e<s;e++){let n=t.points[e];i[0]*n[0]+i[1]*n[1]+i[2]*n[2]+i[3]>=0&&r++}if(0===r)return 0}return 1}intersectsPlane(t){let e=this.points.length,i=0;for(let r=0;r<e;r++){let e=this.points[r];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 pb(t,e,i){let r=t-e;return r<0?-r:Math.max(0,r-i)}function db(t,e,i,r,n){let s,o=t-i;return s=o<0?Math.min(-o,1+o-n):o>n?Math.min(Math.max(o-n,0),1-o):0,Math.max(s,pb(e,r,n))}var mb=class{constructor(){this._boundingVolumeCache=new cb(this._computeTileBoundingVolume)}getCenter(t){return new Cc(t.center.lng,At(t.center.lat,-85.051129,Qt))}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(t,e,i,r){let n=1<<i.z,s=1/n,o=i.x/n,a=i.y/n,l=2;return l=Math.min(l,db(t,e,o,a,s)),l=Math.min(l,db(t,e,o+.5,-a-s,s)),l=Math.min(l,db(t,e,o+.5,2-a-s,s)),l}getWrap(t,e,i){let r=1<<e.z,n=1/r,s=e.x/r,o=pb(t.x,s,n),a=pb(t.x,s-1,n),l=pb(t.x,s+1,n),h=Math.min(o,a,l);return h===l?1:h===a?-1:0}allowVariableZoom(t,e){return ov(t,e)>4}allowWorldCopies(){return!1}getTileBoundingVolume(t,e,i,r){return this._boundingVolumeCache.getTileBoundingVolume(t,e,i,r)}_computeTileBoundingVolume(t,e,i,r){let n=Math.min(0,i),s=Math.max(0,i);if(r?.terrain){let i=new Hm(t.z,e,t.z,t.x,t.y),o=r.terrain.getMinMaxElevation(i);n=o.minElevation??n,s=Math.max(o.maxElevation??s,s)}if(n/=Sc,s/=Sc,n+=1,s+=1,t.z<=0)return fb.fromAabb([-s,-s,-s],[s,s,s]);if(1===t.z)return fb.fromAabb([0===t.x?-s:0,0===t.y?0:-s,-s],[0===t.x?0:s,0===t.y?s:0,s]);{let e=[Kw(0,0,t.x,t.y,t.z),Kw(st,0,t.x,t.y,t.z),Kw(st,st,t.x,t.y,t.z),Kw(0,st,t.x,t.y,t.z)],i=[];for(let t of e)i.push(O([],t,s));if(s!==n)for(let t of e)i.push(O([],t,n));0===t.y&&i.push([0,1,0]),t.y===(1<<t.z)-1&&i.push([0,-1,0]);let r=[1,1,1],o=[-1,-1,-1];for(let t of i)for(let e=0;e<3;e++)r[e]=Math.min(r[e],t[e]),o[e]=Math.max(o[e],t[e]);let a=Kw(st/2,st/2,t.x,t.y,t.z),l=N([],[0,1,0],a);L(l,l);let h=N([],a,l);L(h,h);let u=N([],e[2],e[1]);L(u,u);let c=N([],e[0],e[3]);L(c,c),i.push(O([],a,s)),t.y>=(1<<t.z)/2&&i.push(O([],Kw(st/2,0,t.x,t.y,t.z),s)),t.y<(1<<t.z)/2&&i.push(O([],Kw(st/2,st,t.x,t.y,t.z),s));let f=_b(a,i),p=_b(h,i),d=[-a[0],-a[1],-a[2],f.max],m=[a[0],a[1],a[2],-f.min],_=[-h[0],-h[1],-h[2],p.max],g=[h[0],h[1],h[2],-p.min],y=[...u,0],v=[...c,0],w=[];return 0===t.y?w.push(mt(v,y,d),mt(v,y,m)):w.push(mt(_,y,d),mt(_,y,m),mt(_,v,d),mt(_,v,m)),t.y===(1<<t.z)-1?w.push(mt(v,y,d),mt(v,y,m)):w.push(mt(g,y,d),mt(g,y,m),mt(g,v,d),mt(g,v,m)),new fb(w,[d,m,_,g,y,v],r,o)}}};function _b(t,e){let i=1/0,r=-1/0;for(let n of e){let e=U(t,n);i=Math.min(i,e),r=Math.max(r,e)}return{min:i,max:r}}var gb=class t{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,e){this._cachedClippingPlane=lt(),this._projectionMatrix=ct(),this._globeViewProjMatrix32f=ft(),this._globeViewProjMatrixF64=ct(),this._globeViewProjMatrixF64Inverted=ct(),this._globeProjMatrixInverted=ct(),this._cameraPosition=ht(),this.defaultConstrain=(t,e)=>{let i=At(+e,this.minZoom+ob(0,t.lat),this.maxZoom),r=this._getMaxLatitude(i);return{center:new Cc(t.lng,At(t.lat,-r,r)),zoom:i}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=e??new Tw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new mb}clone(){let e=new t;return e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixF64}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){let t=ht();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){let{overscaledTileID:e,applyGlobeMatrix:i}=t,r=this._helper.getMercatorTileCoordinates(e);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:+!!i,fallbackMatrix:this._globeViewProjMatrix32f,clipAntimeridian:0===e?.canonical.z}}_computeClippingPlane(t){let e=this.pitchInRadians,i=this.cameraToCenterDistance/t,r=Math.sin(e)*i,n=Math.cos(e)*i+1,s=1/Math.sqrt(r*r+n*n)*1,o=-r,a=n,l=Math.sqrt(o*o+a*a);o/=l,a/=l;let h=[0,o,a];Z(h,h,[0,0,0],-this.bearingInRadians),q(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),V(h,h,[0,0,0],this.center.lng*Math.PI/180);let u=1/k(h);return O(h,h,u),[...h,-s*u]}isLocationOccluded(t,e,i){let r=e?.getCoverageIndex();i??=r?e.getElevationForLngLat(t,this):0;let n=wb(t,i);if(!this.isSurfacePointVisible(n))return!0;if(!r)return!1;let s=this._projectSurfacePointToScreen(n),o=this.cameraPosition,a=this.getRayDirectionFromPixel(s),l=bb(o,a,n);if(l<=0)return!0;let h=this.screenTerrainPointToMercatorCoordinate(s,e);return null!=h&&bb(o,a,wb(h.toLngLat(),h.z))<.99*l}transformLightDirection(t){let e=this._helper._center.lng*Math.PI/180,i=this._helper._center.lat*Math.PI/180,r=Math.cos(i),n=[Math.sin(e)*r,Math.sin(i),Math.cos(e)*r],s=[n[2],0,-n[0]],o=[0,0,0];N(o,s,n),L(s,s),L(o,o);let a=[0,0,0];return L(a,[s[0]*t[0]+o[0]*t[1]+n[0]*t[2],s[1]*t[0]+o[1]*t[1]+n[1]*t[2],s[2]*t[0]+o[2]*t[1]+n[2]*t[2]]),a}getPixelScale(){return 1/sb(this._helper._center.lat)}getCircleRadiusCorrection(){return sb(this._helper._center.lat)}getPitchedTextCorrection(t,e,i){let r=Lc(t,e,i.canonical),n=function(t,e){return[wt(t*Math.PI*2+Math.PI,2*Math.PI),2*Math.atan(Math.exp(Math.PI-e*Math.PI*2))-.5*Math.PI]}(r.x,r.y);return this.getCircleRadiusCorrection()/Math.cos(n[1])}projectTileCoordinates(t,e,i,r){let n,s=i.canonical,o=Kw(t,e,s.x,s.y,s.z),a=1+(r??0)/Sc,l=o[0]*a,h=o[1]*a,u=o[2]*a,c=[l,h,u,1];if(Y(c,c,this._globeViewProjMatrixF64),a<=1){let t=this._cachedClippingPlane;n=t[0]*o[0]+t[1]*o[1]+t[2]*o[2]+t[3]<0}else n=this._isLineOfSightBlocked(l,h,u);return{point:new f(c[0]/c[3],c[1]/c[3]),signedDistanceFromCamera:c[3],isOccluded:n}}_isLineOfSightBlocked(t,e,i){let r=this._cameraPosition,n=t-r[0],s=e-r[1],o=i-r[2],a=n*n+s*s+o*o;if(0===a)return!1;let l=At(-(r[0]*n+r[1]*s+r[2]*o)/a,0,1),h=r[0]+l*n,u=r[1]+l*s,c=r[2]+l*o;return h*h+u*u+c*c<1}_calcMatrices(t=this._helper.autoCalculateNearFarZ){let e=tb(this.worldSize,this.center.lat),i=ut();t&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*e),z(i,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let r=this.centerOffset;i[8]=2*-r.x/this._helper._width,i[9]=2*r.y/this._helper._height,this._projectionMatrix=b(i),this._globeProjMatrixInverted=ut(),D(this._globeProjMatrixInverted,i),E(i,i,[0,0,-this.cameraToCenterDistance]),C(i,i,this.rollInRadians),F(i,i,-this.pitchInRadians),C(i,i,this.bearingInRadians),E(i,i,[0,0,-e]);let n=ht();n[0]=e,n[1]=e,n[2]=e,F(i,i,this.center.lat*Math.PI/180),S(i,i,-this.center.lng*Math.PI/180),A(i,i,n),this._globeViewProjMatrixF64=i,this._globeViewProjMatrix32f=new Float32Array(i),this._globeViewProjMatrixF64Inverted=ut(),D(this._globeViewProjMatrixF64Inverted,i);let s=ht();this._cameraPosition=ht(),this._cameraPosition[2]=this.cameraToCenterDistance/e,Z(this._cameraPosition,this._cameraPosition,s,-this.rollInRadians),q(this._cameraPosition,this._cameraPosition,s,this.pitchInRadians),Z(this._cameraPosition,this._cameraPosition,s,-this.bearingInRadians),j(this._cameraPosition,this._cameraPosition,[0,0,1]),q(this._cameraPosition,this._cameraPosition,s,-this.center.lat*Math.PI/180),V(this._cameraPosition,this._cameraPosition,s,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(e);let o=b(this._globeViewProjMatrixF64Inverted);A(o,o,[1,1,-1]),this._cachedFrustum=ev.fromInvProjectionMatrix(o,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){Lt("calculateFogMatrix is not supported on globe projection.");let e=ut();return x(e),e}getVisibleUnwrappedCoordinates(t){return[new Wm(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t?Lt("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(k(this._cameraPosition)-1)*Sc}getCameraLngLat(){let t=ht();return L(t,this._cameraPosition),ib(t)}populateCache(t){}getBounds(){let t=.5*this.width,e=.5*this.height,i=[new f(0,0),new f(t,0),new f(this.width,0),new f(this.width,e),new f(this.width,this.height),new f(t,this.height),new f(0,this.height),new f(0,e)],r=[];for(let t of i)r.push(this.unprojectScreenPoint(t));let n=0,s=0,o=0,a=0,l=this.center;for(let t of r){let e=yt(l.lng,t.lng),i=yt(l.lat,t.lat);e<s&&(s=e),e>n&&(n=e),i<a&&(a=i),i>o&&(o=i)}let h=[l.lng+s,l.lat+a,l.lng+n,l.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(h[3]=90,h[0]=-180,h[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(h[1]=-90,h[0]=-180,h[2]=180),new Um(h)}_getMaxLatitude(t){let e=Ht(4.948870999999997),i=tb(this.tileSize*Pt(t),Qt)*e,r=Math.min(this.width,this.height)/2,n=Math.min(i,r)*bt(i,r,4*r,1,0);return Qt+Yt(e*n/i)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}calculateCameraOptionsFromTo(t,e,i,r){let n=Cc.convert(i),s=Qw(Cc.convert(t));O(s,s,1+e/Sc);let o=Qw(n),a=O(ht(),o,1+r/Sc),l=R(ht(),s,o),h=k(l);if(h<1e-12||function(t,e){var i=e[0]-t[0],r=e[1]-t[1],n=e[2]-t[2];return Math.sqrt(i*i+r*r+n*n)}(s,a)<1e-12)throw Error("Can't calculate camera options with same From and To");let u=ht();V(l,l,u,-Ht(n.lng)),q(l,l,u,Ht(n.lat));let c=Yt(Math.acos(At(l[2]/h,-1,1))),f=Math.hypot(l[0],l[1])<1e-9*h?this.bearing:Yt(Math.atan2(-l[0],-l[1]));return{center:n,elevation:r,zoom:It(this.cameraToCenterDistance/h/tb(this.tileSize,n.lat)),pitch:c,bearing:f}}setLocationAtPoint(t,e,i){let r=Qw(this.unprojectScreenPoint(e)),n=Qw(t),s=ht();!function(t){t[0]=0,t[1]=0,t[2]=0}(s);let o=ht();V(o,r,s,-this.center.lng*Math.PI/180),q(o,o,s,this.center.lat*Math.PI/180);let a=n[0]*n[0]+n[2]*n[2],l=o[0]*o[0];if(a<l)return;let h=Math.sqrt(a-l),u=-h,c=gt(n[0],n[2],o[0],h),f=gt(n[0],n[2],o[0],u),p=ht();V(p,n,s,-c);let d=gt(p[1],p[2],o[1],o[2]),m=ht();V(m,n,s,-f);let _,g,y=gt(m[1],m[2],o[1],o[2]),v=.5*Math.PI,w=d>=-v&&d<=v,b=y>=-v&&y<=v;if(w&&b){let t=this.center.lng*Math.PI/180,e=this.center.lat*Math.PI/180;vt(c,t)+vt(d,e)<vt(f,t)+vt(y,e)?(_=c,g=d):(_=f,g=y)}else if(w)_=c,g=d;else{if(!b)return;_=f,g=y}let x=_/Math.PI*180,D=g/Math.PI*180,M=this.center.lat;this.setCenter(new Cc(x,At(D,-90,90))),this.setZoom(this.zoom+ob(M,this.center.lat))}locationToScreenPoint(t,e){let i=Qw(t);return e&&O(i,i,1+e.getElevationForLngLat(t,this)/Sc),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(t){let e=lt();return Y(e,[...t,1],this._globeViewProjMatrixF64),e[0]/=e[3],e[1]/=e[3],new f((.5*e[0]+.5)*this.width,(.5*-e[1]+.5)*this.height)}screenPointToMercatorCoordinate(t,e){if(e){let i=this.screenTerrainPointToMercatorCoordinate(t,e);if(i)return i}return Oc.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,e){let i=e.getCoverageIndex();if(!i)return null;let r=this.cameraPosition,n=this.getRayDirectionFromPixel(t),s=hb(r,n,1+i.maxElevation/Sc);if(!s)return null;let o=hb(r,n,1+i.minElevation/Sc),a=Math.max(s.tMin,0),l=o?o.tMin:s.tMax;if(l<=a)return null;let h={index:i,exaggeration:e.exaggeration,origin:r,direction:n},u=0;for(let t=0;t<=256;t++){let e=a+(l-a)*t/256;if(vb(h,e)){let{hi:t}=Ow(h,vb,u,e,1e-12),{sample:i,mercator:r}=yb(h,t);return new Oc(r.x,r.y,i.elevation)}u=e}return null}screenPointToLocation(t,e){return this.screenPointToMercatorCoordinate(t,e)?.toLngLat()}screenPointToLocationAtElevation(t,e){return this.screenPointToLocation(t)}isPointOnMapSurface(t,e){return!!hb(this._cameraPosition,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let e=lt();e[0]=t.x/this.width*2-1,e[1]=-1*(t.y/this.height*2-1),e[2]=1,e[3]=1,Y(e,e,this._globeViewProjMatrixF64Inverted),e[0]/=e[3],e[1]/=e[3],e[2]/=e[3];let i=ht();i[0]=e[0]-this._cameraPosition[0],i[1]=e[1]-this._cameraPosition[1],i[2]=e[2]-this._cameraPosition[2];let r=ht();return L(r,i),r}isSurfacePointVisible(t){let 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;let e=lt();return Y(e,[...t,1],this._globeViewProjMatrixF64),e[0]/=e[3],e[1]/=e[3],e[2]/=e[3],e[0]>-1&&e[0]<1&&e[1]>-1&&e[1]<1&&e[2]>-1&&e[2]<1}unprojectScreenPoint(t){let e=this._cameraPosition,i=this.getRayDirectionFromPixel(t),r=hb(e,i);if(r){let t=ht();j(t,e,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let n=ht();return L(n,t),ib(n)}let n=this._cachedClippingPlane,s=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=-dt(n,e)/s,a=ht();if(o>0)j(a,e,[i[0]*o,i[1]*o,i[2]*o]);else{let t=ht();j(t,e,[2*i[0],2*i[1],2*i[2]]);let r=dt(this._cachedClippingPlane,t);W(a,t,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(t){let e=ht();return e[0]=t[0]*-t[3],e[1]=t[1]*-t[3],e[2]=t[2]*-t[3],{center:e,radius:Math.sqrt(1-t[3]*t[3])}}(n);return ib(function(t,e,i){let r=ht();W(r,i,t);let n=ht();return B(n,t,r,e/H(r)),n}(l.center,l.radius,a))}getProjectionDataForCustomLayer(t=!0){let e=this.getProjectionData({overscaledTileID:new Hm(0,0,0,0,0),applyGlobeMatrix:t});return e.tileMercatorCoords=[0,0,1,1],e}getFastPathSimpleProjectionMatrix(t){}};function yb(t,e){let i=ht();B(i,t.origin,t.direction,e);let r=k(i),n=ht();O(n,i,1/r);let s=ib(n),o=Oc.fromLngLat(s),a=new Oc(o.x,At(o.y,0,.999999999)),l=jw(t.index,t.exaggeration,a.x,a.y),h=Math.abs(s.lat)>85.051129?0:l.elevation;return{sample:{...l,elevation:h},radius:r,mercator:a}}function vb(t,e){let{sample:i,radius:r}=yb(t,e);return Rw(i,(r-1)*Sc)}function wb(t,e){let i=Qw(t);return O(i,i,1+e/Sc)}function bb(t,e,i){return U(R(ht(),i,t),e)}var xb=class t{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){this._globeness=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(t){this._globeness=1,this.defaultConstrain=(t,e)=>this.currentTransform.defaultConstrain(t,e),this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new Tw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new Bw(void 0,this._helper),this._verticalPerspectiveTransform=new gb(void 0,this._helper)}clone(){let e=new t;return e._globeness=this._globeness,e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e)}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){let 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,clipAntimeridian:i.clipAntimeridian}}isLocationOccluded(t,e,i){return this.currentTransform.isLocationOccluded(t,e,i)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return xt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return xt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,e,i){return xt(this._mercatorTransform.getPitchedTextCorrection(t,e,i),this._verticalPerspectiveTransform.getPitchedTextCorrection(t,e,i),this._globeness)}projectTileCoordinates(t,e,i,r){return this.currentTransform.projectTileCoordinates(t,e,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform._calcMatrices(),this._mercatorTransform._calcMatrices(this.autoCalculateNearFarZ&&!this.isGlobeRendering))}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.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}calculateCameraOptionsFromTo(t,e,i,r){return this.currentTransform.calculateCameraOptionsFromTo(t,e,i,r)}setLocationAtPoint(t,e,i){this.currentTransform.setLocationAtPoint(t,e,i)}locationToScreenPoint(t,e){return this.currentTransform.locationToScreenPoint(t,e)}screenPointToMercatorCoordinate(t,e){return this.currentTransform.screenPointToMercatorCoordinate(t,e)}screenTerrainPointToMercatorCoordinate(t,e){return this.currentTransform.screenTerrainPointToMercatorCoordinate(t,e)}screenPointToLocation(t,e){return this.currentTransform.screenPointToLocation(t,e)}screenPointToLocationAtElevation(t,e){return this.currentTransform.screenPointToLocationAtElevation(t,e)}isPointOnMapSurface(t,e){return this.currentTransform.isPointOnMapSurface(t,e)}getRayDirectionFromPixel(t){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(t)}getProjectionDataForCustomLayer(t=!0){let e=this._mercatorTransform.getProjectionDataForCustomLayer(t);if(!this.isGlobeRendering)return e;let i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(t);return i.fallbackMatrix=e.mainMatrix,i.projectionTransition=this._globeness,i}getFastPathSimpleProjectionMatrix(t){return this.currentTransform.getFastPathSimpleProjectionMatrix(t)}},Db=class t{get useGlobeControls(){return!0}handlePanInertia(t,e){let i=function(t,e){let i=t.rotate(e.bearingInRadians),r=e.zoom+ob(e.center.lat,0),n=xt(1/sb(e.center.lat),1/sb(Math.min(Math.abs(e.center.lat),60)),bt(r,7,3,0,1)),s=function(t,e){return 360/Jw({worldSize:t,center:{lat:e}})}(e.worldSize,e.center.lat);return new Cc(e.center.lng-i.x*s*n,At(e.center.lat+i.y*s,-90,90))}(t,e);return Math.abs(i.lng-e.center.lng)>180&&(i.lng=e.center.lng+179.5*Math.sign(i.lng-e.center.lng)),{easingCenter:i,easingOffset:new f(0,0)}}handleMapControlsRollPitchBearingZoom(t,e){let i=t.around,r=e.screenPointToLocation(i);t.bearingDelta&&e.setBearing(e.bearing+t.bearingDelta),t.pitchDelta&&e.setPitch(e.pitch+t.pitchDelta),t.rollDelta&&e.setRoll(e.roll+t.rollDelta);let n=e.zoom;t.zoomDelta&&e.setZoom(e.zoom+t.zoomDelta);let s=e.zoom-n;if(0===s)return;let o=yt(e.center.lng,r.lng),a=o/(Math.abs(o/180)+1),l=yt(e.center.lat,r.lat),h=e.getRayDirectionFromPixel(i),u=e.cameraPosition,c=-1*U(u,h),f=ht();j(f,u,[h[0]*c,h[1]*c,h[2]*c]);let p=k(f),d=Math.exp(.5*-Math.max(p-1-.3,0)),m=bt(p,.95,.999,0,1),_=bt(tb(e.worldSize,e.center.lat)/Math.min(e.width,e.height),.9,.5,1,.25),g=Math.min(d,xt(1,_,m)),y=(1-Pt(-s))*g,v=e.center.lat,w=e.zoom,b=new Cc(e.center.lng+a*y,At(e.center.lat+l*y,-90,90));e.setLocationAtPoint(r,i);let x=e.center,D=bt(Math.abs(o),45,85,0,1),M=Math.max(D,m)**.25,E=yt(x.lng,b.lng),A=yt(x.lat,b.lat);e.setCenter(new Cc(x.lng+E*M,At(x.lat+A*M,-90,90)).wrap()),e.setZoom(w+ob(v,e.center.lat))}handleMapControlsPan(t,e,i){t.panDelta&&function(t,e,i,r,n=!0){let s=nb(t,i),o=e;if(r)o=nb(t,i.sub(r));else if(!t.isPointOnMapSurface(i))return;let a=Qw(s),l=Qw(o),h=function(t,e){return J(lt(),-t.lng,-t.lat,e)}(t.center,t.bearing),u=N(ht(),l,a),c=Math.sqrt(U(u,u)),f=Math.acos(At(U(l,a),-1,1))/2,p=Math.sin(f),d=c?K(u[1]/c*p,-u[0]/c*p,u[2]/c*p,Math.cos(f)):K(0,0,0,1),{lng:m,lat:_,bearing:g}=function(t){let e=t[0],i=t[1],r=t[2],n=t[3];return{lng:180*-Math.atan2(2*(n*e+i*r),1-2*(e*e+i*i))/Math.PI,lat:180*-Math.asin(At(2*(n*i-r*e),-1,1))/Math.PI,bearing:180*Math.atan2(2*(n*r+e*i),1-2*(i*i+r*r))/Math.PI}}(function(t,e,i){var r=e[0],n=e[1],s=e[2],o=e[3],a=i[0],l=i[1],h=i[2],u=i[3];return t[0]=r*u+o*a+n*h-s*l,t[1]=n*u+o*l+s*a-r*h,t[2]=s*u+o*h+r*l-n*a,t[3]=o*u-r*a-n*l-s*h,t}(lt(),h,d)),y=t.center.lat,v=t.zoom,w=n?function(t,e,i){return Math.abs(yt(t.bearing,i))<=90?e:e>0?90:-90}(t,_,g):_,b=n?function(t,e,i,r){let n=t.center.lng,s=t.center.lat,o=s>=0?90:-90,a=t.locationToScreenPoint(new Cc(0,o)),l=e.x-a.x,h=e.y-a.y,u=l*l+h*h,c=At(1-(Qt-Math.abs(s))/12,0,1),f=c*c*(3-2*c),p=wt(r-n+180,360)-180,d=0;return f>0&&i&&(d=(o>0?1:-1)*((l*i.y-h*i.x)/Math.max(u,400))*180/Math.PI),n+(1-f)*p+f*d}(t,i,r,m):m;t.setCenter(new Cc(Ft(b,-180,180),w)),n||t.setBearing(g),t.setZoom(v+ob(y,t.center.lat))}(e,i,e.isPointOnMapSurface(t.around)?t.around:e.centerPoint,t.panDelta)}cameraForBoxAndBearing(e,i,r,n,s,o){let a=Vw(e,i,r,n,s,o);if(!a)return;let l=i.left/o.width*2-1,h=(o.width-i.right)/o.width*2-1,u=i.top/o.height*-2+1,c=(o.height-i.bottom)/o.height*-2+1,f=yt(n.getWest(),n.getEast())<0,p=f?n.getEast():n.getWest(),d=f?n.getWest():n.getEast(),m=Math.max(n.getNorth(),n.getSouth()),_=Math.min(n.getNorth(),n.getSouth()),g=p+.5*yt(p,d),y=m+.5*yt(m,_),v=o.clone();v.setCenter(a.center),v.setPadding(r),v.setBearing(a.bearing),v.setPitch(0),v.setRoll(0),v.setZoom(a.zoom);let w=v.modelViewProjectionMatrix,b=[Qw(n.getNorthWest()),Qw(n.getNorthEast()),Qw(n.getSouthWest()),Qw(n.getSouthEast()),Qw(new Cc(d,y)),Qw(new Cc(p,y)),Qw(new Cc(g,m)),Qw(new Cc(g,_))],x=Qw(a.center),D=1/0;for(let e of b)l<0&&(D=t.getLesserNonNegativeNonNull(D,t.solveVectorScale(e,x,w,"x",l))),h>0&&(D=t.getLesserNonNegativeNonNull(D,t.solveVectorScale(e,x,w,"x",h))),u>0&&(D=t.getLesserNonNegativeNonNull(D,t.solveVectorScale(e,x,w,"y",u))),c<0&&(D=t.getLesserNonNegativeNonNull(D,t.solveVectorScale(e,x,w,"y",c)));if(Number.isFinite(D)&&0!==D)return a.zoom=Math.min(v.zoom+It(D),e.maxZoom),a;Gw()}handleJumpToCenterZoom(t,e){let i=t.center.lat,r=e.center?Cc.convert(e.center):t.center;t.setCenter(t.applyConstrain(r,t.zoom).center.wrap());let n=void 0===e.zoom?t.zoom+ob(i,t.center.lat):+e.zoom;t.zoom!==n&&(t.setZoom(n),t.setCenter(t.applyConstrain(r,t.zoom).center.wrap()))}handleEaseTo(t,e){let i=t.zoom,r=t.center,n=t.padding,s={roll:t.roll,pitch:t.pitch,bearing:t.bearing},o={roll:void 0===e.roll?t.roll:e.roll,pitch:void 0===e.pitch?t.pitch:e.pitch,bearing:void 0===e.bearing?t.bearing:e.bearing},a=void 0!==e.zoom,l=!t.isPaddingEqual(e.padding),h=!1,u=e.center?Cc.convert(e.center):r,c=t.applyConstrain(u,a?+e.zoom:i).center;Cw(t,c);let p=t.clone();p.setCenter(c),p.setZoom(a?+e.zoom:i+ob(r.lat,u.lat)),p.setBearing(e.bearing);let d=new f(At(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),At(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(c,d);let m=(e.offset&&e.offsetAsPoint.mag())>0?p.center:c,_=a?+e.zoom:i+ob(r.lat,m.lat),g=i+ob(r.lat,0),y=_+ob(m.lat,0),v=yt(r.lng,m.lng),w=yt(r.lat,m.lat),b=Pt(y-g);return h=_!==i,{easeFunc:i=>{if(Xt(s,o)||qw({startEulerAngles:s,endEulerAngles:o,tr:t,k:i,useSlerp:s.roll!=o.roll}),l&&t.interpolatePadding(n,e.padding,i),e.around)Lt("Easing around a point is not supported under globe projection."),t.setLocationAtPoint(e.around,e.aroundPoint);else{let e=i*(y>g?Math.min(2,b):Math.max(.5,b))**(1-i),n=lb(r,v,w,e);t.setCenter(n.wrap())}if(h){let e=Sr.number(g,y,i)+ob(0,t.center.lat);t.setZoom(e)}1===i&&!e.around&&t.setCenter(m.wrap())},isZooming:h,elevationCenter:m}}handleFlyTo(t,e){let i=void 0!==e.zoom,r=t.center,n=t.zoom,s=t.padding,o=!t.isPaddingEqual(e.padding),a=t.applyConstrain(Cc.convert(e.center||e.locationAtOffset),i?+e.zoom:n).center,l=i?+e.zoom:t.zoom+ob(t.center.lat,a.lat),h=t.clone();h.setCenter(a),h.setZoom(l),h.setBearing(e.bearing);let u=new f(At(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),At(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));h.setLocationAtPoint(a,u);let c=h.center;Cw(t,c);let p=function(t,e,i){let r=At(U(Qw(e),Qw(i)),-1,1),n=Math.acos(r),s=Jw(t);return n/(2*Math.PI)*s}(t,r,c),d=n+ob(r.lat,0),m=l+ob(c.lat,0),_=Pt(m-d),g=Math.max("number"==typeof e.minZoom?+e.minZoom:t.minZoom,t.minZoom)+ob(c.lat,0),y=Math.min(g,d,m)+ob(0,c.lat),v=Pt(t.applyConstrain(c,y).zoom+ob(c.lat,0)-d),w=yt(r.lng,c.lng),b=yt(r.lat,c.lat);return{easeFunc:(i,n,a)=>{let h=lb(r,w,b,a);o&&t.interpolatePadding(s,e.padding,i);let u=1===i?c:h;t.setCenter(u.wrap());let f=d+It(n);t.setZoom(1===i?l:f+ob(0,u.lat)),1===i&&t.setCenter(c.wrap())},scaleOfZoom:_,targetCenter:c,scaleOfMinZoom:v,pixelPathLength:p}}static solveVectorScale(t,e,i,r,n){let s="x"===r?[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]*s[0]+t[1]*s[1]+t[2]*s[2],l=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],h=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],u=e[0]*o[0]+e[1]*o[1]+e[2]*o[2];return h+n*l===a+n*u||o[3]*(a-h)+s[3]*(u-l)+a*u==h*l?null:(h+s[3]-n*u-n*o[3])/(h-a-n*u+n*l)}static getLesserNonNegativeNonNull(t,e){return null!==e&&e>=0&&e<t?e:t}},Mb=class{constructor(t){this._globe=t,this._mercatorCameraHelper=new Zw,this._verticalPerspectiveCameraHelper=new Db}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,r,n,s){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,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 Eb=function(){let t={},e=Ke.$version;for(let i in Ke.$root){let r=Ke.$root[i];if(r.required){let n=null;n="version"===i?e:"array"===r.type?[]:{},null!=n&&(t[i]=n)}}return t}();var Ab=class extends Re{constructor(t,e={}){super(),this._rtlPluginLoaded=()=>{for(let t in this.tileManagers){let e=this.tileManagers[t].getSource().type;("vector"===e||"geojson"===e)&&this.tileManagers[t].reload()}},this.map=t,this.dispatcher=new km(Im(),t._getMapId()).setEventedParent(this),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 im,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver),this.patternAtlas=new rm(this.imageManager);let i=t._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new ym(t._requestManager,e.localIdeographFontFamily,i),this.lineAtlas=new Mm(256,512),this.crossTileSymbolIndex=new bw,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",Ae()),Yy().on(Zy,this._rtlPluginLoaded),this.on("data",(t=>{if("source"!==t.dataType||"metadata"!==t.sourceDataType)return;let e=this.tileManagers[t.sourceId];if(!e)return;let i=e.getSource();if(i?.vectorLayerIds)for(let t in this._layers){let e=this._layers[t];e.source===i.id&&this._validateLayer(e)}}))}_setInitialValues(){this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new Jo,this._imagesListDirty=!1,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._symbolPlacementTriggered=!1,this._placedProjectionTransition=void 0,this.crossTileSymbolIndex=new(this.crossTileSymbolIndex?.constructor||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(t,e){this._checkLoaded();let i=null===e?this.stylesheet.state?.[t]?.default??null:e;return this._setGlobalStateValues({[t]:i}),this}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let e={};for(let i in t)e[i]=t[i].default;this._setGlobalStateValues(e)}_setGlobalStateValues(t){let e=[];for(let i in t)Rt(t[i],this._globalState[i])||e.push(i);if(0===e.length)return;let i={...this._globalState};for(let i of e)this._globalState[i]=t[i];this._applyGlobalStateChanges(e,i)}_applyGlobalStateChanges(t,e){let i=new Set,r={};for(let e of t)r[e]=this._globalState[e];for(let r in this._layers){let n=this._layers[r];n.retainPriorGlobalState(t,e);let s=n.getLayoutAffectingGlobalStateRefs(),o=n.getPaintAffectingGlobalStateRefs(),a=n.getVisibilityAffectingGlobalStateRefs();for(let e of t){if(s.has(e)&&i.add(n.source),o.has(e))for(let{name:t,value:i}of o.get(e))this._updatePaintProperty(n,t,i,{validate:!1});a?.has(e)&&(n.recalculateVisibility(),this._updateLayer(n))}}let n={now:de(),transition:this.getTransition()};this.light?.applyGlobalStateChange(t,e,n),this.sky?.applyGlobalStateChange(t,e,n),this.dispatcher.broadcast("UGS",r);for(let t in this.tileManagers)i.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,e={},i){this.fire(new Ue("dataloading")),e.validate="boolean"!=typeof e.validate||e.validate,this._loadStyleRequest=new AbortController;let r=this._loadStyleRequest;try{let n=await this.map._requestManager.transformRequest(t,"Style");le(r.signal);let s=await Se(n,r);this._loadStyleRequest===r&&(this._loadStyleRequest=null),this._load(s.data,e,i)}catch(t){this._loadStyleRequest===r&&(this._loadStyleRequest=null),t&&!r.signal.aborted&&this.fire(new je(at(t)))}}loadJSON(t,e={},i){this.fire(new Ue("dataloading")),this._frameRequest=new AbortController,fe.frameAsync(this._frameRequest,this.map._ownerWindow).then((()=>{this._frameRequest=null,e.validate=!1!==e.validate,this._load(t,e,i)})).catch((()=>{}))}loadEmpty(){this.fire(new Ue("dataloading")),this._load(Eb,{validate:!1})}_load(t,e,i){let r=e.transformStyle?e.transformStyle(i,t):t;if(!e.validate||!Lo(this,r)){r={...r},this._loaded=!0,this.stylesheet=r;for(let t in r.sources)this.addSource(t,r.sources[t],{validate:!1});r.sprite?this._loadSprite(r.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(r.glyphs),this.glyphManager.setFontFaces(r["font-faces"]),this._createLayers(),this.light=new wm(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new xm(this.stylesheet.sky,this._globalState),this.sky.setEventedParent(this),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new Ue("data")),this.fire(new Le)}}_createLayers(){let t=ei(this.stylesheet.layers);this.setGlobalState(this.stylesheet.state??null),this.dispatcher.broadcast("SL",t),this._order=t.map((t=>t.id)),this._layers={},this._serializedLayers=null;for(let e of t){let t=Qd(e,this._globalState);if(t.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=t,wa(t)&&this.tileManagers[t.source]){let i=e.paint?.["raster-fade-duration"]??t.paint.get("raster-fade-duration");this.tileManagers[t.source].setRasterFadeDuration(i)}}}async _loadSprite(t,e=!1,i){this.imageManager.setLoaded(!1);let r,n=new AbortController;this._spriteRequest=n;try{let i=await async function(t,e,i,r){let n=tm(t),s=i>1?"@2x":"",o={},a={};for(let{id:t,url:i}of n){let n=await e.transformRequest(em(i,s,".json"),"SpriteJSON");o[t]=Se(n,r);let l=await e.transformRequest(em(i,s,".png"),"SpriteImage");a[t]=Te.getImage(l,r)}return await Promise.all([...Object.values(o),...Object.values(a)]),async function(t,e){let i={};for(let r in t){i[r]={};let n=(await e[r]).data;if(!n)throw Error(`Could not load sprite image for ${r}: the response is empty`);let s=fe.getImageCanvasContext(n),o=(await t[r]).data;for(let t in o){let{width:e,height:n,x:a,y:l,sdf:h,pixelRatio:u,stretchX:c,stretchY:f,content:p,textFitWidth:d,textFitHeight:m}=o[t];i[r][t]={data:null,pixelRatio:u,sdf:h,stretchX:c,stretchY:f,content:p,textFitWidth:d,textFitHeight:m,spriteData:{width:e,height:n,x:a,y:l,context:s}}}}return i}(o,a)}(t,this.map._requestManager,this.map.getPixelRatio(),n);if(!i)return;for(let t in i){let{loaded:r,removed:n}=this.imageManager.setSpriteImages(t,i[t]);this._markImagesChanged(n),e&&this._markImagesChanged(r)}}catch(t){r=t,n.signal.aborted||this.fire(new je(r))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),e&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new Ue("data")),i?.(r)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new Ue("data"))}_validateLayer(t){let e=this.tileManagers[t.source];if(!e)return;let i=t.sourceLayer;if(!i)return;let r=e.getSource();("geojson"===r.type||r.vectorLayerIds&&!r.vectorLayerIds.includes(i))&&this.fire(new je(Error(`Source layer "${i}" does not exist on source "${r.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(let t in this.tileManagers)if(!this.tileManagers[t].loaded())return!1;return this.imageManager.isLoaded()}_serializeByIds(t,e=!1){let i=this._serializedAllLayers();if(!t||0===t.length)return Object.values(e?Ot(i):i);let r=[];for(let n of t)if(i[n]){let t=e?Ot(i[n]):i[n];r.push(t)}return r}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};let e=Object.keys(this._layers);for(let i of e){let e=this._layers[i];"custom"!==e.type&&(t[i]=e.serialize())}return t}hasTransitions(){if(this.light?.hasTransition()||this.sky?.hasTransition()||this.projection?.hasTransition())return!0;for(let t in this.tileManagers)if(this.tileManagers[t].hasTransition())return!0;for(let t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw Error("Style is not done loading.")}update(t){if(!this._loaded)return;let e=this._changed;if(e){this._imagesListDirty&&=(this.dispatcher.broadcast("SI",this.imageManager.listImages()),!1);let e=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(e.length||i.length)&&this._updateWorkerLayers(e,i);for(let t in this._updatedSources){let e=this._updatedSources[t];if("reload"===e)this._reloadSource(t);else{if("clear"!==e)throw Error(`Invalid action ${e}`);this._clearSource(t)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(let e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this._resetUpdates()}let i={};for(let t in this.tileManagers){let e=this.tileManagers[t];i[t]=e.used,e.used=!1}let r=this.imageManager.listImages();for(let e of this._order){let i=this._layers[e];i.recalculate(t,r),!i.isHidden(t.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(let t in i){let e=this.tileManagers[t];!!i[t]!=!!e.used&&e.fire(new Ne("data",{sourceDataType:"visibility",sourceId:t}))}this.light.recalculate(t),this.sky.recalculate(t),this.projection.recalculate(t),this.z=t.zoom,e&&this.fire(new Ue("data"))}_updateTilesForChangedImages(){let t=Object.keys(this._changedImages);if(t.length){for(let e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(let 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})}resize(){for(let t of this._order)this._layers[t].resize()}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,e={}){this._checkLoaded();let i=this.serialize();if(t=e.transformStyle?e.transformStyle(i,t):t,(e.validate??1)&&Lo(this,t))return!1;(t=Ot(t)).layers=ei(t.layers);let r=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!ii(t.version,e.version))return[{command:"setStyle",args:[e]}];ii(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),ii(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),ii(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),ii(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),ii(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),ii(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),ii(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),ii(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),ii(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),ii(t["font-faces"],e["font-faces"])||i.push({command:"setFontFaces",args:[e["font-faces"]]}),ii(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),ii(t.light,e.light)||i.push({command:"setLight",args:[e.light]});let r=!ii(t.terrain,e.terrain);r&&!e.terrain&&i.push({command:"setTerrain",args:[void 0]}),ii(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),ii(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});let n={},s=[];!function(t,e,i,r){let n;for(n in t||={},e||={},t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)||si(n,i,r));for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)?ii(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&ai(t,e,n)?ri(i,{command:"setGeoJSONSourceData",args:[n,e[n].data]}):oi(n,e,i,r)):ni(n,e,i))}(t.sources,e.sources,s,n);let o=[];t.layers&&t.layers.forEach((t=>{"source"in t&&n[t.source]?i.push({command:"removeLayer",args:[t.id]}):o.push(t)})),i=i.concat(s),function(t,e,i){t||=[],e||=[];let r,n,s,o,a,l=t.map(ui),h=e.map(ui),u=t.reduce(ci,{}),c=e.reduce(ci,{}),f=l.slice(),p=Object.create(null);for(let t=0,e=0;t<l.length;t++)r=l[t],Object.prototype.hasOwnProperty.call(c,r)?e++:(ri(i,{command:"removeLayer",args:[r]}),f.splice(f.indexOf(r,e),1));for(let t=0,e=0;t<h.length;t++)r=h[h.length-1-t],f[f.length-1-t]!==r&&(Object.prototype.hasOwnProperty.call(u,r)?(ri(i,{command:"removeLayer",args:[r]}),f.splice(f.lastIndexOf(r,f.length-e),1)):e++,o=f[f.length-t],ri(i,{command:"addLayer",args:[c[r],o]}),f.splice(f.length-t,0,r),p[r]=!0);for(let t=0;t<h.length;t++)if(r=h[t],n=u[r],s=c[r],!p[r]&&!ii(n,s)){if(!ii(n.source,s.source)||!ii(n["source-layer"],s["source-layer"])||!ii(n.type,s.type)){ri(i,{command:"removeLayer",args:[r]}),o=f[f.lastIndexOf(r)+1],ri(i,{command:"addLayer",args:[s,o]});continue}for(a in hi(n.layout,s.layout,i,r,"setLayoutProperty"),hi(n.paint,s.paint,i,r,"setPaintProperty"),ii(n.filter,s.filter)||ri(i,{command:"setFilter",args:[r,s.filter]}),(!ii(n.minzoom,s.minzoom)||!ii(n.maxzoom,s.maxzoom))&&ri(i,{command:"setLayerZoomRange",args:[r,s.minzoom,s.maxzoom]}),n)Object.prototype.hasOwnProperty.call(n,a)&&"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?hi(n[a],s[a],i,r,"setPaintProperty"):ii(n[a],s[a])||ri(i,{command:"setLayerProperty",args:[r,a,s[a]]}));for(a in s)Object.prototype.hasOwnProperty.call(s,a)&&!Object.prototype.hasOwnProperty.call(n,a)&&"layout"!==a&&"paint"!==a&&"filter"!==a&&"metadata"!==a&&"minzoom"!==a&&"maxzoom"!==a&&(0===a.indexOf("paint.")?hi(n[a],s[a],i,r,"setPaintProperty"):ii(n[a],s[a])||ri(i,{command:"setLayerProperty",args:[r,a,s[a]]}))}}(o,e.layers,i),r&&e.terrain&&i.push({command:"setTerrain",args:[e.terrain]})}catch(t){console.warn("Unable to compute style diff:",t),i=[{command:"setStyle",args:[e]}]}return i}(i,t),n=this._getOperationsToPerform(r);if(n.unimplemented.length>0)throw Error(`Unimplemented: ${n.unimplemented.join(", ")}.`);if(0===n.operations.length)return!1;for(let t of n.operations)t();return this.stylesheet=t,this._serializedLayers=null,this.fire(new Le({style:this})),!0}_getOperationsToPerform(t){let e=[],i=[];for(let r of t)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":{let[t,i]=r.args;e.push((()=>this.addLayer(t,i)));break}case"removeLayer":{let[t]=r.args;e.push((()=>this.removeLayer(t)));break}case"setPaintProperty":{let[t,i,n]=r.args;e.push((()=>this.setPaintProperty(t,i,n)));break}case"setLayoutProperty":{let[t,i,n]=r.args;e.push((()=>this.setLayoutProperty(t,i,n)));break}case"setFilter":{let[t,i]=r.args;e.push((()=>this.setFilter(t,i)));break}case"addSource":{let[t,i]=r.args;e.push((()=>this.addSource(t,i)));break}case"removeSource":{let[t]=r.args;e.push((()=>this.removeSource(t)));break}case"setLayerZoomRange":{let[t,i,n]=r.args;e.push((()=>this.setLayerZoomRange(t,i,n)));break}case"setLight":{let[t]=r.args;e.push((()=>this.setLight(t)));break}case"setGeoJSONSourceData":{let[t,i]=r.args;e.push((()=>this.setGeoJSONSourceData(t,i)));break}case"setGlyphs":{let[t]=r.args;e.push((()=>this.setGlyphs(t)));break}case"setFontFaces":{let[t]=r.args;e.push((()=>this.setFontFaces(t)));break}case"setSprite":{let[t]=r.args;e.push((()=>this.setSprite(t)));break}case"setTerrain":{let[t]=r.args;e.push((()=>this.map.setTerrain(t)));break}case"setSky":{let[t]=r.args;e.push((()=>this.setSky(t)));break}case"setProjection":{let[t]=r.args;e.push((()=>this.setProjection(t)));break}case"setGlobalState":{let[t]=r.args;e.push((()=>this.setGlobalState(t)));break}case"setTransition":e.push((()=>{}));break;default:i.push(r.command)}return{operations:e,unimplemented:i}}addImage(t,e){this.getImage(t)?this.fire(new je(Error(`An image named "${t}" already exists.`))):(this.imageManager.addImage(t,e),this._afterImageUpdated(t))}updateImage(t,e){this.imageManager.updateImage(t,e)}getImage(t){return this.imageManager.getImage(t)}setMissingImageResolver(t){this.imageManager.setMissingImageResolver(t)}removeImage(t){this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t)):this.fire(new je(Error(`An image named "${t}" does not exist.`)))}_markImagesChanged(t){for(let e of t)this._changedImages[e]=!0}_afterImageUpdated(t){this._changedImages[t]=!0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Ue("data"))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,e,i={}){if(this._checkLoaded(),void 0!==this.tileManagers[t])throw Error(`Source "${t}" already exists.`);if(!e.type)throw Error(`The type property must be defined, but only the following properties were given: ${Object.keys(e).join(", ")}.`);if(Bo.has(e.type)&&this._validate(Oo.source,`sources.${t}`,e,null,i))return;this.map?._collectResourceTiming&&(e.collectResourceTiming=!0);let r=this.tileManagers[t]=new _v(t,e,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 Error(`There is no source with this ID=${t}`);for(let e in this._layers)if(this._layers[e].source===t)return this.fire(new je(Error(`Source "${t}" cannot be removed while layer "${e}" is using it.`)));let e=this.tileManagers[t];delete this.tileManagers[t],delete this._updatedSources[t],e.fire(new Ne("data",{sourceDataType:"metadata",sourceId:t})),e.setEventedParent(null),e.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,e){if(this._checkLoaded(),void 0===this.tileManagers[t])throw Error(`There is no source with this ID=${t}`);let i=this.tileManagers[t].getSource();if("geojson"!==i.type)throw Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(e),this._changed=!0}getSource(t){return this.tileManagers[t]?.getSource()}addLayer(t,e,i={}){this._checkLoaded();let r,n=t.id;if(this.getLayer(n))return void this.fire(new je(Error(`Layer "${n}" already exists on this map.`)));if("custom"===t.type){if(Uo(this,function(t){let e=[],i=t.id;return void 0===i&&e.push(new fi(`layers.${i}`,null,'missing required property "id"')),void 0===t.render&&e.push(new fi(`layers.${i}`,null,'missing required method "render"')),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push(new fi(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),e}(t)))return;r=Qd(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(n,t.source),t=St(t=Ot(t),{source:n})),this._validate(Oo.layer,`layers.${n}`,t,{arrayIndex:-1},i))return;r=Qd(t,this._globalState),this._validateLayer(r),r.setEventedParent(this,{layer:{id:n}})}let s=e?this._order.indexOf(e):this._order.length;if(e&&-1===s)this.fire(new je(Error(`Cannot add layer "${n}" before non-existing layer "${e}".`)));else{if(this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=r,this._removedLayers[n]&&r.source&&"custom"!==r.type){let t=this._removedLayers[n];delete this._removedLayers[n],t.type===r.type?(this._updatedSources[r.source]="reload",this.tileManagers[r.source].pause()):this._updatedSources[r.source]="clear"}this._updateLayer(r),r.onAdd&&r.onAdd(this.map)}}moveLayer(t,e){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new je(Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===e)return;if(e&&!this._order.includes(e))return void this.fire(new je(Error(`Cannot move layer "${t}" before non-existing layer "${e}".`)));let i=this._order.indexOf(t);this._order.splice(i,1);let r=e?this._order.indexOf(e):this._order.length;this._order.splice(r,0,t),this._layerOrderChanged=!0}removeLayer(t){this._checkLoaded();let e=this._layers[t];if(!e)return void this.fire(new je(Error(`Cannot remove non-existing layer "${t}".`)));e.setEventedParent(null);let i=this._order.indexOf(t);this._order.splice(i,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=e,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],"symbol"===e.type&&e.source&&this.tileManagers[e.source]?.resetMaxContentElevation(),e.onRemove&&e.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,e,i){this._checkLoaded();let r=this.getLayer(t);r?(r.minzoom!==e||r.maxzoom!==i)&&(null!=e&&(r.minzoom=e),null!=i&&(r.maxzoom=i),this._updateLayer(r)):this.fire(new je(Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,e,i={}){this._checkLoaded();let r=this.getLayer(t);if(r){if(!Rt(r.filter,e)){if(null==e)return r.setFilter(void 0),void this._updateLayer(r);this._validate(Oo.filter,`layers.${r.id}.filter`,e,null,i)||(r.setFilter(Ot(e)),this._updateLayer(r))}}else this.fire(new je(Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return Ot(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();let n=this.getLayer(t);n?Rt(n.getLayoutProperty(e),i)||(n.setLayoutProperty(e,i,r),this._updateLayer(n)):this.fire(new je(Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){let i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new je(Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();let n=this.getLayer(t);n?Rt(n.getPaintProperty(e),i)||this._updatePaintProperty(n,e,i,r):this.fire(new je(Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,e,i,r={}){t.setPaintProperty(e,i,r)&&this._updateLayer(t),wa(t)&&"raster-fade-duration"===e&&this.tileManagers[t.source].setRasterFadeDuration(i),this._changed=!0,this._updatedPaintProps[t.id]=!0,"symbol"===t.type&&this.triggerSymbolPlacement(),this._serializedLayers=null}getPaintProperty(t,e){return this.getLayer(t).getPaintProperty(e)}setFeatureState(t,e){this._checkLoaded();let i=t.source,r=t.sourceLayer,n=this.tileManagers[i];if(void 0===n)return void this.fire(new je(Error(`The source '${i}' does not exist in the map's style.`)));let s=n.getSource().type;if("geojson"===s&&r)return void this.fire(new je(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new je(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===t.id)return void this.fire(new je(Error("The feature id parameter must be provided.")));let o=["__proto__","constructor","prototype"];e&&Object.keys(e).some((t=>o.includes(t)))?this.fire(new je(Error(`The feature state should not include one of the following keys: ${o}`))):n.setFeatureState(r,t.id,e)}removeFeatureState(t,e){this._checkLoaded();let i=t.source,r=this.tileManagers[i];if(void 0===r)return void this.fire(new je(Error(`The source '${i}' does not exist in the map's style.`)));let n=r.getSource().type,s="vector"===n?t.sourceLayer:void 0;"vector"!==n||s?e&&"string"!=typeof t.id&&"number"!=typeof t.id?this.fire(new je(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,t.id,e):this.fire(new je(Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();let e=t.source,i=t.sourceLayer,r=this.tileManagers[e];if(void 0!==r){if("vector"!==r.getSource().type||i)return void 0===t.id&&this.fire(new je(Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id);this.fire(new je(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new je(Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return St({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=$t(this.tileManagers,(t=>t.serialize())),e=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return jt({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,"font-faces":r["font-faces"],transition:r.transition,projection:r.projection,state:r.state,sources:t,layers:e,terrain:i},(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){let e=t=>"fill-extrusion"===this._layers[t].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){let s=this._order[n];if(e(s)){i[s]=n;for(let e of t){let t=e[s];if(t)for(let e of t)r.push(e)}}}r.sort(((t,e)=>e.intersectionZ-t.intersectionZ));let n=[];for(let s=this._order.length-1;s>=0;s--){let o=this._order[s];if(e(o))for(let t=r.length-1;t>=0;t--){let e=r[t].feature;if(i[e.layer.id]<s)break;n.push(e),r.pop()}else for(let e of t){let t=e[o];if(t)for(let e of t)n.push(e.feature)}}return n}queryRenderedFeatures(t,e,i){e?.filter&&this._validate(Oo.filter,"queryRenderedFeatures.filter",e.filter,null,e);let r={};if(e?.layers){if(!(Array.isArray(e.layers)||e.layers instanceof Set))return this.fire(new je(Error("parameters.layers must be an Array or a Set of strings"))),[];for(let t of e.layers){let e=this._layers[t];if(!e)return this.fire(new je(Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];r[e.source]=!0}}let n=[];e.availableImages=this.imageManager.listImages();let s=this._serializedAllLayers(),o=e.layers instanceof Set?e.layers:Array.isArray(e.layers)?new Set(e.layers):null,a={...e,layers:o,globalState:this._globalState};for(let o in this.tileManagers)(!e.layers||r[o])&&n.push(Rm(this.tileManagers[o],this._layers,s,t,a,i,this.map.terrain?(t,e,i)=>this.map.terrain.getElevation(t,e,i):void 0));return this.placement&&n.push(function(t,e,i,r,n,s,o){let a={},l=s.queryRenderedSymbols(r),h=[];for(let t of Object.keys(l).map(Number))h.push(o[t]);h.sort(Om);for(let i of h){let r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],e,i.bucketIndex,i.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,t);for(let t in r){a[t]||=[];let e=r[t];e.sort(((t,e)=>{let r=i.featureSortOrder;if(r){let i=r.indexOf(t.featureIndex);return r.indexOf(e.featureIndex)-i}return e.featureIndex-t.featureIndex}));for(let i of e)a[t].push(i)}}return function(t,e,i){for(let r in t)for(let n of t[r])Bm(n,i[e[r].source]);return t}(a,t,i)}(this._layers,s,this.tileManagers,t,a,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(n)}querySourceFeatures(t,e){e?.filter&&this._validate(Oo.filter,"querySourceFeatures.filter",e.filter,null,e);let i=this.tileManagers[t];return i?function(t,e){let i=t.getRenderableIds().map((e=>t.getTileByID(e))),r=[],n={};for(let t of i){let i=t.tileID.canonical.key;n[i]||(n[i]=!0,t.querySourceFeatures(r,e))}return r}(i,e?{...e,globalState:this._globalState}:{globalState:this._globalState}):[]}getLight(){return this.light.getLight()}setLight(t,e={}){this._checkLoaded();let i=this.light.getLight(),r=!1;for(let e in t)if(!Rt(t[e],i[e])){r=!0;break}if(!r)return;let n={now:de(),transition:St({duration:300,delay:0},this.stylesheet.transition)};this.light.setLight(t,e),this.light.updateTransitions(n)}getProjection(){return this.stylesheet?.projection}setProjection(t){this._checkLoaded();let e=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(){return this.stylesheet?.sky}setSky(t,e={}){this._checkLoaded();let i=this.getSky(),r=!1;if(!t&&!i)return;if(t&&!i)r=!0;else if(!t&&i)r=!0;else for(let e in t)if(!Rt(t[e],i[e])){r=!0;break}if(!r)return;let n={now:de(),transition:St({duration:300,delay:0},this.stylesheet.transition)};this.sky.setSky(t,e)&&(this.stylesheet.sky=t,this.sky.updateTransitions(n))}_setProjectionInternal(t){let e=function(t,e,i){let r={constrainOverride:e};if(Array.isArray(t)){let e=new Xw({type:t},i);return{projection:e,transform:new xb(r),cameraHelper:new Mb(e)}}switch(t){case"mercator":return{projection:new Fw,transform:new Bw(r),cameraHelper:new Zw};case"globe":{let t=new Xw({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:t,transform:new xb(r),cameraHelper:new Mb(t)}}case"vertical-perspective":return{projection:new Yw,transform:new gb(r),cameraHelper:new Db};default:return Lt(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new Fw,transform:new Bw(r),cameraHelper:new Zw}}}(t,this.map._camera?.transform.constrainOverride,this._globalState);this.projection=e.projection,this.map.migrateProjection(e.transform,e.cameraHelper);for(let t in this.tileManagers)this.tileManagers[t].reload()}_validate(t,e,i,r,n={}){return!1!==n.validate&&No(this,t,{key:e,style:this.serialize(),value:i,...r},n)}_remove(t=!0){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null),Yy().off(Zy,this._rtlPluginLoaded);for(let t in this._layers)this._layers[t].setEventedParent(null);for(let t in this.tileManagers){let 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(let e in this.tileManagers)this.tileManagers[e].update(t,this.map.terrain)}_generateCollisionBoxes(){for(let t in this.tileManagers)this._reloadSource(t)}triggerSymbolPlacement(){this._symbolPlacementTriggered=!0}_placementInputsChanged(t,e,i){let r=this.pauseablePlacement;return!r||this._symbolPlacementTriggered||this._placedProjectionTransition!==this.projection?.transitionState||r._showCollisionBoxes!==e||r.placement.collisionGroups.crossSourceCollisions!==i||r.placement.transform.renderWorldCopies!==t.renderWorldCopies||!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]}(r.placement.transform.modelViewProjectionMatrix,t.modelViewProjectionMatrix)}_updatePlacement(t,e,i,r,n=!1){let s=!1,o=!1,a={};for(let e of this._order){let i=this._layers[e];if("symbol"!==i.type)continue;if(!a[i.source]){let 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)))}let r=this.crossTileSymbolIndex.addLayer(i,a[i.source],t.center.lng);s||=r}this.crossTileSymbolIndex.pruneUnusedLayers(this._order),n||=this._layerOrderChanged||0===i;let l=s||this._placementInputsChanged(t,e,r),h=this.pauseablePlacement?.isDone()&&!this.placement.stillRecent(de(),t.zoom);if((n||!this.pauseablePlacement||h&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new lw(t,this.map.terrain,this._order,n,e,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?l&&this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(de()),o=!0),s&&this.pauseablePlacement.placement.setStale()),o||s)for(let t of this._order){let e=this._layers[t];"symbol"===e.type&&this.placement.updateLayerOpacities(e,a[e.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(de())}_releaseSymbolFadeTiles(){for(let t in this.tileManagers)this.tileManagers[t].releaseSymbolFadeTiles()}async getImages(t,e){let i=await this.imageManager.getImages(e.icons);this._updateTilesForChangedImages();let r=this.tileManagers[e.source];return r&&r.setDependencies(e.tileID.key,e.type,e.icons),i}async getGlyphs(t,e){let i=await this.glyphManager.getGlyphs(e.stacks),r=this.tileManagers[e.source];return r&&r.setDependencies(e.tileID.key,e.type,[""]),i}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,e={}){this._checkLoaded(),(!t||!this._validate(Oo.glyphs,"glyphs",t,null,e))&&(this._changed=!0,this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}getFontFaces(){return this.stylesheet["font-faces"]||null}setFontFaces(t){this._checkLoaded(),this._changed=!0,this._glyphsDidChange=!0,this.stylesheet["font-faces"]=t,this.glyphManager.setFontFaces(t)}async getDashes(t,e){let i={};for(let[t,r]of Object.entries(e.dashes))i[t]=this.lineAtlas.getDash(r.dasharray,r.round);return i}addSprite(t,e,i={},r){this._checkLoaded();let n=[{id:t,url:e}],s=[...tm(this.stylesheet.sprite),...n];this._validate(Oo.sprite,"sprite",s,null,i)||(this.stylesheet.sprite=s,this._loadSprite(n,!0,r))}removeSprite(t){this._checkLoaded();let e=tm(this.stylesheet.sprite);if(!e.find((e=>e.id===t)))return void this.fire(new je(Error(`Sprite "${t}" doesn't exists on this map.`)));let i=this.imageManager.removeSpriteImages(t);this._markImagesChanged(i),e.splice(e.findIndex((e=>e.id===t)),1),this.stylesheet.sprite=e.length>0?e:void 0,this._imagesListDirty=!0,this._changed=!0,this.fire(new Ue("data"))}getSprite(){return tm(this.stylesheet.sprite)}setSprite(t,e={},i){this._checkLoaded(),(!t||!this._validate(Oo.sprite,"sprite",t,null,e))&&(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,i):(this._unloadSprite(),i&&i(null)))}destroy(){this._frameRequest&&=(this._frameRequest.abort(),null),this._loadStyleRequest&&=(this._loadStyleRequest.abort(),null),this._spriteRequest&&=(this._spriteRequest.abort(),null);for(let t in this.tileManagers){let e=this.tileManagers[t];e.setEventedParent(null),e.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this.patternAtlas.destroy()),this.glyphManager&&this.glyphManager.destroy();for(let t in this._layers){let 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={}}};const Fb=Ea([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var Sb=class{constructor(t,e,i){this.context=t;let r=t.gl;this.buffer=r.createBuffer(),this.dynamicDraw=!!i,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let e=this.context.gl;if(!this.dynamicDraw)throw 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 Cb={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};var zb=class{constructor(t,e,i,r){this.length=e.length,this.attributes=i,this.itemSize=e.bytesPerElement,this.dynamicDraw=r,this.context=t;let n=t.gl;this.buffer=n.createBuffer(),t.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,e.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||e.freeBufferAfterUpload()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);let e=this.context.gl;this.bind(),e.bufferSubData(e.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,e){for(let i of this.attributes){let r=e.attributes[i.name];void 0!==r&&t.enableVertexAttribArray(r.location)}}setVertexAttribPointers(t,e,i){for(let r of this.attributes){let n=e.attributes[r.name];if(void 0!==n){let e=r.offset+this.itemSize*(i||0);n.isInteger?t.vertexAttribIPointer(n.location,r.components,t[Cb[r.type]],this.itemSize,e):t.vertexAttribPointer(n.location,r.components,t[Cb[r.type]],!1,this.itemSize,e)}}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}},Tb=class{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)}},Pb=class extends Tb{getDefault(){return nr.transparent}set(t){let 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)}},Ib=class extends Tb{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},kb=class extends Tb{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},$b=class extends Tb{getDefault(){return[!0,!0,!0,!0]}set(t){let 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)}},jb=class extends Tb{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},Rb=class extends Tb{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},Ob=class extends Tb{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let 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)}},Bb=class extends Tb{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let 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)}},Lb=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this.current=t,this.dirty=!1}},Ub=class extends Tb{getDefault(){return[0,1]}set(t){let 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)}},Nb=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this.current=t,this.dirty=!1}},Gb=class extends Tb{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},qb=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.BLEND):e.disable(e.BLEND),this.current=t,this.dirty=!1}},Vb=class extends Tb{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let 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)}},Zb=class extends Tb{getDefault(){return nr.transparent}set(t){let 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)}},Wb=class extends Tb{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},Hb=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;t?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this.current=t,this.dirty=!1}},Yb=class extends Tb{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},Xb=class extends Tb{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},Jb=class extends Tb{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},Kb=class extends Tb{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},Qb=class extends Tb{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let 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)}},tx=class extends Tb{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindFramebuffer(e.FRAMEBUFFER,t),this.current=t,this.dirty=!1}},ex=class extends Tb{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindRenderbuffer(e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},ix=class extends Tb{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindTexture(e.TEXTURE_2D,t),this.current=t,this.dirty=!1}},rx=class extends Tb{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.bindBuffer(e.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},nx=class extends Tb{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},sx=class extends Tb{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},ox=class extends Tb{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}},ax=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}},lx=class extends Tb{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let e=this.gl;e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}},hx=class extends Tb{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}},ux=class extends hx{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}},cx=class extends hx{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},fx=class extends hx{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let e=this.gl;e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,t),this.current=t,this.dirty=!1}},px=class{constructor(t,e,i,r,n){this.context=t,this.width=e,this.height=i;let s=this.framebuffer=t.gl.createFramebuffer();if(this.colorAttachment=new ux(t,s),r)this.depthAttachment=n?new fx(t,s):new cx(t,s);else if(n)throw Error("Stencil cannot be set without depth")}destroy(){let t=this.context.gl,e=this.colorAttachment.get();if(e&&t.deleteTexture(e),this.depthAttachment){let e=this.depthAttachment.get();e&&t.deleteRenderbuffer(e)}t.deleteFramebuffer(this.framebuffer)}};const dx={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2},mx={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function _x(t){let e={},i=0;for(let{name:r,type:n}of t){let[t,s]=mx[n];i=Math.ceil(i/s)*s,e[r]=i,i+=t}return{offsets:e,contentWords:i,sizeWords:4*Math.ceil(i/4)}}var gx=class{constructor(t,e,i){this.context=t,this.binding=e,this.contentWords=i.contentWords;let r=t.gl;this.buffer=r.createBuffer(),r.bindBuffer(r.UNIFORM_BUFFER,this.buffer),r.bufferData(r.UNIFORM_BUFFER,4*i.sizeWords,r.DYNAMIC_DRAW),this.uploaded=new Float32Array(i.sizeWords),this.pending=new Float32Array(i.sizeWords),this.uploadedWords=new Uint32Array(this.uploaded.buffer),this.pendingWords=new Uint32Array(this.pending.buffer),this.hasData=!1}upload(){let t=this.context.gl,e=!this.hasData;if(!e){let t=this.pendingWords,i=this.uploadedWords;for(let r=0;r<this.contentWords;r++)if(t[r]!==i[r]){e=!0;break}}e?(t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),this.context.boundUniformBuffers[this.binding]=this.buffer,t.bufferData(t.UNIFORM_BUFFER,this.pending,t.DYNAMIC_DRAW),this.uploaded.set(this.pending),this.hasData=!0):this.bind()}bind(){let t=this.context.boundUniformBuffers;if(t[this.binding]===this.buffer)return;let e=this.context.gl;e.bindBufferBase(e.UNIFORM_BUFFER,this.binding,this.buffer),t[this.binding]=this.buffer}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}};const yx=_x([{name:"u_projection_matrix",type:"mat4"},{name:"u_projection_fallback_matrix",type:"mat4"},{name:"u_projection_tile_mercator_coords",type:"vec4"},{name:"u_projection_clipping_plane",type:"vec4"},{name:"u_projection_transition",type:"float"},{name:"u_projection_clip_antimeridian",type:"int"}]),vx=yx.offsets;function wx(t){return new gx(t,dx.ProjectionUBO,yx)}function bx(t,e){let i=t.pending;i.set(e.mainMatrix,vx.u_projection_matrix),i.set(e.fallbackMatrix,vx.u_projection_fallback_matrix),i.set(e.tileMercatorCoords,vx.u_projection_tile_mercator_coords),i.set(e.clippingPlane,vx.u_projection_clipping_plane),i[vx.u_projection_transition]=e.projectionTransition,t.pendingWords[vx.u_projection_clip_antimeridian]=+!!e.clipAntimeridian,t.upload()}const xx=_x([{name:"u_units_to_pixels",type:"vec2"},{name:"u_world_size",type:"vec2"},{name:"u_camera_to_center_distance",type:"float"},{name:"u_symbol_fade_change",type:"float"},{name:"u_aspect_ratio",type:"float"},{name:"u_device_pixel_ratio",type:"float"},{name:"u_viewport_size",type:"vec2"},{name:"u_pixel_extrude_scale",type:"vec2"},{name:"u_pitch",type:"float"}]),Dx=xx.offsets;function Mx(t,e,i){let r=t.pending;r[Dx.u_world_size]=e,r[Dx.u_world_size+1]=i,t.upload()}const Ex=_x([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),Ax=Ex.offsets;var Fx=class{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}};Fx.Replace=[1,0],Fx.disabled=new Fx(Fx.Replace,nr.transparent,[!1,!1,!1,!1]),Fx.unblended=new Fx(Fx.Replace,nr.transparent,[!0,!0,!0,!0]),Fx.alphaBlended=new Fx([1,771],nr.transparent,[!0,!0,!0,!0]);var Sx=class{constructor(t){this.gl=t,this.clearColor=new Pb(this),this.clearDepth=new Ib(this),this.clearStencil=new kb(this),this.colorMask=new $b(this),this.depthMask=new jb(this),this.stencilMask=new Rb(this),this.stencilFunc=new Ob(this),this.stencilOp=new Bb(this),this.stencilTest=new Lb(this),this.depthRange=new Ub(this),this.depthTest=new Nb(this),this.depthFunc=new Gb(this),this.blend=new qb(this),this.blendFunc=new Vb(this),this.blendColor=new Zb(this),this.blendEquation=new Wb(this),this.cullFace=new Hb(this),this.cullFaceSide=new Yb(this),this.frontFace=new Xb(this),this.program=new Jb(this),this.activeTexture=new Kb(this),this.viewport=new Qb(this),this.bindFramebuffer=new tx(this),this.bindRenderbuffer=new ex(this),this.bindTexture=new ix(this),this.bindVertexBuffer=new rx(this),this.bindElementBuffer=new nx(this),this.bindVertexArray=new sx(this),this.pixelStoreUnpack=new ox(this),this.pixelStoreUnpackPremultiplyAlpha=new ax(this),this.pixelStoreUnpackFlipY=new lx(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),t.getExtension("EXT_color_buffer_half_float"),t.getExtension("EXT_color_buffer_float"),this.boundUniformBuffers=[],this.projectionUniformBuffer=wx(this),this.keyedProjectionUniformBuffers=new Map,this.freeProjectionUniformBuffers=[],this.terrainUniformBuffer=function(t){return new gx(t,dx.TerrainUBO,Ex)}(this),this.frameUniformBuffer=function(t){return new gx(t,dx.FrameUBO,xx)}(this)}destroy(){(function(t){t.projectionUniformBuffer.destroy();for(let e of t.keyedProjectionUniformBuffers.values())e.destroy();for(let e of t.freeProjectionUniformBuffers)e.destroy()})(this),this.terrainUniformBuffer.destroy(),this.frameUniformBuffer.destroy()}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,this.boundUniformBuffers=[]}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(t,e){return new Sb(this,t,e)}createVertexBuffer(t,e,i){return new zb(this,t,e,i)}createRenderbuffer(t,e,i){let r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,t,e,i),this.bindRenderbuffer.set(null),n}createFramebuffer(t,e,i,r){return new px(this,t,e,i,r)}clear({color:t,depth:e,stencil:i}){let r=this.gl,n=0;t&&(n|=r.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),void 0!==e&&(n|=r.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(e),this.depthMask.set(!0)),void 0!==i&&(n|=r.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),r.clear(n)}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){Rt(t.blendFunction,Fx.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(){return this.gl.createVertexArray()}deleteVertexArray(t){this.gl.deleteVertexArray(t)}unbindVAO(){this.bindVertexArray.set(null)}},Cx=class{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,r,n,s,o,a,l){this.context=t;let h=this.boundPaintVertexBuffers.length!==r.length;for(let t=0;!h&&t<r.length;t++)this.boundPaintVertexBuffers[t]!==r[t]&&(h=!0);!this.vao||this.boundProgram!==e||this.boundLayoutVertexBuffer!==i||h||this.boundIndexBuffer!==n||this.boundVertexOffset!==s||this.boundDynamicVertexBuffer!==o||this.boundDynamicVertexBuffer2!==a||this.boundDynamicVertexBuffer3!==l?this.freshBind(e,i,r,n,s,o,a,l):t.bindVertexArray.set(this.vao)}freshBind(t,e,i,r,n,s,o,a){let l=t.numAttributes,h=this.context,u=h.gl;this.vao&&this.destroy(),this.vao=h.createVertexArray(),h.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=e,this.boundPaintVertexBuffers=i,this.boundIndexBuffer=r,this.boundVertexOffset=n,this.boundDynamicVertexBuffer=s,this.boundDynamicVertexBuffer2=o,this.boundDynamicVertexBuffer3=a,e.enableAttributes(u,t);for(let e of i)e.enableAttributes(u,t);s&&s.enableAttributes(u,t),o&&o.enableAttributes(u,t),a&&a.enableAttributes(u,t),e.bind(),e.setVertexAttribPointers(u,t,n);for(let e of i)e.bind(),e.setVertexAttribPointers(u,t,n);s&&(s.bind(),s.setVertexAttribPointers(u,t,n)),r&&r.bind(),o&&(o.bind(),o.setVertexAttribPointers(u,t,n)),a&&(a.bind(),a.setVertexAttribPointers(u,t,n)),h.currentNumAttributes=l}destroy(){this.vao&&=(this.context.deleteVertexArray(this.vao),null)}};const zx=(t,e,i,r,n)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:e,u_fog_color:i?i["fog-color"]:nr.white,u_fog_ground_blend:i?i["fog-ground-blend"]:1,u_fog_ground_blend_opacity:n?0:i?Dm(r):0,u_horizon_color:i?i["horizon-color"]:nr.white,u_horizon_fog_blend:i?i["horizon-fog-blend"]:1,u_is_globe_mode:+!!n}),Tx=t=>({u_ele_delta:t}),Px=t=>({u_tile_bounds:t});function Ix(t){let e=[];for(let i of t){if(null===i)continue;let t=i.split(" ");e.push(t.pop())}return e}var kx=class{constructor(t,e,i,r,n,s,o,a,l=[]){let h=t.gl;this.program=h.createProgram();let u=Ix(e.staticAttributes),c=i?i.getBinderAttributes():[],f=u.concat(c),p=Dw.prelude.staticUniforms?Ix(Dw.prelude.staticUniforms):[],d=e.staticUniforms?Ix(e.staticUniforms):[],m=i?i.getBinderUniforms():[],_=p.concat(d).concat(m),g=[];for(let t of _)g.includes(t)||g.push(t);let y=i?i.defines():[];y.unshift("#version 300 es"),n&&y.push("#define OVERDRAW_INSPECTOR;"),s&&y.push("#define TERRAIN3D;"),a&&y.push(a),l&&y.push(...l);let v=y.concat(Dw.prelude.fragmentSource,o.fragmentSource,e.fragmentSource).join("\n"),w=y.concat(Dw.prelude.vertexSource,o.vertexSource,e.vertexSource).join("\n"),b=h.createShader(h.FRAGMENT_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);h.shaderSource(b,v),h.compileShader(b),h.attachShader(this.program,b);let x=h.createShader(h.VERTEX_SHADER);if(h.isContextLost())return void(this.failedToCreate=!0);h.shaderSource(x,w),h.compileShader(x),h.attachShader(this.program,x),this.attributes={};let D={};if(this.numAttributes=f.length,h.linkProgram(this.program),!h.getProgramParameter(this.program,h.LINK_STATUS)){if(h.isContextLost()||0===h.getProgramParameter(this.program,h.ATTACHED_SHADERS))return void(this.failedToCreate=!0);throw h.getShaderParameter(b,h.COMPILE_STATUS)?h.getShaderParameter(x,h.COMPILE_STATUS)?Error(`Program failed to link: ${h.getProgramInfoLog(this.program)}`):Error(`Could not compile vertex shader: ${h.getShaderInfoLog(x)}`):Error(`Could not compile fragment shader: ${h.getShaderInfoLog(b)}`)}!function(t,e){for(let[i,r]of Object.entries(dx)){let n=t.getUniformBlockIndex(e,i);n!==t.INVALID_INDEX&&t.uniformBlockBinding(e,n,r)}}(h,this.program);let M=function(t,e){let i=new Set([t.INT,t.INT_VEC2,t.INT_VEC3,t.INT_VEC4,t.UNSIGNED_INT,t.UNSIGNED_INT_VEC2,t.UNSIGNED_INT_VEC3,t.UNSIGNED_INT_VEC4]),r=new Set,n=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){let n=t.getActiveAttrib(e,s);n&&i.has(n.type)&&r.add(n.name)}return r}(h,this.program);for(let t of f){if(!t)continue;let e=h.getAttribLocation(this.program,t);e>=0&&(this.attributes[t]={location:e,isInteger:M.has(t)})}h.deleteShader(x),h.deleteShader(b);for(let t of g)if(t&&!D[t]){let e=h.getUniformLocation(this.program,t);e&&(D[t]=e)}this.fixedUniforms=r(t,D),this.terrainUniforms=((t,e)=>({u_depth:new Nl(t,e.u_depth),u_terrain:new Nl(t,e.u_terrain)}))(t,D),this.binderUniforms=i?i.getUniforms(t,D):[]}draw(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m,_,g,y){let v=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.terrainUniformBuffer.bind(),t.frameUniformBuffer.bind(),t.setDepthMode(i),t.setStencilMode(r),t.setColorMode(n),t.setCullFace(s),a){t.activeTexture.set(v.TEXTURE2),v.bindTexture(v.TEXTURE_2D,a.depthTexture),t.activeTexture.set(v.TEXTURE3),v.bindTexture(v.TEXTURE_2D,a.texture);for(let t in this.terrainUniforms)this.terrainUniforms[t].set(a[t]);!function(t,e){let i=t.pending;i.set(e.u_terrain_matrix,Ax.u_terrain_matrix),i.set(e.u_terrain_unpack,Ax.u_terrain_unpack),i[Ax.u_terrain_dim]=e.u_terrain_dim,i[Ax.u_terrain_exaggeration]=e.u_terrain_exaggeration,t.upload()}(t.terrainUniformBuffer,a)}if(function(t,e){if(!e)return void t.projectionUniformBuffer.bind();let i=e.uniformBufferKey;if(void 0===i)return void bx(t.projectionUniformBuffer,e);let r=t.keyedProjectionUniformBuffers.get(i);if(r)return void r.bind();let n=t.freeProjectionUniformBuffers.pop()??wx(t);t.keyedProjectionUniformBuffers.set(i,n),bx(n,e)}(t,l),o)for(let t in this.fixedUniforms)this.fixedUniforms[t].set(o[t]);m&&m.setUniforms(t,this.binderUniforms,p,{zoom:d});let w=0;switch(e){case v.LINES:w=2;break;case v.TRIANGLES:w=3;break;case v.LINE_STRIP:w=1}for(let i of f.get())i.vaos||={},i.vaos[h]||=new Cx,i.vaos[h].bind(t,this,u,m?m.getPaintVertexBuffers():[],c,i.vertexOffset,_,g,y),v.drawElements(e,i.primitiveLength*w,v.UNSIGNED_SHORT,i.primitiveOffset*w*2)}};function $x(t,e,i){let r=1/ot(i,1,e.frameRenderContext.transform.tileZoom),n=2**i.tileID.overscaledZ,s=i.tileSize*2**e.frameRenderContext.transform.tileZoom/n,o=s*(i.tileID.canonical.x+i.tileID.wrap*n),a=s*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture.size,u_scale:[r,t.fromScale,t.toScale],u_fade:t.t,u_pixel_coord_upper:[o>>16,a>>16],u_pixel_coord_lower:[65535&o,65535&a]}}const jx=(t,e,i,r,n)=>{let s=Gt(e.position),o=v();"viewport"===e.anchor&&function(t,e){var i=Math.sin(e),r=Math.cos(e);t[0]=r,t[1]=i,t[2]=0,t[3]=-i,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1}(o,t.frameRenderContext.transform.bearingInRadians),function(t,e,i){var r=e[0],n=e[1],s=e[2];t[0]=r*i[0]+n*i[3]+s*i[6],t[1]=r*i[1]+n*i[4]+s*i[7],t[2]=r*i[2]+n*i[5]+s*i[8]}(s,s,o);let a=t.frameRenderContext.transform.transformLightDirection(s),l=e.color;return{u_lightpos:s,u_lightpos_globe:a,u_lightintensity:e.intensity,u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},Rx=(t,e,i,r,n,s,o,a)=>St(jx(t,e,i,r,n),$x(o,t,a),{u_height_factor:-(2**s.overscaledZ)/a.tileSize/8}),Ox=(t,e,i,r,n)=>St($x(e,t,i),{u_fill_translate:r,u_sdf_pattern:+!!n}),Bx=t=>({u_fill_translate:t}),Lx=t=>({u_fill_translate:t}),Ux=(t,e,i,r,n)=>Ox(t,e,i,r,n),Nx=(t,e,i,r,n)=>{let s,o,a=t.frameRenderContext.transform,l=0;if("map"===i.paint.get("circle-pitch-alignment")){let t=ot(e,1,a.zoom);s=!0,o=[t,t],l=t/(st*2**e.tileID.overscaledZ)*2*Math.PI*n}else s=!1,o=a.pixelsToGLUnits;return{u_scale_with_map:+("map"===i.paint.get("circle-pitch-scale")),u_pitch_with_map:+s,u_extrude_scale:o,u_globe_extrude_scale:l,u_translate:r}},Gx=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),qx=(t,e,i,r)=>{let n=ot(t,1,e)/(st*2**t.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:ot(t,1,e),u_intensity:i,u_globe_extrude_scale:n}},Vx=(t,e,i,r)=>{let n=w();return T(n,0,t.width,t.height,0,0,1),{u_matrix:n,u_image:i,u_color_ramp:r,u_opacity:e.paint.get("heatmap-opacity")}},Zx=(t,e,i)=>{let r,n=i.paint.get("hillshade-accent-color");switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}let s=i.getIlluminationProperties();for(let e=0;e<s.directionRadians.length;e++)"viewport"===i.paint.get("hillshade-illumination-anchor")&&(s.directionRadians[e]+=t.frameRenderContext.transform.bearingInRadians);return{u_image:0,u_latrange:Hx(0,e.tileID),u_exaggeration:i.paint.get("hillshade-exaggeration"),u_altitudes:s.altitudeRadians,u_azimuths:s.directionRadians,u_accent:n,u_method:r,u_highlights:s.highlightColor,u_shadows:s.shadowColor}},Wx=(t,e)=>{let i=e.stride,r=w();return T(r,0,st,-8192,0,0,1),E(r,r,[0,-8192,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}};function Hx(t,e){let i=2**e.canonical.z,r=e.canonical.y;return[new Oc(0,r/i).toLngLat().lat,new Oc(0,(r+1)/i).toLngLat().lat]}const Yx=(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")}),Xx=(t,e,i,r)=>{let n=t.frameRenderContext.transform;return{u_translation:iD(t,e,i),u_ratio:r/ot(e,1,n.zoom)}},Jx=(t,e,i,r,n)=>St(Xx(t,e,i,r),{u_image:0,u_image_height:n}),Kx=(t,e,i,r,n)=>{let s=t.frameRenderContext.transform,o=eD(e,s);return{u_translation:iD(t,e,i),u_texsize:e.imageAtlasTexture.size,u_ratio:r/ot(e,1,s.zoom),u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t}},Qx=(t,e,i,r,n)=>{let s=eD(e,t.frameRenderContext.transform);return St(Xx(t,e,i,r),{u_tileratio:s,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image:0,u_mix:n.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})},tD=(t,e,i,r,n,s)=>{let o=eD(e,t.frameRenderContext.transform);return St(Xx(t,e,i,r),{u_image:0,u_image_height:s,u_tileratio:o,u_crossfade_from:n.fromScale,u_crossfade_to:n.toScale,u_image_dash:1,u_mix:n.t,u_lineatlas_width:t.lineAtlas.width,u_lineatlas_height:t.lineAtlas.height})};function eD(t,e){return 1/ot(t,1,e.tileZoom)}function iD(t,e,i){return pt(t.frameRenderContext.transform,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const rD=(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d)=>({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_rotate_symbol:+i,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:s,u_texsize:c,u_texture:0,u_translation:h,u_pitched_scale:f,u_is_offset:p,u_height_anchor_ground:+d}),nD=(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m)=>{let _=o.frameRenderContext.transform;return St(rD(t,e,i,r,n,s,0,a,l,h,u,c,p,d,m),{u_gamma_scale:r?Math.cos(_.pitch*Math.PI/180)*_.cameraToCenterDistance:1,u_is_halo:+!!f,u_is_plain:1})},sD=(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d)=>St(nD(t,e,i,r,n,s,o,a,l,h,!0,u,!0,f,p,d),{u_texsize_icon:c,u_texture_icon:1}),oD=(t,e)=>({u_opacity:t,u_color:e}),aD=(t,e,i,r,n)=>St(function(t,e,i,r){let n=i.patternAtlas.getPattern(t.from.toString()),s=i.patternAtlas.getPattern(t.to.toString()),{width:o,height:a}=i.patternAtlas.getPixelSize(),l=2**r.tileID.overscaledZ,h=r.tileSize*2**i.frameRenderContext.transform.tileZoom/l,u=h*(r.tileID.canonical.x+r.tileID.wrap*l),c=h*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:n.tl,u_pattern_br_a:n.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[o,a],u_mix:e.t,u_pattern_size_a:n.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:e.fromScale,u_scale_b:e.toScale,u_tile_units_to_pixels:1/ot(r,1,i.frameRenderContext.transform.tileZoom),u_pixel_coord_upper:[u>>16,c>>16],u_pixel_coord_lower:[65535&u,65535&c]}}(i,n,e,r),{u_opacity:t}),lD=()=>({}),hD={fillExtrusion:(t,e)=>({u_lightpos:new Vl(t,e.u_lightpos),u_lightpos_globe:new Vl(t,e.u_lightpos_globe),u_lightintensity:new Gl(t,e.u_lightintensity),u_lightcolor:new Vl(t,e.u_lightcolor),u_vertical_gradient:new Gl(t,e.u_vertical_gradient),u_opacity:new Gl(t,e.u_opacity),u_fill_translate:new ql(t,e.u_fill_translate)}),fillExtrusionPattern:(t,e)=>({u_lightpos:new Vl(t,e.u_lightpos),u_lightpos_globe:new Vl(t,e.u_lightpos_globe),u_lightintensity:new Gl(t,e.u_lightintensity),u_lightcolor:new Vl(t,e.u_lightcolor),u_vertical_gradient:new Gl(t,e.u_vertical_gradient),u_height_factor:new Gl(t,e.u_height_factor),u_opacity:new Gl(t,e.u_opacity),u_fill_translate:new ql(t,e.u_fill_translate),u_image:new Nl(t,e.u_image),u_texsize:new ql(t,e.u_texsize),u_pixel_coord_upper:new ql(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ql(t,e.u_pixel_coord_lower),u_scale:new Vl(t,e.u_scale),u_fade:new Gl(t,e.u_fade)}),fill:(t,e)=>({u_fill_translate:new ql(t,e.u_fill_translate)}),fillPattern:(t,e)=>({u_image:new Nl(t,e.u_image),u_texsize:new ql(t,e.u_texsize),u_pixel_coord_upper:new ql(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ql(t,e.u_pixel_coord_lower),u_scale:new Vl(t,e.u_scale),u_fade:new Gl(t,e.u_fade),u_sdf_pattern:new Nl(t,e.u_sdf_pattern),u_fill_translate:new ql(t,e.u_fill_translate)}),fillOutline:(t,e)=>({u_fill_translate:new ql(t,e.u_fill_translate)}),fillOutlinePattern:(t,e)=>({u_image:new Nl(t,e.u_image),u_texsize:new ql(t,e.u_texsize),u_pixel_coord_upper:new ql(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ql(t,e.u_pixel_coord_lower),u_scale:new Vl(t,e.u_scale),u_fade:new Gl(t,e.u_fade),u_sdf_pattern:new Nl(t,e.u_sdf_pattern),u_fill_translate:new ql(t,e.u_fill_translate)}),circle:(t,e)=>({u_scale_with_map:new Nl(t,e.u_scale_with_map),u_pitch_with_map:new Nl(t,e.u_pitch_with_map),u_extrude_scale:new ql(t,e.u_extrude_scale),u_globe_extrude_scale:new Gl(t,e.u_globe_extrude_scale),u_translate:new ql(t,e.u_translate)}),collisionBox:lD,collisionCircle:lD,debug:(t,e)=>({u_color:new Wl(t,e.u_color),u_overlay:new Nl(t,e.u_overlay),u_overlay_scale:new Gl(t,e.u_overlay_scale)}),depth:lD,clippingMask:lD,heatmap:(t,e)=>({u_extrude_scale:new Gl(t,e.u_extrude_scale),u_intensity:new Gl(t,e.u_intensity),u_globe_extrude_scale:new Gl(t,e.u_globe_extrude_scale)}),heatmapTexture:(t,e)=>({u_matrix:new Jl(t,e.u_matrix),u_image:new Nl(t,e.u_image),u_color_ramp:new Nl(t,e.u_color_ramp),u_opacity:new Gl(t,e.u_opacity)}),hillshade:(t,e)=>({u_image:new Nl(t,e.u_image),u_latrange:new ql(t,e.u_latrange),u_exaggeration:new Gl(t,e.u_exaggeration),u_altitudes:new Yl(t,e.u_altitudes),u_azimuths:new Yl(t,e.u_azimuths),u_accent:new Wl(t,e.u_accent),u_method:new Nl(t,e.u_method),u_shadows:new Hl(t,e.u_shadows),u_highlights:new Hl(t,e.u_highlights)}),hillshadePrepare:(t,e)=>({u_matrix:new Jl(t,e.u_matrix),u_image:new Nl(t,e.u_image),u_dimension:new ql(t,e.u_dimension),u_zoom:new Gl(t,e.u_zoom),u_unpack:new Zl(t,e.u_unpack)}),colorRelief:(t,e)=>({u_image:new Nl(t,e.u_image),u_unpack:new Zl(t,e.u_unpack),u_dimension:new ql(t,e.u_dimension),u_elevation_stops:new Nl(t,e.u_elevation_stops),u_color_stops:new Nl(t,e.u_color_stops),u_color_ramp_size:new Nl(t,e.u_color_ramp_size),u_opacity:new Gl(t,e.u_opacity)}),line:(t,e)=>({u_translation:new ql(t,e.u_translation),u_ratio:new Gl(t,e.u_ratio)}),lineGradient:(t,e)=>({u_translation:new ql(t,e.u_translation),u_ratio:new Gl(t,e.u_ratio),u_image:new Nl(t,e.u_image),u_image_height:new Gl(t,e.u_image_height)}),linePattern:(t,e)=>({u_translation:new ql(t,e.u_translation),u_texsize:new ql(t,e.u_texsize),u_ratio:new Gl(t,e.u_ratio),u_image:new Nl(t,e.u_image),u_scale:new Vl(t,e.u_scale),u_fade:new Gl(t,e.u_fade)}),lineSDF:(t,e)=>({u_translation:new ql(t,e.u_translation),u_ratio:new Gl(t,e.u_ratio),u_image:new Nl(t,e.u_image),u_mix:new Gl(t,e.u_mix),u_tileratio:new Gl(t,e.u_tileratio),u_crossfade_from:new Gl(t,e.u_crossfade_from),u_crossfade_to:new Gl(t,e.u_crossfade_to),u_lineatlas_width:new Gl(t,e.u_lineatlas_width),u_lineatlas_height:new Gl(t,e.u_lineatlas_height)}),lineGradientSDF:(t,e)=>({u_translation:new ql(t,e.u_translation),u_ratio:new Gl(t,e.u_ratio),u_image:new Nl(t,e.u_image),u_image_height:new Gl(t,e.u_image_height),u_tileratio:new Gl(t,e.u_tileratio),u_crossfade_from:new Gl(t,e.u_crossfade_from),u_crossfade_to:new Gl(t,e.u_crossfade_to),u_image_dash:new Nl(t,e.u_image_dash),u_mix:new Gl(t,e.u_mix),u_lineatlas_width:new Gl(t,e.u_lineatlas_width),u_lineatlas_height:new Gl(t,e.u_lineatlas_height)}),layerOpacity:(t,e)=>({u_image:new Nl(t,e.u_image),u_opacity:new Gl(t,e.u_opacity)}),raster:(t,e)=>({u_tl_parent:new ql(t,e.u_tl_parent),u_scale_parent:new Gl(t,e.u_scale_parent),u_buffer_scale:new Gl(t,e.u_buffer_scale),u_image_warp:new Vl(t,e.u_image_warp),u_fade_t:new Gl(t,e.u_fade_t),u_opacity:new Gl(t,e.u_opacity),u_image0:new Nl(t,e.u_image0),u_image1:new Nl(t,e.u_image1),u_brightness_low:new Gl(t,e.u_brightness_low),u_brightness_high:new Gl(t,e.u_brightness_high),u_saturation_factor:new Gl(t,e.u_saturation_factor),u_contrast_factor:new Gl(t,e.u_contrast_factor),u_spin_weights:new Vl(t,e.u_spin_weights),u_coords_top:new Zl(t,e.u_coords_top),u_coords_bottom:new Zl(t,e.u_coords_bottom)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new Nl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Nl(t,e.u_is_size_feature_constant),u_size_t:new Gl(t,e.u_size_t),u_size:new Gl(t,e.u_size),u_rotate_symbol:new Nl(t,e.u_rotate_symbol),u_label_plane_matrix:new Jl(t,e.u_label_plane_matrix),u_coord_matrix:new Jl(t,e.u_coord_matrix),u_is_text:new Nl(t,e.u_is_text),u_pitch_with_map:new Nl(t,e.u_pitch_with_map),u_is_along_line:new Nl(t,e.u_is_along_line),u_is_variable_anchor:new Nl(t,e.u_is_variable_anchor),u_texsize:new ql(t,e.u_texsize),u_texture:new Nl(t,e.u_texture),u_translation:new ql(t,e.u_translation),u_pitched_scale:new Gl(t,e.u_pitched_scale),u_is_offset:new Nl(t,e.u_is_offset),u_height_anchor_ground:new Nl(t,e.u_height_anchor_ground)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new Nl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Nl(t,e.u_is_size_feature_constant),u_size_t:new Gl(t,e.u_size_t),u_size:new Gl(t,e.u_size),u_rotate_symbol:new Nl(t,e.u_rotate_symbol),u_label_plane_matrix:new Jl(t,e.u_label_plane_matrix),u_coord_matrix:new Jl(t,e.u_coord_matrix),u_is_text:new Nl(t,e.u_is_text),u_pitch_with_map:new Nl(t,e.u_pitch_with_map),u_is_along_line:new Nl(t,e.u_is_along_line),u_is_variable_anchor:new Nl(t,e.u_is_variable_anchor),u_texsize:new ql(t,e.u_texsize),u_texture:new Nl(t,e.u_texture),u_gamma_scale:new Gl(t,e.u_gamma_scale),u_is_halo:new Nl(t,e.u_is_halo),u_is_plain:new Nl(t,e.u_is_plain),u_translation:new ql(t,e.u_translation),u_pitched_scale:new Gl(t,e.u_pitched_scale),u_is_offset:new Nl(t,e.u_is_offset),u_height_anchor_ground:new Nl(t,e.u_height_anchor_ground)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new Nl(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Nl(t,e.u_is_size_feature_constant),u_size_t:new Gl(t,e.u_size_t),u_size:new Gl(t,e.u_size),u_rotate_symbol:new Nl(t,e.u_rotate_symbol),u_label_plane_matrix:new Jl(t,e.u_label_plane_matrix),u_coord_matrix:new Jl(t,e.u_coord_matrix),u_is_text:new Nl(t,e.u_is_text),u_pitch_with_map:new Nl(t,e.u_pitch_with_map),u_is_along_line:new Nl(t,e.u_is_along_line),u_is_variable_anchor:new Nl(t,e.u_is_variable_anchor),u_texsize:new ql(t,e.u_texsize),u_texsize_icon:new ql(t,e.u_texsize_icon),u_texture:new Nl(t,e.u_texture),u_texture_icon:new Nl(t,e.u_texture_icon),u_gamma_scale:new Gl(t,e.u_gamma_scale),u_is_halo:new Nl(t,e.u_is_halo),u_translation:new ql(t,e.u_translation),u_pitched_scale:new Gl(t,e.u_pitched_scale),u_is_offset:new Nl(t,e.u_is_offset),u_height_anchor_ground:new Nl(t,e.u_height_anchor_ground)}),background:(t,e)=>({u_opacity:new Gl(t,e.u_opacity),u_color:new Wl(t,e.u_color)}),backgroundPattern:(t,e)=>({u_opacity:new Gl(t,e.u_opacity),u_image:new Nl(t,e.u_image),u_pattern_tl_a:new ql(t,e.u_pattern_tl_a),u_pattern_br_a:new ql(t,e.u_pattern_br_a),u_pattern_tl_b:new ql(t,e.u_pattern_tl_b),u_pattern_br_b:new ql(t,e.u_pattern_br_b),u_texsize:new ql(t,e.u_texsize),u_mix:new Gl(t,e.u_mix),u_pattern_size_a:new ql(t,e.u_pattern_size_a),u_pattern_size_b:new ql(t,e.u_pattern_size_b),u_scale_a:new Gl(t,e.u_scale_a),u_scale_b:new Gl(t,e.u_scale_b),u_pixel_coord_upper:new ql(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new ql(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new Gl(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_texture:new Nl(t,e.u_texture),u_ele_delta:new Gl(t,e.u_ele_delta),u_fog_matrix:new Jl(t,e.u_fog_matrix),u_fog_color:new Wl(t,e.u_fog_color),u_fog_ground_blend:new Gl(t,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new Gl(t,e.u_fog_ground_blend_opacity),u_horizon_color:new Wl(t,e.u_horizon_color),u_horizon_fog_blend:new Gl(t,e.u_horizon_fog_blend),u_is_globe_mode:new Gl(t,e.u_is_globe_mode)}),terrainDepth:(t,e)=>({u_ele_delta:new Gl(t,e.u_ele_delta)}),terrainHeight:(t,e)=>({u_tile_bounds:new Zl(t,e.u_tile_bounds)}),atmosphere:(t,e)=>({u_sun_pos:new Vl(t,e.u_sun_pos),u_atmosphere_blend:new Gl(t,e.u_atmosphere_blend),u_globe_position:new Vl(t,e.u_globe_position),u_globe_radius:new Gl(t,e.u_globe_radius),u_inv_proj_matrix:new Jl(t,e.u_inv_proj_matrix)}),sky:(t,e)=>({u_sky_color:new Wl(t,e.u_sky_color),u_horizon_color:new Wl(t,e.u_horizon_color),u_horizon:new ql(t,e.u_horizon),u_horizon_normal:new ql(t,e.u_horizon_normal),u_sky_horizon_blend:new Gl(t,e.u_sky_horizon_blend),u_sky_blend:new Gl(t,e.u_sky_blend),u_inv_proj_matrix:new Jl(t,e.u_inv_proj_matrix),u_globe_position:new Vl(t,e.u_globe_position),u_globe_radius:new Gl(t,e.u_globe_radius),u_atmosphere_blend:new Gl(t,e.u_atmosphere_blend)})};var uD=class{constructor(t){this.programs={},this.context=t}getProgram(t){let e=t.programConfiguration?t.programConfiguration.cacheKey:"",i=`/${t.projectionShaderVariant.name}`,r=t.showOverdrawInspector?"/overdraw":"",n=t.useTerrain?"/terrain":"",s=t.defines?`/${t.defines.join("/")}`:"",o=t.name+e+i+r+n+s;return this.programs[o]||=new kx(this.context,Dw[t.name],t.programConfiguration,hD[t.name],t.showOverdrawInspector,t.useTerrain,t.projectionShaderVariant.prelude,t.projectionShaderVariant.define,t.defines),this.programs[o]}destroy(){for(let t of Object.values(this.programs))t.program&&this.context.gl.deleteProgram(t.program);this.programs={}}};const cD=7680;var fD=class{constructor(t,e,i,r,n,s){this.test=t,this.ref=e,this.mask=i,this.fail=r,this.depthFail=n,this.pass=s}};fD.disabled=new fD({func:519,mask:0},0,0,cD,cD,cD);const pD=2305;var dD=class{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}};dD.disabled=new dD(!1,1029,pD),dD.backCCW=new dD(!0,1029,pD),dD.frontCCW=new dD(!0,1028,pD);var mD=class{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}};let _D;function gD(t,e,i,r,n,s){let o=t.context,a=o.gl,l=s.useProgram("collisionBox"),h=[],u=0,c=0;for(let t of r){let r=e.getTile(t).getBucket(i);if(!r)continue;let f=n?r.textCollisionBox:r.iconCollisionBox,p=r.collisionCircleArray;p.length>0&&(h.push({circleArray:p,circleOffset:c,coord:t}),u+=p.length/4,c=u),f&&l.draw(o,a.LINES,mD.disabled,fD.disabled,s.colorModeForRenderPass(),dD.disabled,null,s.getTerrainDataForTile(t),s.getProjectionDataForTile(t),i.id,f.layoutVertexBuffer,f.indexBuffer,f.segments,null,s.transform.zoom,null,null,f.collisionVertexBuffer)}if(!n||!h.length)return;let f=s.useProgram("collisionCircle"),p=new Dl;p.resize(4*u),p._trim();let d=0;for(let t of h)for(let e=0;e<t.circleArray.length/4;e++){let i=4*e,r=t.circleArray[i+0],n=t.circleArray[i+1],s=t.circleArray[i+2],o=t.circleArray[i+3];p.emplace(d++,r,n,s,o,0),p.emplace(d++,r,n,s,o,1),p.emplace(d++,r,n,s,o,2),p.emplace(d++,r,n,s,o,3)}(!_D||_D.length<2*u)&&(_D=function(t){let e=2*t,i=new El;i.resize(e),i._trim();for(let t=0;t<e;t++){let e=6*t;i.uint16[e+0]=4*t+0,i.uint16[e+1]=4*t+1,i.uint16[e+2]=4*t+2,i.uint16[e+3]=4*t+2,i.uint16[e+4]=4*t+3,i.uint16[e+5]=4*t+0}return i}(u));let m=o.createIndexBuffer(_D,!0),_=o.createVertexBuffer(p,Ef.members,!0);for(let t of h)f.draw(o,a.TRIANGLES,mD.disabled,fD.disabled,s.colorModeForRenderPass(),dD.disabled,null,s.getTerrainDataForTile(t.coord),null,i.id,_,m,zl.simpleSegment(0,2*t.circleOffset,t.circleArray.length,t.circleArray.length/2),null,s.transform.zoom,null,null,null);_.destroy(),m.destroy()}mD.ReadOnly=!1,mD.ReadWrite=!0,mD.disabled=new mD(519,mD.ReadOnly,[0,1]);const yD=x(new Float32Array(16));function vD(t,e,i,r,n,s){let{horizontalAlign:o,verticalAlign:a}=Up(t);return new f((-(o-.5)*e/n+r[0])*s,(-(a-.5)*i/n+r[1])*s)}function wD(t,e,i,r,n,s){let o=e.tileAnchorPoint.add(new f(e.translation[0],e.translation[1]));if(e.pitchWithMap){let t=r.mult(s);i||(t=t.rotate(-n));let a=o.add(t);return Fv(a.x,a.y,e.pitchedLabelPlaneMatrix,Av(e,a.x,a.y)).point}if(i){let i=jv(e.tileAnchorPoint.x+1,e.tileAnchorPoint.y,e).point.sub(t),n=Math.atan(i.y/i.x)+(i.x<0?Math.PI:0);return t.add(r.rotate(n))}return t.add(r)}function bD(t,e,i,r,n,s,o,a,l,h,u,c,p){let d=t.text.placedSymbolArray,m=t.text.dynamicLayoutVertexArray,_=t.icon.dynamicLayoutVertexArray,g={};m.clear();for(let _=0;_<d.length;_++){let y=d.get(_),v=y.hidden||!y.crossTileID||t.allowVerticalPlacement&&!y.placedOrientation?null:r[y.crossTileID];if(v){let r=new f(y.anchorX,y.anchorY),d={getElevation:c,heightOffset:y.heightOffset,heightAnchorGround:p,width:n.width,height:n.height,pitchedLabelPlaneMatrix:s,pitchWithMap:i,transform:n,tileAnchorPoint:r,translation:h,unwrappedTileID:u},_=i?Ov(r.x,r.y,d):jv(r.x,r.y,d),w=Sv(n.cameraToCenterDistance,_.signedDistanceFromCamera),b=rd(t.textSizeData,a,y)*w/24;i&&(b*=t.tilePixelRatio/o);let{width:x,height:D,anchor:M,textOffset:E,textBoxScale:A}=v,F=vD(M,x,D,E,A,b),S=n.getPitchedTextCorrection(r.x+h[0],r.y+h[1],u),C=wD(_.point,d,e,F,-n.bearingInRadians,S),z=t.allowVerticalPlacement&&2===y.placedOrientation?Math.PI/2:0;for(let t=0;t<y.numGlyphs;t++)Rd(m,C,z);l&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:C,angle:z})}else Gv(y.numGlyphs,m)}if(l){_.clear();let e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){let i=e.get(t);if(i.hidden)Gv(i.numGlyphs,_);else{let e=g[t];if(e)for(let t=0;t<i.numGlyphs;t++)Rd(_,e.shiftedAnchor,e.angle);else Gv(i.numGlyphs,_)}}t.icon.dynamicLayoutVertexBuffer.updateData(_)}t.text.dynamicLayoutVertexBuffer.updateData(m)}function xD(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function DD(t,e,i,r,n,s,o,a,l,h,u,c,f){let p=t.context,d=p.gl,m=f.transform,_="map"===a,g="map"===l,y="viewport"!==a&&"point"!==i.layout.get("symbol-placement"),v=_&&!g&&!y,b=!i.layout.get("symbol-sort-key").isConstant(),x=!1,D=f.getDepthModeForSublayer(0,mD.ReadOnly),M=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[],A=m.getCircleRadiusCorrection();for(let a of r){let r=e.getTile(a),l=r.getBucket(i);if(!l)continue;let u=n?l.text:l.icon;if(!u?.segments.get().length||!u.hasVisibleVertices)continue;let c,p,D,F,S=u.programConfigurations.get(i.id),C=n||l.sdfIcons,z=n?l.textSizeData:l.iconSizeData,T=g||0!==m.pitch,P=f.useProgram(xD(C,n,l),S),I=nd(z,m.zoom),k=f.getTerrainDataForTile(a),$=[0,0],j=null;if(n)p=r.glyphAtlasTexture,D=d.LINEAR,c=r.glyphAtlasTexture.size,l.iconsInText&&($=r.imageAtlasTexture.size,j=r.imageAtlasTexture,F=T||f.data.rotating||f.data.zooming||"composite"===z.kind||"camera"===z.kind?d.LINEAR:d.NEAREST);else{let t=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;p=r.imageAtlasTexture,D=C||f.data.rotating||f.data.zooming||t||T?d.LINEAR:d.NEAREST,c=r.imageAtlasTexture.size}let R=ot(r,1,f.transform.zoom),O=Dv(_,f.transform,R),B=Mv(g,_,f.transform,R),L=pt(m,r,s,o),U=f.getProjectionDataForTile(a),N=M&&l.hasTextData(),G="none"!==i.layout.get("icon-text-fit")&&N&&l.hasIconData(),q=i._unevaluatedLayout.hasValue("icon-offset"),V="ground"===i.layout.get("symbol-height-anchor");if(y){let e=w();bv(e,O);let r=f.terrain?(t,e)=>f.terrain.getElevation(a,t,e):void 0;zv(l,t,n,O,e,g,h,"map"===i.layout.get("text-rotation-alignment"),a.toUnwrapped(),m.width,m.height,L,r)}let Z,W=n&&M||G,H=y||W?yD:g?O:f.transform.clipSpaceToPixelsMatrix,Y=C&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);Z=C?l.iconsInText?sD(z.kind,I,v,g,y,W,t,H,B,L,c,$,A,q,V):nD(z.kind,I,v,g,y,W,t,H,B,L,n,c,Y,A,q,V):rD(z.kind,I,v,g,y,W,0,H,B,L,n,c,A,q,V);let X={program:P,buffers:u,uniformValues:Z,projectionData:U,atlasTexture:p,atlasTextureIcon:j,atlasInterpolation:D,atlasInterpolationIcon:F,isSDF:C,hasHalo:Y};if(b&&l.canOverlap){x=!0;let t=u.segments.get();for(let e of t)E.push({segments:new zl([e]),sortKey:e.sortKey,state:X,terrainData:k})}else E.push({segments:u.segments,sortKey:0,state:X,terrainData:k})}x&&E.sort(((t,e)=>t.sortKey-e.sortKey));let F=i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(null)??1/0,S=24*i.layout.get("text-letter-spacing").constantOr(0)<0||F>1;for(let e of E){let r=e.state;p.activeTexture.set(d.TEXTURE0),r.atlasTexture.bind(r.atlasInterpolation,d.CLAMP_TO_EDGE),r.atlasTextureIcon&&(p.activeTexture.set(d.TEXTURE1),r.atlasTextureIcon&&r.atlasTextureIcon.bind(r.atlasInterpolationIcon,d.CLAMP_TO_EDGE));let n=r.isSDF&&r.hasHalo;if(n){let n=r.uniformValues;n.u_is_halo=1,S&&(n.u_is_plain=0,MD(r.buffers,e.segments,i,t,r.program,D,u,c,n,r.projectionData,e.terrainData),n.u_is_halo=0,n.u_is_plain=1)}MD(r.buffers,e.segments,i,t,r.program,D,u,c,r.uniformValues,r.projectionData,e.terrainData),n&&!S&&(r.uniformValues.u_is_halo=0)}}function MD(t,e,i,r,n,s,o,a,l,h,u){let c=r.context;n.draw(c,c.gl.TRIANGLES,s,o,a,dD.backCCW,l,u,h,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.frameRenderContext.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function ED(t,e,i,r,n){let s=t.context,o=s.gl,a=fD.disabled,l=new Fx([o.ONE,o.ONE],nr.transparent,[!0,!0,!0,!0]),h=e.getBucket(i);if(!h)return;let u=r.key,c=i.heatmapFbos.get(u);c||(c=FD(s,e.tileSize,e.tileSize),i.heatmapFbos.set(u,c)),s.bindFramebuffer.set(c.framebuffer),s.viewport.set([0,0,e.tileSize,e.tileSize]),s.clear({color:nr.transparent});let f=h.programConfigurations.get(i.id),p=n.useProgram("heatmap",f,!n.data.isRenderingGlobe),d=n.getProjectionDataForTile(e.tileID),m=n.getTerrainDataForTile(r);p.draw(s,o.TRIANGLES,mD.disabled,a,l,dD.disabled,qx(e,n.transform.zoom,i.paint.get("heatmap-intensity"),1),m,d,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,n.transform.zoom,f)}function AD(t,e,i,r){let n=t.context,s=n.gl,o=r.transform;n.setColorMode(r.colorModeForRenderPass());let a=SD(n,e),l=i.key,h=e.heatmapFbos.get(l);if(!h)return;n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.colorAttachment.get()),n.activeTexture.set(s.TEXTURE1),a.bind(s.LINEAR,s.CLAMP_TO_EDGE);let u=r.getProjectionDataForTile(i,{applyTerrainMatrix:r.data.isRenderingGlobe});r.useProgram("heatmapTexture").draw(n,s.TRIANGLES,mD.disabled,fD.disabled,r.colorModeForRenderPass(),dD.disabled,Vx(t,e,0,1),null,u,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,o.zoom),h.destroy(),e.heatmapFbos.delete(l)}function FD(t,e,i){let r=t.gl,n=r.createTexture();r.bindTexture(r.TEXTURE_2D,n),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),r.texStorage2D(r.TEXTURE_2D,1,r.RGBA16F,e,i);let s=t.createFramebuffer(e,i,!1,!1);return s.colorAttachment.set(n),s}function SD(t,e){return e.colorRampTexture||=new au(t,e.colorRamp,t.gl.RGBA),e.colorRampTexture}function CD(t,e,i){let r=t.context,n=r.bindFramebuffer.get(),s=r.viewport.get(),[,,o,a]=s;return function(t,e,i){let r=t.context.gl;if(!t.layerOpacityFbo){let n=t.context.createFramebuffer(e,i,!0,!0),s=r.createTexture();return r.bindTexture(r.TEXTURE_2D,s),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),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,i,0,r.RGBA,r.UNSIGNED_BYTE,null),n.colorAttachment.set(s),n.depthAttachment.set(t.context.createRenderbuffer(r.DEPTH_STENCIL,e,i)),t.layerOpacityFbo=n,void t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer)}if(t.layerOpacityFbo.width===e&&t.layerOpacityFbo.height===i)return void t.context.bindFramebuffer.set(t.layerOpacityFbo.framebuffer);let n=t.layerOpacityFbo;r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,e,i,0,r.RGBA,r.UNSIGNED_BYTE,null),t.context.bindRenderbuffer.set(n.depthAttachment.get()),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,e,i),t.context.bindRenderbuffer.set(null),n.width=e,n.height=i,t.context.bindFramebuffer.set(n.framebuffer)}(t,o,a),r.viewport.set([0,0,o,a]),r.clear({color:nr.transparent,depth:1,stencil:0}),t.frameRenderContext.invalidateTileClippingMasks(),t.frameRenderContext.renderTileClippingMasks(e,i),{compositeTarget:n,compositeViewport:s}}function zD(t,e,i,r){let n=t.context,s=n.gl;n.bindFramebuffer.set(i.compositeTarget),n.viewport.set(i.compositeViewport),n.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,t.layerOpacityFbo.colorAttachment.get()),t.frameRenderContext.useProgram("layerOpacity").draw(n,s.TRIANGLES,mD.disabled,fD.disabled,t.frameRenderContext.colorModeForRenderPass(),dD.disabled,(t=>({u_image:0,u_opacity:t}))(e),null,null,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.frameRenderContext.transform.zoom),t.frameRenderContext.invalidateTileClippingMasks()}function TD(t,e,i,r,n,s,o,a){let l=256;if(n.stepInterpolant){let r=e.getSource().maxzoom,n=o.canonical.z===r?Math.ceil(1<<t.frameRenderContext.transform.maxZoom-o.canonical.z):1;l=At(function(t){return t<=1?1:2**Math.ceil(Math.log(t)/Math.LN2)}(s.maxLineLength/st*1024*n),256,i.maxTextureSize)}return a.gradient=Kh({expression:n.gradientExpression(),evaluationKey:"lineProgress",resolution:l,image:a.gradient||void 0,clips:s.lineClipsArray}),a.texture?a.texture.update(a.gradient):a.texture=new au(i,a.gradient,r.RGBA),a.version=n.gradientVersion,a.texture}function PD(t,e,i,r,n){t.activeTexture.set(e.TEXTURE0),i.imageAtlasTexture.bind(e.LINEAR,e.CLAMP_TO_EDGE),r.updatePaintBuffers(n)}function ID(t,e,i,r,n,s){(n||t.lineAtlas.dirty)&&(e.activeTexture.set(i.TEXTURE0),t.lineAtlas.bind(e)),r.updatePaintBuffers(s)}function kD(t,e,i,r,n,s,o){let a=s.gradients[n.id],l=a.texture;n.gradientVersion!==a.version&&(l=TD(t,e,i,r,n,s,o,a)),i.activeTexture.set(r.TEXTURE0),l.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE)}function $D(t,e,i,r,n,s,o,a,l){let h=s.gradients[n.id],u=h.texture;n.gradientVersion!==h.version&&(u=TD(t,e,i,r,n,s,o,h)),i.activeTexture.set(r.TEXTURE0),u.bind(n.stepInterpolant?r.NEAREST:r.LINEAR,r.CLAMP_TO_EDGE),i.activeTexture.set(r.TEXTURE1),t.lineAtlas.bind(i),a.updatePaintBuffers(l)}function jD(t,e,i,r,n){let s,o=n.getDepthModeForSublayer(0,mD.ReadOnly),a=n.colorModeForRenderPass(),l=i.paint.get("line-dasharray"),h=l.constantOr(1),u=i.paint.get("line-pattern"),c=u.constantOr(1),f=i.paint.get("line-gradient"),p=i.getCrossfadeParameters();s=c?"linePattern":h&&f?"lineGradientSDF":h?"lineSDF":f?"lineGradient":"line";let d=t.context,m=d.gl,_=n.transform,g=!0;for(let y of r){let r=e.getTile(y);if(c&&!r.patternsLoaded())continue;let v=r.getBucket(i);if(!v)continue;let w=v.programConfigurations.get(i.id),b=t.context.program.get(),x=n.useProgram(s,w),D=g||x.program!==b,M=n.getTerrainDataForTile(y),E=u.constantOr(null),A=l?.constantOr(null);if(E&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[E.to.toString()],i=t.patternPositions[E.from.toString()];e&&i&&w.setConstantPatternPositions(e,i)}else if(A){let e="round"===i.layout.get("line-cap").constantOr(null),r=t.lineAtlas.getDash(A.to,e),n=t.lineAtlas.getDash(A.from,e);w.setConstantDashPositions(r,n)}let F,S=n.getProjectionDataForTile(y),C=_.getPixelScale();c?(F=Kx(t,r,i,C,p),PD(d,m,r,w,p)):h&&f?(F=tD(t,r,i,C,p,v.lineClipsArray.length),$D(t,e,d,m,i,v,y,w,p)):h?(F=Qx(t,r,i,C,p),ID(t,d,m,w,D,p)):f?(F=Jx(t,r,i,C,v.lineClipsArray.length),kD(t,e,d,m,i,v,y)):F=Xx(t,r,i,C);let z=n.stencilModeForClipping(y);x.draw(d,m.TRIANGLES,o,z,a,dD.disabled,F,M,S,i.id,v.layoutVertexBuffer,v.indexBuffer,v.segments,i.paint,n.transform.zoom,w,v.layoutVertexBuffer2),g=!1}}function RD(t,e,i,r,n){if(!i||!r?.imageAtlas)return;let s=r.imageAtlas.patternPositions,o=s[i.to.toString()],a=s[i.from.toString()];if(!o&&a&&(o=a),!a&&o&&(a=o),!o||!a){let t=n.getPaintProperty(e);o=s[t],a=s[t]}o&&a&&t.setConstantPatternPositions(o,a)}function OD(t,e,i,r,n){let s=n.colorModeForRenderPass();LD(t,e,i,r,n.getDepthModeForSublayer(1,mD.ReadOnly),s,!1,n),BD(t,e,i,r,n)}function BD(t,e,i,r,n){if(!i.paint.get("fill-antialias"))return;let s=n.colorModeForRenderPass();LD(t,e,i,r,n.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,mD.ReadOnly),s,!0,n)}function LD(t,e,i,r,n,s,o,a){let l,h,u,c,f,p=t.context.gl,d="fill-pattern",m=i.paint.get(d),_=m?.constantOr(1),g=i.getCrossfadeParameters(),y=a.transform,v=i.paint.get("fill-translate"),w=i.paint.get("fill-translate-anchor");o?(h=_&&!i.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",l=p.LINES):(h=_?"fillPattern":"fill",l=p.TRIANGLES);let b=m.constantOr(null);for(let m of r){let r=e.getTile(m);if(_&&!r.patternsLoaded())continue;let x=r.getBucket(i);if(!x)continue;let D=x.sdfPatterns[i.id]??!1,M=x.programConfigurations.get(i.id),E=a.useProgram(h,M),A=a.getTerrainDataForTile(m);_&&(t.context.activeTexture.set(p.TEXTURE0),r.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),M.updatePaintBuffers(g)),RD(M,d,b,r,i);let F=a.getProjectionDataForTile(m),S=pt(y,r,v,w);o?(c=x.indexBuffer2,f=x.segments2,u="fillOutlinePattern"===h&&_?Ux(t,g,r,S,D):Lx(S)):(c=x.indexBuffer,f=x.segments,u=_?Ox(t,g,r,S,D):Bx(S));let C=a.stencilModeForClipping(m);E.draw(t.context,l,n,C,s,dD.backCCW,u,A,F,i.id,x.layoutVertexBuffer,c,f,i.paint,a.transform.zoom,M)}}function UD(t,e,i,r,n,s,o,a){let l=t.context,h=l.gl,u="fill-extrusion-pattern",c=i.paint.get(u),f=c.constantOr(1),p=i.getCrossfadeParameters(),d=i.paint.get("fill-extrusion-opacity"),m=c.constantOr(null),_=a.transform;for(let c of r){let r=e.getTile(c),g=r.getBucket(i);if(!g)continue;let y=a.getTerrainDataForTile(c),v=g.programConfigurations.get(i.id),w=a.useProgram(f?"fillExtrusionPattern":"fillExtrusion",v);f&&(t.context.activeTexture.set(h.TEXTURE0),r.imageAtlasTexture.bind(h.LINEAR,h.CLAMP_TO_EDGE),v.updatePaintBuffers(p));let b=a.getProjectionDataForTile(c);RD(v,u,m,r,i);let x=pt(_,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),D=i.paint.get("fill-extrusion-vertical-gradient"),M=f?Rx(t,a.data.light,D,d,x,c,p,r):jx(t,a.data.light,D,d,x);w.draw(l,l.gl.TRIANGLES,n,s,o,dD.backCCW,M,y,b,i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,a.transform.zoom,v,a.terrain&&g.centroidVertexBuffer)}}function ND(t,e,i,r,n,s,o,a,l){let h=t.context,u=h.gl,c=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],f=l.useProgram("hillshade",null,!1,c),p=!l.data.moving;for(let c of r){let r=e.getTile(c),d=r.fbo;if(!d)continue;let m=l.getMeshFromTileID(c.canonical,a,!0,"raster"),_=l.getTerrainDataForTile(c);h.activeTexture.set(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,d.colorAttachment.get());let g=l.getProjectionDataForTile(c,{aligned:p});f.draw(h,u.TRIANGLES,s,n[c.overscaledZ],o,dD.backCCW,Zx(t,r,i),_,g,i.id,m.vertexBuffer,m.indexBuffer,m.segments)}}let GD=0;function qD(t,e,i,r,n,s,o,a,l){let h=t.context,u=h.gl,c=l.useProgram("colorRelief"),f=!l.data.moving,p="nearest"===i.paint.get("resampling")?u.NEAREST:u.LINEAR,d=!0,m=0;for(let _ of r){let r=e.getTile(_),g=r.dem;if(!g?.data)continue;if(d){GD||=u.getParameter(u.MAX_TEXTURE_SIZE);let t=GD,{elevationTexture:e,colorTexture:r}=i.getColorRampTextures(h,t,g.getUnpackVector());h.activeTexture.set(u.TEXTURE1),e.bind(u.NEAREST,u.CLAMP_TO_EDGE),h.activeTexture.set(u.TEXTURE4),r.bind(u.LINEAR,u.CLAMP_TO_EDGE),d=!1,m=e.size[0]}let y=g.stride;h.activeTexture.set(u.TEXTURE0),(!r.demTexture||r.needsColorReliefPrepare)&&(h.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=t.getTileTexture(y)??new au(h,{width:y,height:y,data:null},u.RGBA),r.demTexture.update(g.getPixels(),{premultiply:!1}),r.needsColorReliefPrepare=!1),r.demTexture.bind(p,u.CLAMP_TO_EDGE);let v=l.getMeshFromTileID(_.canonical,a,!0,"raster"),w=l.getTerrainDataForTile(_),b=l.getProjectionDataForTile(_,{aligned:f});c.draw(h,u.TRIANGLES,s,n[_.overscaledZ],o,dD.backCCW,Yx(i,r.dem,m),w,b,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}}const VD=[new f(0,0),new f(st,0),new f(st,st),new f(0,st)];function ZD(t,e,i,r,n,s,o,a,l,h=!1,u,c=null){let f=r[r.length-1].overscaledZ,p=t.context,d=p.gl,m=u.useProgram("raster"),_=u.colorModeForRenderPass(),g=!u.data.moving,y=i.paint.get("raster-opacity"),v="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR,w=i.paint.get("raster-fade-duration"),b=!!u.terrain;for(let t of r){let r=u.getDepthModeForSublayer(t.overscaledZ-f,1===y?mD.ReadWrite:mD.ReadOnly,d.LESS),x=e.getTile(t);p.activeTexture.set(d.TEXTURE0),x.texture.bind(v,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(d.TEXTURE1);let{parentTile:D,parentScaleBy:M,parentTopLeft:E,fadeValues:A}=WD(x,e,w,b);x.fadeOpacity=A.tileOpacity,D?(D.fadeOpacity=A.parentTileOpacity,D.texture.bind(v,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)):x.texture.bind(v,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),x.texture.useMipmap&&p.extTextureFilterAnisotropic&&u.transform.pitch>u.data.anisotropicFilterPitch&&d.texParameterf(d.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let F=u.getTerrainDataForTile(t),S=u.getProjectionDataForTile(t,{aligned:g}),C=h_(E,M,A.fadeMix,i,a,l),z=c??u.getMeshFromTileID(t.canonical,s,o,"raster");m.draw(p,d.TRIANGLES,r,n?n[t.overscaledZ]:fD.disabled,_,h?dD.frontCCW:dD.backCCW,C,F,S,i.id,z.vertexBuffer,z.indexBuffer,z.segments)}}function WD(t,e,i,r){let n={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===i||r)return n;if(t.fadingParentID){let r=e.getLoadedTile(t.fadingParentID);if(!r)return n;let s=2**(r.tileID.overscaledZ-t.tileID.overscaledZ);return{parentTile:r,parentScaleBy:s,parentTopLeft:[t.tileID.canonical.x*s%1,t.tileID.canonical.y*s%1],fadeValues:HD(t,r,i)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:YD(t,i)}:n}function HD(t,e,i){let r=de(),n=(r-e.timeAdded)/i,s=1===t.fadingDirection,o=At((r-t.timeAdded)/i,0,1),a=At(1-n,0,1),l=s?o:a;return{tileOpacity:l,parentTileOpacity:s?a:o,fadeMix:{opacity:1,mix:1-l}}}function YD(t,e){let i=At((de()-t.timeAdded)/e,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}const XD=new nr(1,0,0,1),JD=new nr(0,1,0,1),KD=new nr(0,0,1,1),QD=new nr(1,0,1,1),tM=new nr(0,1,1,1);function eM(t,e,i,r){rM(t,0,e+i/2,t.transform.width,i,r)}function iM(t,e,i,r){rM(t,e-i/2,0,i,t.transform.height,r)}function rM(t,e,i,r,n,s){let o=t.context,a=o.gl,l=t.data.pixelRatio;a.enable(a.SCISSOR_TEST),a.scissor(e*l,i*l,r*l,n*l),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function nM(t,e,i,r){let n=t.context,s=n.gl,o=r.useProgram("debug"),a=mD.disabled,l=fD.disabled,h=r.colorModeForRenderPass(),u="$debug",c=r.getTerrainDataForTile(i);n.activeTexture.set(s.TEXTURE0);let f=e.getTileByID(i.key).latestRawTileData?.byteLength||0,p=Math.floor(f/1024),d=e.getTile(i).tileSize,m=512/Math.min(d,512)*(i.overscaledZ/r.transform.zoom)*.5,_=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(_+=` => ${i.overscaledZ}`),function(t,e){t.initDebugOverlayCanvas();let i=t.debugOverlayCanvas,r=t.context.gl,n=t.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(e,5,5),n.strokeText(e,5,5),t.debugOverlayTexture.update(i),t.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,`${_} ${p}kB`);let g=r.getProjectionDataForTile(i);o.draw(n,s.TRIANGLES,a,l,Fx.alphaBlended,dD.disabled,Gx(nr.transparent,m),null,g,u,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),o.draw(n,s.LINE_STRIP,a,l,h,dD.disabled,Gx(nr.red),c,g,u,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}const sM={symbol:function(t,e,i,r,n){if("translucent"!==n.currentPass)return;let s=fD.disabled,o=n.colorModeForRenderPass();(i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(t,e,i,r,n,s,o,a,l){let h=e.frameRenderContext.transform,u=e.frameRenderContext.terrain,c="map"===n,f="map"===s;for(let n of t){let t=r.getTile(n),s=t.getBucket(i);if(!s?.text?.segments.get().length)continue;let p=nd(s.textSizeData,h.zoom),d=ot(t,1,e.frameRenderContext.transform.zoom),m=Dv(c,e.frameRenderContext.transform,d),_="none"!==i.layout.get("icon-text-fit")&&s.hasIconData();if(p){let e=u?(t,e)=>u.getElevation(n,t,e):void 0;bD(s,c,f,l,h,m,2**(h.zoom-t.tileID.overscaledZ),p,_,pt(h,t,o,a),n.toUnwrapped(),e,"ground"===i.layout.get("symbol-height-anchor"))}}}(r,t,i,e,i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),n.data.variableOffsets),0!==i.paint.get("icon-opacity").constantOr(1)&&DD(t,e,i,r,!1,i.paint.get("icon-translate"),i.paint.get("icon-translate-anchor"),i.layout.get("icon-rotation-alignment").constantOr("viewport"),i.layout.get("icon-pitch-alignment"),i.layout.get("icon-keep-upright"),s,o,n),0!==i.paint.get("text-opacity").constantOr(1)&&DD(t,e,i,r,!0,i.paint.get("text-translate"),i.paint.get("text-translate-anchor"),i.layout.get("text-rotation-alignment"),i.layout.get("text-pitch-alignment"),i.layout.get("text-keep-upright"),s,o,n),e.map.showCollisionBoxes&&(gD(t,e,i,r,!0,n),gD(t,e,i,r,!1,n))},circle:function(t,e,i,r,n){if("translucent"!==n.currentPass)return;let s=i.paint.get("circle-opacity"),o=i.paint.get("circle-stroke-width"),a=i.paint.get("circle-stroke-opacity"),l=!i.layout.get("circle-sort-key").isConstant();if(0===s.constantOr(1)&&(0===o.constantOr(1)||0===a.constantOr(1)))return;let h=t.context,u=h.gl,c=n.transform,f=n.getDepthModeForSublayer(0,mD.ReadOnly),p=fD.disabled,d=n.colorModeForRenderPass(),m=[],_=c.getCircleRadiusCorrection();for(let s of r){let r=e.getTile(s),o=r.getBucket(i);if(!o)continue;let a=pt(c,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),h=o.programConfigurations.get(i.id),u=n.useProgram("circle",h),f=o.layoutVertexBuffer,p=o.indexBuffer,d=n.getTerrainDataForTile(s),g={programConfiguration:h,program:u,layoutVertexBuffer:f,indexBuffer:p,uniformValues:Nx(t,r,i,a,_),terrainData:d,projectionData:n.getProjectionDataForTile(s)};if(l){let t=o.segments.get();for(let e of t)m.push({segments:new zl([e]),sortKey:e.sortKey,state:g})}else m.push({segments:o.segments,sortKey:0,state:g})}l&&m.sort(((t,e)=>t.sortKey-e.sortKey));for(let t of m){let{programConfiguration:e,program:r,layoutVertexBuffer:s,indexBuffer:o,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,u.TRIANGLES,f,p,d,dD.backCCW,a,l,c,i.id,s,o,t.segments,i.paint,n.transform.zoom,e)}},heatmap:function(t,e,i,r,n){if(0===i.paint.get("heatmap-opacity"))return;let s=t.context;if(n.terrain){for(let s of r){let r=e.getTile(s);e.hasRenderableParent(s)||("offscreen"===n.currentPass?ED(t,r,i,s,n):"translucent"===n.currentPass&&AD(t,i,s,n))}s.viewport.set([0,0,t.width,t.height])}else"offscreen"===n.currentPass?function(t,e,i,r,n){let s=t.context,o=s.gl,a=n.transform,l=fD.disabled,h=new Fx([o.ONE,o.ONE],nr.transparent,[!0,!0,!0,!0]);(function(t,e,i){let r=t.gl;t.activeTexture.set(r.TEXTURE1),t.viewport.set([0,0,e.width/4,e.height/4]);let n=i.heatmapFbos.get(Qh);n?(r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer)):(n=FD(t,e.width/4,e.height/4),i.heatmapFbos.set(Qh,n))})(s,t,i),s.clear({color:nr.transparent});for(let t of r){if(e.hasRenderableParent(t))continue;let r=e.getTile(t),u=r.getBucket(i);if(!u)continue;let c=u.programConfigurations.get(i.id),f=n.useProgram("heatmap",c),p=n.getProjectionDataForTile(t,{applyTerrainMatrix:!1}),d=a.getCircleRadiusCorrection();f.draw(s,o.TRIANGLES,mD.disabled,l,h,dD.backCCW,qx(r,a.zoom,i.paint.get("heatmap-intensity"),d),null,p,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,a.zoom,c)}s.viewport.set([0,0,t.width,t.height])}(t,e,i,r,n):"translucent"===n.currentPass&&function(t,e){let i=t.context,r=i.gl;i.setColorMode(t.frameRenderContext.colorModeForRenderPass());let n=e.heatmapFbos.get(Qh);n&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),SD(i,e).bind(r.LINEAR,r.CLAMP_TO_EDGE),t.frameRenderContext.useProgram("heatmapTexture").draw(i,r.TRIANGLES,mD.disabled,fD.disabled,t.frameRenderContext.colorModeForRenderPass(),dD.disabled,Vx(t,e,0,1),null,null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.frameRenderContext.transform.zoom))}(t,i)},line:function(t,e,i,r,n){if("translucent"!==n.currentPass)return;let s=i.paint.get("line-opacity"),o=i.paint.get("line-width"),a=i.paint.get("line-layer-opacity");if(0!==s.constantOr(1)&&0!==o.constantOr(1)&&0!==a){if(a<1){let s=CD(t,i,r);return jD(t,e,i,r,n),void zD(t,a,s,i)}jD(t,e,i,r,n)}},fill:function(t,e,i,r,n){let s=i.paint.get("fill-color"),o=i.paint.get("fill-opacity"),a=i.paint.get("fill-layer-opacity");if(0===o.constantOr(1)||0===a)return;if(a<1){if("translucent"!==n.currentPass)return;let s=CD(t,i,r);return OD(t,e,i,r,n),void zD(t,a,s,i)}let l=i.paint.get("fill-pattern"),h=n.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===s.constantOr(nr.transparent).a&&1===o.constantOr(0);if(h&&"opaque"===n.currentPass){let s=n.colorModeForRenderPass();LD(t,e,i,r,n.getDepthModeForSublayer(1,mD.ReadWrite),s,!1,n)}else h&&"translucent"===n.currentPass?BD(t,e,i,r,n):"translucent"===n.currentPass&&OD(t,e,i,r,n)},fillExtrusion:function(t,e,i,r,n){let s=i.paint.get("fill-extrusion-opacity");if(0!==s&&"translucent"===n.currentPass){let o=new mD(t.context.gl.LEQUAL,mD.ReadWrite,n.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))UD(t,e,i,r,o,fD.disabled,Fx.disabled,n),UD(t,e,i,r,o,n.stencilModeFor3D(),n.colorModeForRenderPass(),n);else{let s=n.colorModeForRenderPass();UD(t,e,i,r,o,fD.disabled,s,n)}}},hillshade:function(t,e,i,r,n){if("offscreen"!==n.currentPass&&"translucent"!==n.currentPass)return;let s=t.context,{useSubdivision:o}=n.data,a=n.getDepthModeForSublayer(0,mD.ReadOnly),l=n.colorModeForRenderPass();if("offscreen"===n.currentPass)(function(t,e,i,r,n,s,o){let a=t.context,l=a.gl,h="nearest"===r.paint.get("resampling")?l.NEAREST:l.LINEAR;for(let u of i){let i=e.getTile(u),c=i.dem;if(!c?.data||!i.needsHillshadePrepare)continue;let f=c.dim+2,p=c.stride,d=c.getPixels();if(a.activeTexture.set(l.TEXTURE1),a.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture||=t.getTileTexture(p),i.demTexture){let t=i.demTexture;t.update(d,{premultiply:!1}),t.bind(l.NEAREST,l.CLAMP_TO_EDGE)}else i.demTexture=new au(a,d,l.RGBA,{premultiply:!1}),i.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);a.activeTexture.set(l.TEXTURE0);let m=i.fbo;if(!m){let t=new au(a,{width:f,height:f,data:null},l.RGBA);t.bind(h,l.CLAMP_TO_EDGE),m=i.fbo=a.createFramebuffer(f,f,!0,!1),m.colorAttachment.set(t.texture)}a.bindFramebuffer.set(m.framebuffer),a.viewport.set([0,0,f,f]),t.frameRenderContext.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,s,o,dD.disabled,Wx(i.tileID,c),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(t,e,r,i,a,fD.disabled,l),s.viewport.set([0,0,t.width,t.height]);else if("translucent"===n.currentPass)if(o){let[s,o,h]=n.stencilConfigForOverlapTwoPass(r);ND(t,e,i,h,s,a,l,!1,n),ND(t,e,i,h,o,a,l,!0,n)}else{let[s,o]=n.getStencilConfigForOverlapAndUpdateStencilID(r);ND(t,e,i,o,s,a,l,!1,n)}},colorRelief:function(t,e,i,r,n){if("translucent"!==n.currentPass||!r.length)return;let{useSubdivision:s}=n.data,o=n.getDepthModeForSublayer(0,mD.ReadOnly),a=n.colorModeForRenderPass();if(s){let[s,l,h]=n.stencilConfigForOverlapTwoPass(r);qD(t,e,i,h,s,o,a,!1,n),qD(t,e,i,h,l,o,a,!0,n)}else{let[s,l]=n.getStencilConfigForOverlapAndUpdateStencilID(r);qD(t,e,i,l,s,o,a,!1,n)}},raster:function(t,e,i,r,n){if("translucent"!==n.currentPass||0===i.paint.get("raster-opacity")||!r.length)return;let s=e.getSource(),{useSubdivision:o}=n.data;if(s instanceof __)ZD(t,e,i,r,null,!1,!1,s.tileCoords,s.imageWarp,s.flippedWindingOrder,n,s.getMesh(t.context,o));else if(o){let[s,o,a]=n.stencilConfigForOverlapTwoPass(r);ZD(t,e,i,a,s,!1,!0,VD,l_,!1,n),ZD(t,e,i,a,o,!0,!0,VD,l_,!1,n)}else{let[s,o]=n.getStencilConfigForOverlapAndUpdateStencilID(r);ZD(t,e,i,o,s,!1,!0,VD,l_,!1,n)}},background:function(t,e,i,r,n){let s=i.paint.get("background-color"),o=i.paint.get("background-opacity");if(0===o)return;let a=t.context,l=a.gl,h=n.transform,u=h.tileSize,c=i.paint.get("background-pattern");if(t.patternAtlas.isPatternMissing(c))return;let f=!c&&1===s.a&&1===o&&n.opaquePassEnabledForLayer()?"opaque":"translucent";if(n.currentPass!==f)return;let p=fD.disabled,d=n.getDepthModeForSublayer(0,"opaque"===f?mD.ReadWrite:mD.ReadOnly),m=n.colorModeForRenderPass(),_=n.useProgram(c?"backgroundPattern":"background"),g=r||lv(h,{tileSize:u,terrain:n.terrain});c&&(a.activeTexture.set(l.TEXTURE0),t.patternAtlas.bind(t.context));let y=i.getCrossfadeParameters();for(let e of g){let r=n.getProjectionDataForTile(e),h=c?aD(o,t,c,{tileID:e,tileSize:u},y):oD(o,s),f=n.getTerrainDataForTile(e),g=n.getMeshFromTileID(e.canonical,!1,!0,"raster");_.draw(a,l.TRIANGLES,d,p,m,dD.backCCW,h,f,r,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}},sky:function(t,e,i){let r=t.context,n=r.gl,s=((t,e,i)=>{let r=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),s=Gc(e),o=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition,a=eb(e),l=tb(e.worldSize,e.center.lat);return{u_sky_color:t["sky-color"],u_horizon_color:t["horizon-color"],u_horizon:[(e.width/2-s*n)*i,(e.height/2+s*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:t["sky-horizon-blend"]*e.height/2*i,u_sky_blend:o,u_inv_proj_matrix:e.inverseProjectionMatrix,u_globe_position:a,u_globe_radius:l,u_atmosphere_blend:t["atmosphere-blend"]*ub(k(a)-l,l)}})(e,t.frameRenderContext.transform,i),o=new mD(n.LEQUAL,mD.ReadWrite,[0,1]),a=fD.disabled,l=t.frameRenderContext.colorModeForRenderPass(),h=t.frameRenderContext.useProgram("sky"),u=t.skyMesh;h.draw(r,n.TRIANGLES,o,a,l,dD.disabled,s,null,void 0,"sky",u.vertexBuffer,u.indexBuffer,u.segments)},atmosphere:function(t,e,i){let r=t.context,n=r.gl,s=t.frameRenderContext.useProgram("atmosphere"),o=new mD(n.LEQUAL,mD.ReadOnly,[0,1]),a=t.frameRenderContext.transform,l=function(t,e){let i=Gt(t.position);!function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}(i,i);let r=x(new Float64Array(16));return"map"===t.anchor&&(C(r,r,e.rollInRadians),F(r,r,-e.pitchInRadians),C(r,r,e.bearingInRadians),F(r,r,e.center.lat*Math.PI/180),S(r,r,-e.center.lng*Math.PI/180)),function(t,e,i){var r=e[0],n=e[1],s=e[2],o=i[3]*r+i[7]*n+i[11]*s+i[15];o||=1,t[0]=(i[0]*r+i[4]*n+i[8]*s+i[12])/o,t[1]=(i[1]*r+i[5]*n+i[9]*s+i[13])/o,t[2]=(i[2]*r+i[6]*n+i[10]*s+i[14])/o}(i,i,r),i}(i,t.frameRenderContext.transform),h=a.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=tb(a.worldSize,a.center.lat),c=eb(a),f=ub(k(c)-u,u),p=e["atmosphere-blend"]*h.projectionTransition*f;if(0===p)return;let d=((t,e,i,r,n)=>({u_sun_pos:t,u_atmosphere_blend:e,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(l,p,c,u,a.inverseProjectionMatrix),m=t.skyMesh;s.draw(r,n.TRIANGLES,o,fD.disabled,Fx.alphaBlended,dD.disabled,d,null,null,"atmosphere",m.vertexBuffer,m.indexBuffer,m.segments)},custom:function(t,e,i,r,n){if(n.isRenderingToTexture)return void function(t,e,i,r){let n=t.context,s=n.bindFramebuffer.get(),o=n.viewport.get();n.setCustomLayerDefaults(),n.setColorMode(r.colorModeForRenderPass()),n.setDepthMode(mD.disabled),n.setStencilMode(fD.disabled),e.implementation.renderToTerrainTile(n.gl,{tileID:{canonical:i.canonical,wrap:i.wrap},width:o[2],height:o[3]}),n.setDirty(),t.setBaseState(),n.bindFramebuffer.set(s),n.viewport.set(o)}(t,i,r[0],n);let{isRenderingGlobe:s,projectionShaderVariant:o}=n.data,{terrain:a}=n,l=t.context,h=i.implementation,u=n.transform,c=u.getProjectionDataForCustomLayer(s),f={farZ:u.farZ,nearZ:u.nearZ,fov:u.fov*Math.PI/180,modelViewProjectionMatrix:u.modelViewProjectionMatrix,projectionMatrix:u.projectionMatrix,shaderData:{variantName:o.name,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${o.prelude.vertexSource}`,define:o.define},defaultProjectionData:c,getProjectionData:t=>u.getProjectionData({overscaledTileID:new Hm(t.tileID.canonical.z,t.tileID.wrap??0,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),aligned:t.aligned,applyGlobeMatrix:t.applyGlobeMatrix,applyTerrainMatrix:t.applyTerrainMatrix}),renderTerrainHeightMap:a&&"offscreen"===n.currentPass?t=>function(t,e,i){let r=t.context,n=r.gl,[s,o,a,l]=i.bounds;r.setDirty();let h=e.getHeightMapFramebuffer(i.texture);r.viewport.set([0,0,i.width,i.height]),r.clear({color:nr.transparent});let u=t.useProgram("terrainHeight",null,!0);for(let i of e.tileManager.getRenderableTiles()){let h=e.getTerrainData(i.tileID);if(!h.tile?.dem)continue;let{canonical:c,wrap:f}=i.tileID,p=1/(1<<c.z),d=Px([(c.x*p+f-s)/(a-s),(c.y*p-o)/(l-o),p/(a-s),p/(l-o)]),m=e.getTerrainMesh(i.tileID,t.data.isRenderingGlobe);u.draw(r,n.TRIANGLES,mD.disabled,fD.disabled,Fx.unblended,dD.disabled,d,h,null,"terrain",m.vertexBuffer,m.indexBuffer,m.segments)}h.colorAttachment.set(null)}(n,a,t):void 0},p=h.renderingMode?h.renderingMode:"2d";if("offscreen"===n.currentPass){let e=h.prerender;e&&(l.setCustomLayerDefaults(),l.setColorMode(n.colorModeForRenderPass()),e.call(h,l.gl,f),l.setDirty(),t.setBaseState())}else if("translucent"===n.currentPass){l.setCustomLayerDefaults(),l.setColorMode(n.colorModeForRenderPass()),l.setStencilMode(fD.disabled);let e="3d"===p?n.getDepthModeFor3D():n.getDepthModeForSublayer(0,mD.ReadOnly);l.setDepthMode(e),h.render(l.gl,f),l.setDirty(),t.setBaseState(),l.bindFramebuffer.set(null)}},debug:function(t,e,i,r){for(let n of i)nM(t,e,n,r)},debugPadding:function(t){let e=t.transform.padding;eM(t,t.transform.height-(e.top||0),3,XD),eM(t,e.bottom||0,3,JD),iM(t,e.left||0,3,KD),iM(t,t.transform.width-(e.right||0),3,QD);let i=t.transform.centerPoint;!function(t,e,i,r){rM(t,e-1,i-10,2,20,r),rM(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,tM)},terrainDepth:function(t,e,i){let r=t.context,n=r.gl,s=i.transform,o=Fx.unblended,a=new mD(n.LEQUAL,mD.ReadWrite,[0,1]),l=e.tileManager.getRenderableTiles(),h=i.useProgram("terrainDepth");r.bindFramebuffer.set(e.getFramebuffer().framebuffer),r.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),r.clear({color:nr.white,depth:1});for(let t of l){let l=e.getTerrainMesh(t.tileID,i.data.isRenderingGlobe),u=e.getTerrainData(t.tileID),c=s.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),f=Tx(e.getSkirtLength(s.zoom));h.draw(r,n.TRIANGLES,a,fD.disabled,o,dD.backCCW,f,u,c,"terrain",l.vertexBuffer,l.indexBuffer,l.segments)}r.bindFramebuffer.set(null),r.viewport.set([0,0,t.width,t.height])}},oM=_v.maxOverzooming+_v.maxUnderzooming+1,aM=1/65536,lM={name:Aw,define:Ew,prelude:Dw.projectionMercator};var hM=class{constructor(t){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.transform=t.transform,this.terrain=t.terrain,this.data=t.data,this.context=t.context,this.programCache=t.programCache,this.currentPass=t.currentPass,this.projection=t.projection}getProjectionDataForTile(t,e={}){let i=this.transform.getProjectionData({overscaledTileID:t,aligned:e.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:e.applyTerrainMatrix??!0});return this.isRenderingToTexture||(i.uniformBufferKey=e.aligned?`${t.key}/aligned`:t.key),i}getTerrainDataForTile(t){return this.isRenderingToTexture?null:this.terrain?.getTerrainData(t)??null}getMeshFromTileID(t,e,i,r){return this.projection.getMeshFromTileID(this.context,t,e,i,r)}useProgram(t,e,i=!1,r=[]){return this.programCache.getProgram({name:t,programConfiguration:e,projectionShaderVariant:i?lM:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:null!==this.terrain,defines:r})}colorModeForRenderPass(){let t=this.context.gl;if(this.data.showOverdrawInspector){let e=1/8;return new Fx([t.CONSTANT_COLOR,t.ONE],new nr(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.currentPass?Fx.unblended:Fx.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return mD.disabled;let r=1-((1+this.currentLayer)*oM+t)*aM;return new mD(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new mD(this.context.gl.LEQUAL,mD.ReadWrite,this.depthRangeFor3D)}setDepthRangeFor3D(t){this.depthRangeFor3D=[0,1-(t+2)*oM*aM]}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}clearStencil(){this.nextStencilID=1,this.currentStencilSource=void 0,this.context.clear({stencil:0})}invalidateTileClippingMasks(){this.currentStencilSource=void 0}renderTileClippingMasks(t,e){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e?.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();let i=this.context;i.setColorMode(Fx.disabled),i.setDepthMode(mD.disabled);let r={};for(let t of e)r[t.key]=this.nextStencilID++;this.data.useSubdivision&&this.renderTileMasks(r,e,!0),this.renderTileMasks(r,e,!1),this.tileClippingMaskIDs=r}renderTileMasks(t,e,i){let r=this.context,n=r.gl,s=this.useProgram("clippingMask");for(let o of e){let e=t[o.key],a=this.getTerrainDataForTile(o),l=this.getMeshFromTileID(o.canonical,i,!0,"stencil"),h=this.getProjectionDataForTile(o);s.draw(r,n.TRIANGLES,mD.disabled,new fD({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Fx.disabled,this.isRenderingToTexture?dD.disabled:dD.backCCW,null,a,h,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,e=this.context.gl;return new fD({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new fD({func:e.EQUAL,mask:255},this.tileClippingMaskIDs[t.key],0,e.KEEP,e.KEEP,e.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(t){let e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();let t={};for(let i=0;i<n;i++)t[i+r]=new fD({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:fD.disabled},i]}stencilConfigForOverlapTwoPass(t){let e=this.context.gl,i=t.sort(((t,e)=>e.overscaledZ-t.overscaledZ)),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){let t={},s={};for(let i=0;i<n;i++)t[i+r]=new fD({func:e.GREATER,mask:255},n+1+i,255,e.KEEP,e.KEEP,e.REPLACE),s[i+r]=new fD({func:e.GREATER,mask:255},1+i,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID=2*n+1,[t,s,i]}return this.nextStencilID=3,[{[r]:new fD({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new fD({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}},uM=class t{constructor(t){this.drawFunctions=sM,this.context=new Sx(t),this.programCache=new uD(this.context),this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:x(new Float64Array(16)),renderTime:0},this.setup()}resize(t,e,i){this.width=Math.round(t*i),this.height=Math.round(e*i),this.context.viewport.set([0,0,this.width,this.height])}setup(){let t=this.context,e=new hl;e.emplaceBack(0,0),e.emplaceBack(st,0),e.emplaceBack(0,st),e.emplaceBack(st,st),this.tileExtentBuffer=t.createVertexBuffer(e,d_.members),this.tileExtentSegments=zl.simpleSegment(0,0,4,2);let i=new hl;i.emplaceBack(0,0),i.emplaceBack(st,0),i.emplaceBack(0,st),i.emplaceBack(st,st),this.debugBuffer=t.createVertexBuffer(i,d_.members),this.debugSegments=zl.simpleSegment(0,0,4,5);let r=new cl;r.emplaceBack(0,0,0,0),r.emplaceBack(st,0,st,0),r.emplaceBack(0,st,0,st),r.emplaceBack(st,st,st,st),this.rasterBoundsBuffer=t.createVertexBuffer(r,Fb.members),this.rasterBoundsSegments=zl.simpleSegment(0,0,4,2);let n=new hl;n.emplaceBack(0,0),n.emplaceBack(1,0),n.emplaceBack(0,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,d_.members),this.viewportSegments=zl.simpleSegment(0,0,4,2);let s=new Sl;s.emplaceBack(0),s.emplaceBack(1),s.emplaceBack(3),s.emplaceBack(2),s.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(s);let o=new Al;o.emplaceBack(1,0,2),o.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(o),this.tileExtentMesh=new p_(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments);let a=new hl;a.emplaceBack(-1,-1),a.emplaceBack(1,-1),a.emplaceBack(1,1),a.emplaceBack(-1,1);let l=new Al;l.emplaceBack(0,1,2),l.emplaceBack(0,2,3),this.skyMesh=new p_(t.createVertexBuffer(a,d_.members),t.createIndexBuffer(l),zl.simpleSegment(0,0,a.length,l.length))}_renderTilesDepthBuffer(){let t=this.context,e=t.gl,i=this.frameRenderContext.transform,r=this.frameRenderContext.useProgram("depth"),n=this.frameRenderContext.getDepthModeFor3D(),s=lv(i,{tileSize:i.tileSize});for(let i of s){let s=this.frameRenderContext.getTerrainDataForTile(i),o=this.frameRenderContext.getMeshFromTileID(i.canonical,!0,!0,"raster"),a=this.frameRenderContext.getProjectionDataForTile(i);r.draw(t,e.TRIANGLES,n,fD.disabled,Fx.disabled,dD.backCCW,null,s,a,"$clipping",o.vertexBuffer,o.indexBuffer,o.segments)}}render(t,e,i){let r=this.frameRenderContext=new hM({transform:e,terrain:t.map.terrain??null,data:i,context:this.context,programCache:this.programCache,currentPass:"offscreen",projection:t.projection});this.lineAtlas=t.lineAtlas,this.patternAtlas=t.patternAtlas,function(t,e,i){let r=t.pending,n=t.context.gl;r[Dx.u_units_to_pixels]=1/e.pixelsToGLUnits[0],r[Dx.u_units_to_pixels+1]=1/e.pixelsToGLUnits[1],r[Dx.u_world_size]=n.drawingBufferWidth,r[Dx.u_world_size+1]=n.drawingBufferHeight,r[Dx.u_camera_to_center_distance]=e.cameraToCenterDistance,r[Dx.u_symbol_fade_change]=i.fadeDuration?i.symbolFadeChange:1,r[Dx.u_aspect_ratio]=e.width/e.height,r[Dx.u_device_pixel_ratio]=i.pixelRatio,r[Dx.u_viewport_size]=e.width,r[Dx.u_viewport_size+1]=e.height,r[Dx.u_pixel_extrude_scale]=1/e.width,r[Dx.u_pixel_extrude_scale+1]=1/e.height,r[Dx.u_pitch]=e.pitch/360*2*Math.PI,t.upload()}(this.context.frameUniformBuffer,e,i),t.imageManager.beginFrame(),function(t){t.freeProjectionUniformBuffers.push(...t.keyedProjectionUniformBuffers.values()),t.keyedProjectionUniformBuffers.clear()}(this.context);let n=t._order,s=t.tileManagers,o={},a={},l={};for(let t in s){let e=s[t];e.used&&e.prepare(this.context),o[t]=e.getVisibleCoordinates(!1),a[t]=o[t].slice().reverse(),l[t]=e.getVisibleCoordinates(!0).reverse()}r.opaquePassCutoff=1/0;for(let e=0;e<n.length;e++)if(t._layers[n[e]].is3D()){r.opaquePassCutoff=e;break}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(t,e.zoom,i.moving),r.opaquePassCutoff=0),r.currentPass="offscreen";for(let i of n){let n=t._layers[i];if(!n.hasOffscreenPass()||n.isHidden(e.zoom))continue;let o=a[n.source];("custom"===n.type||o.length)&&this.renderLayer(this,s[n.source],n,o,r)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?nr.black:nr.transparent,depth:1}),r.clearStencil(),i.sky&&this.drawFunctions.sky(this,i.sky,i.pixelRatio),r.setDepthRangeFor3D(t._order.length),!this.renderToTexture)for(r.currentPass="opaque",r.currentLayer=n.length-1;r.currentLayer>=0;r.currentLayer--){let i=t._layers[n[r.currentLayer]];if(i.isHidden(e.zoom))continue;let a=s[i.source],l=o[i.source];r.renderTileClippingMasks(i,l),this.renderLayer(this,a,i,l,r)}r.currentPass="translucent";let h=!1;for(r.currentLayer=0;r.currentLayer<n.length;r.currentLayer++){let u=t._layers[n[r.currentLayer]];if(u.isHidden(e.zoom))continue;let c=s[u.source];if(this.renderToTexture?.renderLayer(u,t,r))continue;!r.opaquePassEnabledForLayer()&&!h&&(h=!0,i.isRenderingGlobe&&!r.terrain&&this._renderTilesDepthBuffer());let f=("symbol"===u.type?l:a)[u.source];r.renderTileClippingMasks(u,o[u.source]),this.renderLayer(this,c,u,f,r)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this,i.sky,i.light),i.showTileBoundaries){let i=function(t,e){let i=null,r=Object.values(t._layers).flatMap((i=>i.source&&!i.isHidden(e)?[t.tileManagers[i.source]]:[])),n=r.filter((t=>"vector"===t.getSource().type)),s=r.filter((t=>"vector"!==t.getSource().type)),o=t=>{(!i||i.getSource().maxzoom<t.getSource().maxzoom)&&(i=t)};for(let t of n)o(t);if(!i)for(let t of s)o(t);return i}(t,e.zoom);i&&this.drawFunctions.debug(this,i,i.getVisibleCoordinates(),r)}i.showPadding&&this.drawFunctions.debugPadding(r),this.renderToTexture&&!i.moving&&this.clearRTTPool(),this.context.setDefault()}markTerrainDepthDirty(){this.terrainFacilitator.depthDirty=!0}maybeDrawDepth(){if(!this.frameRenderContext.data.projectionShaderVariant||!this.frameRenderContext.terrain)return;let t=this.terrainFacilitator.matrix,e=this.frameRenderContext.transform.modelViewProjectionMatrix,i=this.terrainFacilitator.depthDirty;i||=!function(t,e){var i=t[0],r=t[1],n=t[2],s=t[3],o=t[4],a=t[5],l=t[6],h=t[7],u=t[8],c=t[9],f=t[10],p=t[11],d=t[12],m=t[13],_=t[14],g=t[15],y=e[0],v=e[1],w=e[2],b=e[3],x=e[4],D=e[5],M=e[6],E=e[7],A=e[8],F=e[9],S=e[10],C=e[11],z=e[12],T=e[13],P=e[14],I=e[15];return Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=1e-6*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-w)<=1e-6*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(s-b)<=1e-6*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(o-x)<=1e-6*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(a-D)<=1e-6*Math.max(1,Math.abs(a),Math.abs(D))&&Math.abs(l-M)<=1e-6*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(h-E)<=1e-6*Math.max(1,Math.abs(h),Math.abs(E))&&Math.abs(u-A)<=1e-6*Math.max(1,Math.abs(u),Math.abs(A))&&Math.abs(c-F)<=1e-6*Math.max(1,Math.abs(c),Math.abs(F))&&Math.abs(f-S)<=1e-6*Math.max(1,Math.abs(f),Math.abs(S))&&Math.abs(p-C)<=1e-6*Math.max(1,Math.abs(p),Math.abs(C))&&Math.abs(d-z)<=1e-6*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(m-T)<=1e-6*Math.max(1,Math.abs(m),Math.abs(T))&&Math.abs(_-P)<=1e-6*Math.max(1,Math.abs(_),Math.abs(P))&&Math.abs(g-I)<=1e-6*Math.max(1,Math.abs(g),Math.abs(I))}(t,e),i||=this.frameRenderContext.terrain.tileManager.anyTilesAfterTime(this.terrainFacilitator.renderTime),i&&(function(t,e){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,e),this.terrainFacilitator.renderTime=de(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.frameRenderContext.terrain,this.frameRenderContext))}renderLayer(t,e,i,r,n){if(i.isHidden(n.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;let s=this.drawFunctions;Zd(i)?s.symbol(t,e,i,r,n):(t=>"circle"===t.type)(i)?s.circle(t,e,i,r,n):(t=>"heatmap"===t.type)(i)?s.heatmap(t,e,i,r,n):(t=>"line"===t.type)(i)?s.line(t,e,i,r,n):(t=>"fill"===t.type)(i)?s.fill(t,e,i,r,n):(t=>"fill-extrusion"===t.type)(i)?s.fillExtrusion(t,e,i,r,n):(t=>"hillshade"===t.type)(i)?s.hillshade(t,e,i,r,n):(t=>"color-relief"===t.type)(i)?s.colorRelief(t,e,i,r,n):wa(i)?s.raster(t,e,i,r,n):(t=>"background"===t.type)(i)?s.background(t,e,i,r,n):Jd(i)&&s.custom(t,e,i,r,n)}static{this.MAX_TEXTURE_POOL_SIZE_PER_BUCKET=50}saveTileTexture(e){let i=this._tileTextures[e.size[0]];i?i.length<t.MAX_TEXTURE_POOL_SIZE_PER_BUCKET?i.push(e):e.destroy():this._tileTextures[e.size[0]]=[e]}getTileTexture(t){let e=this._tileTextures[t];return e&&e.length>0?e.pop():null}acquireRTT(t){let e=this.context.gl,i=this._rttObjectRecyclePool.pop();if(i)return i.size!==t&&(i.texture.update({width:t,height:t,data:null},{premultiply:!1,useMipmap:!0}),i.texture.bind(e.LINEAR,e.CLAMP_TO_EDGE,e.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&e.texParameterf(e.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),i.size=t),i;let r=new au(this.context,{width:t,height:t,data:null},e.RGBA,{premultiply:!1,useMipmap:!0});return r.bind(e.LINEAR,e.CLAMP_TO_EDGE,e.LINEAR_MIPMAP_LINEAR),this.context.extTextureFilterAnisotropic&&e.texParameterf(e.TEXTURE_2D,this.context.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,this.context.extTextureFilterAnisotropicMax),{texture:r,size:t}}bindRTT(t){let e=this.context.gl,i=t.size;if(!this._rttSharedFbo){let t=this.context.createFramebuffer(i,i,!0,!0),r=this.context.createRenderbuffer(e.DEPTH_STENCIL,i,i);t.depthAttachment.set(r),this._rttSharedFbo={fbo:t,depthRenderbuffer:r,size:i}}this._rttSharedFbo.size!==i&&(this.context.bindRenderbuffer.set(this._rttSharedFbo.depthRenderbuffer),e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,i,i),this.context.bindRenderbuffer.set(null),this._rttSharedFbo.fbo.width=i,this._rttSharedFbo.fbo.height=i,this._rttSharedFbo.size=i),this._rttSharedFbo.fbo.colorAttachment.set(t.texture.texture),this.context.bindFramebuffer.set(this._rttSharedFbo.fbo.framebuffer)}releaseRTT(t){this._rttObjectRecyclePool.push(t)}clearRTTPool(){for(let t of this._rttObjectRecyclePool)t.texture.destroy();this._rttObjectRecyclePool.length=0}destroyRTTResources(){if(this.clearRTTPool(),!this._rttSharedFbo)return;this._rttSharedFbo.fbo.colorAttachment.set(null),this._rttSharedFbo.fbo.depthAttachment.set(null);let t=this.context.gl;t.deleteRenderbuffer(this._rttSharedFbo.depthRenderbuffer),t.deleteFramebuffer(this._rttSharedFbo.fbo.framebuffer),this._rttSharedFbo=null}setBaseState(){let 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 au(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){if(this._tileTextures){for(let t in this._tileTextures){let e=this._tileTextures[t];if(e)for(let t of e)t.destroy()}this._tileTextures={}}this.destroyRTTResources(),this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.skyMesh?.destroy(),this.skyMesh=null,this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.destroy(),this.programCache.destroy(),this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}},cM=class extends Error{constructor(t,e){super("WebGL2 is required to display this map. We are sorry, but it seems that your browser does not support WebGL2, a technology for rendering 3D graphics on the web. Read more on https://wiki.openstreetmap.org/wiki/This_map_requires_WebGL"),this.name="GPUInitializationError",this.requestedAttributes=t,this.statusMessage=e?.statusMessage??null}};function fM(t,e){let i,r=!1,n=null,s=()=>{n=null,r&&=(t(...i),n=setTimeout(s,e),!1)};return(...t)=>(r=!0,i=t,n||s(),n)}var pM=class{constructor(t){this._getHashParams=()=>new URLSearchParams(window.location.hash.replace("#","")),this._getCurrentHash=()=>{let t=this._getHashParams();return this._hashName?(t.get(this._hashName)||"").split("/"):([...t.keys()][0]??"").split("/")},this._onHashChange=()=>{let t=this._getCurrentHash();if(!this._isValidHash(t))return!1;let 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=()=>{let t=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,t)},this._removeHash=()=>{let t=this._getHashParams();if(this._hashName)t.delete(this._hashName);else{let e=Array.from(t.keys());e.length>0&&t.delete(e[0])}let e=decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,""),i=window.location.href.replace(/(#.+)?$/,e?`#${e}`:"");i=i.replace("&&","&"),window.history.replaceState(window.history.state,null,i)},this._updateHash=fM(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){let e=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=10**Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.round(e.lng*r)/r,s=Math.round(e.lat*r)/r,o=this._map.getBearing(),a=this._map.getPitch(),l="";if(l+=t?`/${n}/${s}/${i}`:`${i}/${s}/${n}`,(o||a)&&(l+="/"+Math.round(10*o)/10),a&&(l+=`/${Math.round(a)}`),this._hashName){let t=this._getHashParams();return t.set(this._hashName,l),`#${decodeURIComponent(t.toString()).replace(/=&/g,"&").replace(/=$/g,"")}`}return`#${l}`}_isValidHash(t){if(t.length<3||t.some((t=>isNaN(+t))))return!1;try{new Cc(+t[2],+t[1])}catch{return!1}let e=+t[0],i=+(t[3]||0),r=+(t[4]||0);return e>=this._map.getMinZoom()&&e<=this._map.getMaxZoom()&&i>=-180&&i<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}};const dM={linearity:.3,easing:Mt(0,0,.3,1)},mM=St({deceleration:2500,maxSpeed:1400},dM),_M=St({deceleration:20,maxSpeed:1400},dM),gM=St({deceleration:1e3,maxSpeed:360},dM),yM=St({deceleration:1e3,maxSpeed:90},dM),vM=St({deceleration:1e3,maxSpeed:360},dM);var wM=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:de(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=de();for(;t.length>0&&e-t[0].time>160;)t.shift()}_getVelocityEntries(){let t=this._inertiaBuffer,e=de()-60,i=Math.max(0,t.length-2);for(;i>0&&t[i-1].time>=e;)i--;return t.slice(i)}_onMoveEnd(t){this._drainInertiaBuffer();let e=this._getVelocityEntries();if(e.length<2)return void this.clear();let i={zoom:0,bearing:0,pitch:0,roll:0,pan:new f(0,0),pinchAround:void 0,around:void 0};for(let{settings:t}of e)t.around&&(i.around=t.around),t.pinchAround&&(i.pinchAround=t.pinchAround);for(let{settings:t}of e.slice(1))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);if(!(i.pan.mag()||i.zoom||i.bearing||i.pitch||i.roll))return void this.clear();let r=de()-e[0].time,n={};if(i.pan.mag()){let e=xM(i.pan.mag(),r,St({},mM,t||{})),s=i.pan.mult(e.amount/i.pan.mag()),o=this._map._camera.cameraHelper.handlePanInertia(s,this._map._camera.transform);n.center=o.easingCenter,n.offset=o.easingOffset,bM(n,e)}if(i.zoom){let t=xM(i.zoom,r,_M);n.zoom=kt(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),bM(n,t)}if(i.bearing){let t=xM(i.bearing,r,gM);n.bearing=this._map.getBearing()+At(t.amount,-179,179),bM(n,t)}if(i.pitch){let t=xM(i.pitch,r,yM);n.pitch=this._map.getPitch()+t.amount,bM(n,t)}if(i.roll){let t=xM(i.roll,r,vM);n.roll=this._map.getRoll()+At(t.amount,-179,179),bM(n,t)}if(n.zoom||n.bearing){let t=void 0===i.pinchAround?i.around:i.pinchAround;n.around=t?this._map.unproject(t):this._map.getCenter()}return this.clear(),St(n,{noMoveStart:!0})}};function bM(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function xM(t,e,i){let{maxSpeed:r,linearity:n,deceleration:s}=i,o=At(t*n/(e/1e3),-r,r),a=Math.abs(o)/(s*n);return{easing:i.easing,duration:1e3*a,amount:a/2*o}}var DM=class{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Ve(this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new Ge(t.type,this._map,t))}mouseup(t){this._map.fire(new Ge(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new Ge(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Ge(t.type,this._map,t))}mouseover(t){this._map.fire(new Ge(t.type,this._map,t))}mouseout(t){this._map.fire(new Ge(t.type,this._map,t))}touchstart(t){return this._firePreventable(new qe(t.type,this._map,t))}touchmove(t){this._map.fire(new qe(t.type,this._map,t))}touchend(t){this._map.fire(new qe(t.type,this._map,t))}touchcancel(t){this._map.fire(new qe(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},MM=class{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent,this._clearLongPress(),this._touchActive=!1}mousemove(t){this._map.fire(new Ge(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Ge("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}touchstart(t,e,i){if(this._clearLongPress(),this._touchActive=i.length>0,1!==i.length)return;this._longPressStart=e[0];let r=i[0];this._longPressTimer=setTimeout((()=>{this._longPressTimer=void 0;let t=new MouseEvent("contextmenu",{clientX:r.clientX,clientY:r.clientY,button:2,bubbles:!0,cancelable:!0});this._map.fire(new Ge("contextmenu",this._map,t))}),500)}touchmove(t,e,i){this._longPressTimer&&(1!==i.length||!this._longPressStart||e[0].dist(this._longPressStart)>this._clickTolerance)&&this._clearLongPress()}touchend(){this._touchActive=!1,this._clearLongPress()}touchcancel(){this._touchActive=!1,this._clearLongPress()}_clearLongPress(){this._longPressTimer&&=void clearTimeout(this._longPressTimer),this._longPressStart=void 0}contextmenu(t){this._touchActive?t.preventDefault():(this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Ge(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault())}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},EM=class{constructor(t,e,i){this._map=t,this._tr=i,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&&(be.disableDrag(),this._startPos=this._lastPos=e,this._active=!0)}mousemoveWindow(t,e){if(!this._active)return;let i=e;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)<this._clickTolerance)return;let r=this._startPos;this._lastPos=i,this._box||(this._box=be.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let n=Math.min(r.x,i.x),s=Math.max(r.x,i.x),o=Math.min(r.y,i.y),a=Math.max(r.y,i.y);this._box.style.transform=`translate(${n}px,${o}px)`,this._box.style.width=s-n+"px",this._box.style.height=a-o+"px"}mouseupWindow(t,e){if(!this._active||0!==t.button)return;let i=this._startPos,r=e;if(this.reset(),be.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new Ze("boxzoomend",{originalEvent:t})),this._boxZoomEnd?void this._boxZoomEnd(this._map,i,r,t):{cameraAnimation:t=>t.fitScreenCoordinates(i,r,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(),null),be.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new Ze(t,{originalEvent:e}))}};function AM(t,e){if(t.length!==e.length)throw Error(`The number of touches and points are not equal - touches ${t.length}, points ${e.length}`);let i={};for(let r=0;r<t.length;r++)i[t[r].identifier]=e[r];return i}var FM=class{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,e,i){(this.centroid||i.length>this.numTouches)&&(this.aborted=!0),!this.aborted&&(void 0===this.startTime&&(this.startTime=t.timeStamp),i.length===this.numTouches&&(this.centroid=function(t){let e=new f(0,0);for(let i of t)e._add(i);return e.div(t.length)}(e),this.touches=AM(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let r=AM(i,e);for(let t in this.touches){let e=r[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){let t=!this.aborted&&this.centroid;if(this.reset(),t)return t}}},SM=class{constructor(t){this.singleTap=new FM(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){let r=this.singleTap.touchend(t,e,i);if(r){let e=t.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if((!e||!i)&&this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}},CM=class{constructor(t,e){this._tr=e,this._zoomIn=new SM({numTouches:1,numTaps:2}),this._zoomOut=new SM({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,e,i){let r=this._zoomIn.touchend(t,e,i),n=this._zoomOut.touchend(t,e,i),s=this._tr;return r?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:kt(s.zoom+1,e.getZoomSnap()),around:s.transform.isPointOnMapSurface(r)?s.unproject(r):void 0},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:kt(s.zoom-1,e.getZoomSnap()),around:s.transform.isPointOnMapSurface(n)?s.unproject(n):void 0},{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}},zM=class{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){let 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;let i=this._lastPoint;if(!i)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let r=Array.isArray(e)?e[0]:e;return!this._moved&&r.dist(i)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=r,this._move(i,r))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&be.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 TM={0:1,2:2};var PM=class{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){let i=TM[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return t.button===this._eventButton}};const IM=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function kM({enable:t,clickTolerance:e,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:n=.8},s){return new zM({clickTolerance:e,move:(t,e)=>{let o=s();if(i&&Math.abs(o.y-t.y)>r)return{bearingDelta:Jt(new f(t.x,e.y),e,o)};let a=(e.x-t.x)*n;return i&&e.y<o.y&&(a=-a),{bearingDelta:a}},moveStateManager:new PM({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey}),enable:t,assignEvents:IM})}var $M=class{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new f(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)return this._shouldBePrevented(i.length)?void this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t):(t.preventDefault(),this._calculateTransform(t,e,i))}touchend(t,e,i){this._calculateTransform(t,e,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,e,i){i.length>0&&(this._active=!0);let r=AM(i,e),n=new f(0,0),s=new f(0,0),o=0;for(let t in r){let e=r[t],i=this._touches[t];i&&(n._add(e),s._add(e.sub(i)),o++,r[t]=e)}if(this._touches=r,this._shouldBePrevented(o)||!s.mag())return;let a=s.div(o);return this._sum._add(a),this._sum.mag()<this._clickTolerance?void 0:{around:n.div(o),panDelta:a}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},jM=class{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();let[r,n]=this._firstTwoTouches,s=RM(i,e,r),o=RM(i,e,n);if(!s||!o)return;let a=this._aroundCenter?null:s.add(o).div(2);return this._move([s,o],a,t)}touchend(t,e,i){if(!this._firstTwoTouches)return;let[r,n]=this._firstTwoTouches,s=RM(i,e,r),o=RM(i,e,n);s&&o||(this._active&&be.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 RM(t,e,i){for(let r=0;r<t.length;r++)if(t[r].identifier===i)return e[r]}function OM(t,e){return Math.log(t/e)/Math.LN2}var BM=class extends jM{constructor(){super(),this._zoomRate=1,this._zoomThreshold=.1}setZoomRate(t){this._zoomRate=t??1}setZoomThreshold(t){this._zoomThreshold=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){let i=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(OM(this._distance,this._startDistance))<this._zoomThreshold))return this._active=!0,{zoomDelta:OM(this._distance,i)*this._zoomRate,pinchAround:e}}};function LM(t,e){return 180*t.angleWith(e)/Math.PI}var UM=class extends jM{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){let r=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:LM(this._vector,r),pinchAround:e}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let e=25/(Math.PI*this._minDiameter)*360,i=LM(t,this._startVector);return Math.abs(i)<e}};function NM(t){return Math.abs(t.y)>Math.abs(t.x)}var GM=class extends jM{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,NM(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,e,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let r=t[0].sub(this._lastPoints[0]),n=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(t,e,i){if(void 0!==this._valid)return this._valid;let r=t.mag()>=2,n=e.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;let s=t.y>0==e.y>0;return NM(t)&&NM(e)&&s}};const qM={panStep:100,bearingStep:15,pitchStep:10};var VM=class{constructor(t,e){this._tr=e;let i=qM;this._panStep=i.panStep,this._bearingStep=i.bearingStep,this._pitchStep=i.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let e=0,i=0,r=0,n=0,s=0;switch(t.keyCode){case 61:case 107:case 171:case 187:e=1;break;case 189:case 109:case 173:e=-1;break;case 37:t.shiftKey?i=-1:(t.preventDefault(),n=-1);break;case 39:t.shiftKey?i=1:(t.preventDefault(),n=1);break;case 38:t.shiftKey?r=1:(t.preventDefault(),s=-1);break;case 40:t.shiftKey?r=-1:(t.preventDefault(),s=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:o=>{let a=this._tr;o.easeTo({duration:300,easeId:"keyboardHandler",easing:ZM,zoom:e?kt(a.zoom+e*(t.shiftKey?2:1),o.getZoomSnap()):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-n*this._panStep,-s*this._panStep],center:a.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 ZM(t){return t*(2-t)}const WM=4.000244140625;var HM=class{constructor(t,e,i){this._onTimeout=t=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(t)},this._map=t,this._tr=i,this._triggerRenderFrame=e,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}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,i=de(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%WM==0?this._type="wheel":0!==e&&Math.abs(e)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=e,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(r*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);let e=be.mousePos(this._map.getCanvas(),t),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint(Cc.convert(i.center)):e,this._needsRerender||(this._needsRerender=!0,this._triggerRenderFrame())}renderFrame(){if(!this._needsRerender||(this._needsRerender=!1,!this.isActive()))return;let t=this._tr.transform;if("number"==typeof this._lastExpectedZoom){let e=t.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=e),"number"==typeof this._targetZoom&&(this._targetZoom+=e)}if(0!==this._delta){let e="wheel"===this._type&&Math.abs(this._delta)>WM?this._wheelZoomRate:this._defaultZoomRate,i=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==i&&(i=1/i);let r="number"==typeof this._targetZoom?Pt(this._targetZoom):t.scale,n=t.applyConstrain(t.getCameraLngLat(),It(r*i)).zoom,s=this._map.getZoomSnap();if("wheel"===this._type&&s>0){let e=kt(t.zoom,s);this._targetZoom=kt(n,s,n-e)}else this._targetZoom=n;"wheel"===this._type&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let e,i="number"==typeof this._targetZoom?this._targetZoom:t.zoom,r=this._startZoom,n=this._easing,s=!1;if("wheel"===this._type&&r&&n){let t=de()-this._lastWheelEventTime,o=Math.min((t+5)/200,1),a=n(o);e=Sr.number(r,i,a),o<1?this._needsRerender=!0:s=!0}else e=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout((()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout}),200)),this._lastExpectedZoom=e,{noInertia:!0,needsRenderFrame:!s,zoomDelta:e-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let e=Et;if(this._prevEase){let t=this._prevEase,i=(de()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;e=Mt(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:de(),duration:t,easing:e},e}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}},YM=class{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()}},XM=class{constructor(t,e){this._tr=e,this.reset()}reset(){this._active=!1}dblclick(t,e){return t.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:kt(this._tr.zoom+(t.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.transform.isPointOnMapSurface(e)?this._tr.unproject(e):void 0},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},JM=class{constructor(){this._tap=new SM({numTouches:1,numTaps:1}),this._zoomRate=1,this.reset()}setZoomRate(t){this._zoomRate=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){let r=e[0],n=t.timeStamp-this._tapTime<500,s=this._tapPoint.dist(r)<30;n&&s?i.length>0&&(this._swipePoint=r,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;let r=e[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,t.preventDefault(),this._active=!0,{zoomDelta:n/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{let r=this._tap.touchend(t,e,i);r&&(this._tapTime=t.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},KM=class{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()}},QM=class{constructor(t,e,i,r){this._pitchWithRotate=t.pitchWithRotate,this._rollEnabled=t.rollEnabled,this._mouseRotate=e,this._mousePitch=i,this._mouseRoll=r}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()}},tE=class{constructor(t,e,i,r){this._el=t,this._touchZoom=e,this._touchRotate=i,this._tapDragZoom=r,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()}},eE=class{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;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=be.create("div","maplibregl-cooperative-gesture-screen",t);let e=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(e=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=e,this._container.appendChild(r);let n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),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,e){this._enabled&&(this._map.fire(new Oe("cooperativegestureprevented",{gestureType:t,originalEvent:e})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}},iE=class{constructor(t){this._camera=t}get transform(){return this._camera._requestedCameraState||this._camera.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(f.convert(t),this._camera.terrain)}};const rE=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var nE=class extends $e{};function sE(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var oE=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,e,i){this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this.handleWindowEvent=t=>{this.handleEvent(t,`${t.type}Window`)},this.handleEvent=(t,e)=>{if("blur"===t.type)return void this.stop(!0);this._updatingCamera=!0;let i="renderFrame"===t.type?void 0:t,r={needsRenderFrame:!1},n={},s={};for(let{handlerName:o,handler:a,allowed:l}of this._handlers){if(!a.isEnabled())continue;let h;if(this._blockedByActive(s,l,o))a.reset();else if(a[e||t.type]){if(re(t,e||t.type)){let i=be.mousePos(this._map.getCanvas(),t);h=a[e||t.type](t,i)}else if(ie(t,e||t.type)){let i=this._getMapTouches(t.touches),r=be.touchPos(this._map.getCanvas(),i);h=a[e||t.type](t,r,i)}else ne(e||t.type)||(h=a[e||t.type](t));this.mergeHandlerResult(r,n,h,o,i),h?.needsRenderFrame&&this._triggerRenderFrame()}(h||a.isActive())&&(s[o]=a)}let o={};for(let t in this._previousActiveHandlers)s[t]||(o[t]=i);this._previousActiveHandlers=s,(Object.keys(o).length||sE(r))&&(this._changes.push([r,n,o]),this._triggerRenderFrame()),(Object.keys(s).length||sE(r))&&this._camera.stop(!0),this._updatingCamera=!1;let{cameraAnimation:a}=r;a&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],a(this._map))},this._map=t,this._camera=e,this._transformProvider=new iE(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new wM(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);let r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[this._ownerDocument,"mousemove",{capture:!0}],[this._ownerDocument,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[this._ownerWindow,"blur",void 0]];for(let[t,e,i]of this._listeners)t.addEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(let[t,e,i]of this._listeners)t.removeEventListener(e,t===this._ownerDocument?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(t){let e=this._map,i=e.getCanvasContainer();this._add("mapEvent",new DM(e,t));let r=e.boxZoom=new EM(e,t,this._transformProvider);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();let n=e.cooperativeGestures=new eE(e,t.cooperativeGestures);this._add("cooperativeGestures",n),t.cooperativeGestures&&n.enable();let s=new CM(e,this._transformProvider),o=new XM(e,this._transformProvider);e.doubleClickZoom=new YM(o,s),this._add("tapZoom",s),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let a=new JM;this._add("tapDragZoom",a);let l=e.touchPitch=new GM(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let h=()=>this._camera.transform.centerPoint,u=kM(t,h),c=function({enable:t,clickTolerance:e,pitchSpeed:i=-.5}){return new zM({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new PM({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button}),enable:t,assignEvents:IM})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){return new zM({clickTolerance:e,move:(t,e)=>{let n=r(),s=(e.x-t.x)*i;return e.y<n.y&&(s=-s),{rollDelta:s}},moveStateManager:new PM({checkCorrectEvent:t=>2===t.button&&t.ctrlKey}),enable:t,assignEvents:IM})}(t,h);e.dragRotate=new QM(t,u,c,f),this._add("mouseRotate",u,["mousePitch"]),this._add("mousePitch",c,["mouseRotate","mouseRoll"]),this._add("mouseRoll",f,["mousePitch"]),t.interactive&&t.dragRotate&&e.dragRotate.enable();let p=function({enable:t,clickTolerance:e}){return new zM({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new PM({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey}),enable:t,assignEvents:IM})}(t),d=new $M(t,e);e.dragPan=new KM(i,p,d),this._add("mousePan",p),this._add("touchPan",d,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&e.dragPan.enable(t.dragPan);let m=new UM,_=new BM;e.touchZoomRotate=new tE(i,_,m,a),this._add("touchRotate",m,["touchPan","touchZoom"]),this._add("touchZoom",_,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&e.touchZoomRotate.enable(t.touchZoomRotate),this._add("blockableMapEvent",new MM(e,t),["touchPan"]);let g=e.scrollZoom=new HM(e,(()=>this._triggerRenderFrame()),this._transformProvider);this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let y=e.keyboard=new VM(e,this._transformProvider);this._add("keyboard",y),t.interactive&&t.keyboard&&e.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(let{handler:t}of this._handlers)t.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{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!!rE(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,e,i){for(let r in t)if(r!==i&&!e?.includes(r))return!0;return!1}_getMapTouches(t){let e=[];for(let i of t)this._el.contains(i.target)&&e.push(i);return e}mergeHandlerResult(t,e,i,r,n){if(!i)return;St(t,i);let s={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(e.zoom=s),void 0!==i.panDelta&&(e.drag=s),void 0!==i.rollDelta&&(e.roll=s),void 0!==i.pitchDelta&&(e.pitch=s),void 0!==i.bearingDelta&&(e.rotate=s)}_applyChanges(){let t={},e={},i={};for(let[r,n,s]of this._changes)r.panDelta&&(t.panDelta=(t.panDelta||new f(0,0))._add(r.panDelta)),r.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(t.rollDelta=(t.rollDelta||0)+r.rollDelta),void 0!==r.around&&(t.around=r.around),void 0!==r.pinchAround&&(t.pinchAround=r.pinchAround),r.noInertia&&(t.noInertia=r.noInertia),St(e,n),St(i,s);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){let r=this._map.terrain;if(!sE(t))return void this._fireEvents(e,i,!0);let n=this._camera.getTransformForUpdate();this._camera.stop(!0);let{panDelta:s,zoomDelta:o,bearingDelta:a,pitchDelta:l,rollDelta:h}=t;o>0&&this._terrainGesture.inFlight&&this._camera.moveCenterOntoTerrain(n,o);let{around:u,aroundOnSurface:c}=this._resolveAround(t,r,n),f=r?this._terrainGestureElevation(r,u,c,n,e):void 0,p={panDelta:s,zoomDelta:o,rollDelta:h,pitchDelta:l,bearingDelta:a,around:u,aroundElevation:f};this._camera.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(u)&&(u=n.centerPoint);let d=this._computePreZoomAroundLoc(n,u,s,f);this._handleMapControls({terrain:r,tr:n,deltasForHelper:p,preZoomAroundLoc:d,combinedEventsInProgress:e,panDelta:s}),this._camera.applyUpdatedTransform(n),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(e,i,!0)}_resolveAround(t,e,i){let r=void 0===t.pinchAround?t.around:t.pinchAround;return r||=this._camera.transform.centerPoint,e&&!i.isPointOnMapSurface(r)?{around:i.centerPoint,aroundOnSurface:!1}:{around:r,aroundOnSurface:!0}}_terrainGestureElevation(t,e,i,r,n){if(!i)return;if(this._terrainGesture.anchorCenterElevation!==r.elevation&&(n.drag||n.zoom)){let i=r.screenTerrainPointToMercatorCoordinate(e,t);this._terrainGesture.anchorElevation=i?i.z:void 0,this._terrainGesture.anchorCenterElevation=r.elevation}let s=this._terrainGesture.anchorElevation;return null==s||e.distSqr(r.centerPoint)<.01||s-r.elevation>=.9*(r.getCameraAltitude()-r.elevation)?void 0:s}_computePreZoomAroundLoc(t,e,i,r){if(e.distSqr(t.centerPoint)<.01)return t.center;let n=i?e.sub(i):e;return void 0===r?t.screenPointToLocation(n):t.screenPointToLocationAtElevation(n,r)}_handleMapControls({terrain:t,tr:e,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:n,panDelta:s}){let o=this._camera.cameraHelper;if(o.handleMapControlsRollPitchBearingZoom(i,e),t||o.useGlobeControls||e.isPointOnMapSurface(i.around)){if(t)return this._terrainGesture.inFlight?void(!o.useGlobeControls&&void 0===i.aroundElevation&&n.drag&&s?e.setCenter(e.screenPointToLocation(e.centerPoint.sub(s))):o.handleMapControlsPan(i,e,r)):(this._terrainGesture.inFlight=!0,this._camera.holdElevation(e,"gesture"),void o.handleMapControlsPan(i,e,r));o.handleMapControlsPan(i,e,r)}else s&&e.setCenter(e.screenPointToLocation(e.centerPoint.sub(s)))}_fireEvents(t,e,i){let r=rE(this._eventsInProgress),n=rE(t),s={};for(let e in t){let{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&n&&this._fireEvent("movestart",n.originalEvent);for(let t in s)this._fireEvent(t,s[t]);n&&this._fireEvent("move",n.originalEvent);for(let e in t){let{originalEvent:i}=t[e];this._fireEvent(e,i)}let o,a={};for(let t in this._eventsInProgress){let{handlerName:i,originalEvent:r}=this._eventsInProgress[t];this._handlersById[i].isActive()||(delete this._eventsInProgress[t],o=e[i]||r,a[`${t}end`]=o)}for(let t in a)this._fireEvent(t,a[t]);let l=rE(this._eventsInProgress),h=(r||n)&&!l;if(h&&this._terrainGesture.inFlight){let t=this._camera.releaseElevation();this._terrainGesture={inFlight:!1,anchorElevation:null,anchorCenterElevation:null},this._camera.applyTransformChange((e=>{this._map.getCenterClampedToGround()&&(this._map.terrain?this._camera.putCenterBackOnTerrain(e,this._map.terrain,t):e.setElevation(0))}))}if(i&&h){this._updatingCamera=!0;let t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),e=t=>0!==t&&-this._bearingSnap<t&&t<this._bearingSnap;!t||!t.essential&&fe.prefersReducedMotion?(this._fireEvent("moveend",o),e(this._map.getBearing())&&this._map.resetNorth()):(e(t.bearing||this._map.getBearing())&&(t.bearing=0),t.freezeElevation=!0,this._map.easeTo(t,{originalEvent:o})),this._updatingCamera=!1}}_fireEvent(t,e){this._camera.fire(new Be(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new nE("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},aE=class{constructor(t,e){this.holder=t,this.startedWithoutDem=e,this.lift=null,this._terrainChanged=!1,this.awaitsDem=e}get tookDem(){return this.startedWithoutDem&&!this.awaitsDem}noteTerrainChange(){this.startedWithoutDem&&(this._terrainChanged=!0)}take(t,e){let i=!1;if(this._terrainChanged&&(this._terrainChanged=!1,e.hasElevationForLngLat(t.center,t)||(t.setElevation(0),this.awaitsDem=!0,i=!0)),!this.awaitsDem)return i;let r=e.getDrawnElevationForLngLat(t.center,!0);if(void 0!==r)return t.setElevation(r),this.awaitsDem=!1,!0;let n=e.getDrawnElevationForLngLat(t.center);return void 0===n||n<=t.elevation||t.getCameraAltitude()>=e.getElevationForLngLatZoom(t.getCameraLngLat(),t.zoom)?i:(t.setElevation(n),!0)}},lE=class extends Re{constructor(t){super(),this._elevationHold=null,this._renderFrameCallback=()=>{let t=Math.min((de()-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.transform=new Bw,this.cameraHelper=new Zw,void 0!==t.minZoom&&this.transform.setMinZoom(t.minZoom),void 0!==t.maxZoom&&this.transform.setMaxZoom(t.maxZoom),void 0!==t.minPitch&&this.transform.setMinPitch(t.minPitch),void 0!==t.maxPitch&&this.transform.setMaxPitch(t.maxPitch),void 0!==t.renderWorldCopies&&this.transform.setRenderWorldCopies(t.renderWorldCopies),null!==t.transformConstrain&&this.transform.setConstrainOverride(t.transformConstrain),this._moving=!1,this._zooming=!1,this._bearingSnap=t.bearingSnap,this._zoomSnap=t.zoomSnap,this._requestRenderFrame=t.requestRenderFrame,this._cancelRenderFrame=t.cancelRenderFrame,this.terrain=t.terrain,this._centerClampedToGround=t.centerClampedToGround??!0,this.transformCameraUpdate=t.transformCameraUpdate??null,this._stopHandlers=t.stopHandlers??(()=>{}),this.on("moveend",(()=>{delete this._requestedCameraState}))}setTerrain(t){this.terrain=t,t&&this._elevationHold?.noteTerrainChange(),this.applyTerrainChange()}migrateProjection(t,e){if(t.apply(this.transform,!0),this.transform=t,this.cameraHelper=e,this._requestedCameraState){let e=t.clone();e.apply(this._requestedCameraState,!0),this._requestedCameraState=e}}getCenter(){return new Cc(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,e,i){return t=f.convert(t).mult(-1),this.panTo(this.transform.center,St({offset:t},e),i)}panTo(t,e,i){return this.easeTo(St({center:t},e),i)}getZoom(){return this.transform.zoom}setZoom(t,e){return this.jumpTo({zoom:t},e),this}zoomTo(t,e,i){return this.easeTo(St({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(kt(this.getZoom()+1,this._zoomSnap),t,e),this}zoomOut(t,e){return this.zoomTo(kt(this.getZoom()-1,this._zoomSnap),t,e),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,e){return t!=this.transform.fov&&(this.applyTransformChange((e=>e.setFov(t))),this.fire(new Be("movestart",e)).fire(new Be("move",e)).fire(new Be("moveend",e))),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,e,i){return this.easeTo(St({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,St({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(St({bearing:0,pitch:0,roll:0,duration:1e3},t),e),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=Um.convert(t).adjustAntiMeridian();let i=e?.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),i,e)}_cameraForBoxAndBearing(t,e,i,r){let n={top:0,bottom:0,right:0,left:0};if("number"==typeof(r=St({padding:n,offset:[0,0],maxZoom:this.transform.maxZoom},r)).padding){let t=r.padding;r.padding={top:t,bottom:t,right:t,left:t}}let s=St(n,r.padding);r.padding=s;let o=this.transform,a=new Um(t,e),l={top:0,bottom:0,right:0,left:0},h=r.absolutePadding?l:s,u=r.absolutePadding?s:St(l,o.padding),c=this.cameraHelper.cameraForBoxAndBearing(r,h,u,a,i,o);if(c)return this._zoomSnap&&(c.zoom=kt(c.zoom,this._zoomSnap,-1)),r.absolutePadding?{...c,padding:s}:c}fitBounds(t,e,i){return this._fitInternal(this.cameraForBounds(t,e),e,i)}fitScreenCoordinates(t,e,i,r,n){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.screenPointToLocation(f.convert(t)),this.transform.screenPointToLocation(f.convert(e)),i,r),r,n)}_fitInternal(t,e,i){return t?((e=St(t,e)).absolutePadding?(e.padding=t.padding,delete e.absolutePadding):delete e.padding,e.linear?this.easeTo(e,i):this.flyTo(e,i)):this}jumpTo(t,e){this.stop(),void 0!==t.zoom&&this._zoomSnap&&(t.zoom=kt(t.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,n=!1,s=!1,o=i.zoom;this.terrain&&this.getCenterClampedToGround()&&i.setElevation(this.terrain.getElevationForLngLat(t.center?Cc.convert(t.center):i.center,i)),this.cameraHelper.handleJumpToCenterZoom(i,t);let a=i.zoom!==o;return void 0!==t.elevation&&i.elevation!==+t.elevation&&i.setElevation(+t.elevation),void 0!==t.bearing&&i.bearing!==+t.bearing&&(r=!0,i.setBearing(+t.bearing)),void 0!==t.pitch&&i.pitch!==+t.pitch&&(n=!0,i.setPitch(+t.pitch)),void 0!==t.roll&&i.roll!==+t.roll&&(s=!0,i.setRoll(+t.roll)),null!=t.padding&&!i.isPaddingEqual(t.padding)&&i.setPadding(t.padding),this.applyUpdatedTransform(i),this.fire(new Be("movestart",e)).fire(new Be("move",e)),a&&this.fire(new Be("zoomstart",e)).fire(new Be("zoom",e)).fire(new Be("zoomend",e)),r&&this.fire(new Be("rotatestart",e)).fire(new Be("rotate",e)).fire(new Be("rotateend",e)),n&&this.fire(new Be("pitchstart",e)).fire(new Be("pitch",e)).fire(new Be("pitchend",e)),s&&this.fire(new Be("rollstart",e)).fire(new Be("roll",e)).fire(new Be("rollend",e)),this.fire(new Be("moveend",e))}calculateAnchoredCameraOptions(t){let e=this.transform.clone(),i=Cc.convert(t.anchorLocation),r=f.convert(t.anchorScreenPoint),n={panDelta:r.sub(this.transform.locationToScreenPoint(i,this.terrain)),zoomDelta:void 0===t.zoom?0:t.zoom-e.zoom,bearingDelta:0,pitchDelta:0,rollDelta:0,around:r,aroundElevation:this.terrain?.getElevationForLngLat(i,e)};return this.cameraHelper.handleMapControlsRollPitchBearingZoom(n,e),this.cameraHelper.handleMapControlsPan(n,e,i),{center:e.center,zoom:e.zoom}}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n){let s=this.transform.calculateCenterFromCameraLngLatAlt(t,e,i,r);return{center:s.center,elevation:s.elevation,zoom:s.zoom,bearing:i,pitch:r,roll:n}}easeTo(t,e){this._stop(!1,t.easeId),void 0!==(t=St({offset:[0,0],duration:500,easing:Et},t)).zoom&&this._zoomSnap&&(t.zoom=kt(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&fe.prefersReducedMotion)&&(t.duration=0);let i,r,n=this.getTransformForUpdate(),s=this.getBearing(),o=n.pitch,a=n.roll,l=void 0===t.bearing?s:this._normalizeBearing(t.bearing,s),h=void 0===t.pitch?o:+t.pitch,u=void 0===t.roll?a:this._normalizeBearing(t.roll,a),c=void 0===t.padding?n.padding:t.padding,p=f.convert(t.offset);t.around&&(i=Cc.convert(t.around),r=n.locationToScreenPoint(i));let d={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching,rolling:this._rolling},m=this.cameraHelper.handleEaseTo(n,{bearing:l,pitch:h,roll:u,padding:c,around:i,aroundPoint:r,offsetAsPoint:p,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating||=s!==l,this._pitching||=h!==o,this._rolling||=u!==a,this._padding=!n.isPaddingEqual(c),this._zooming||=m.isZooming,this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,d,{tr:n,center:m.elevationCenter,freeze:t.freezeElevation}),this._ease((i=>{m.easeFunc(i),this.terrain&&!t.freezeElevation&&this._updateElevation(i,n),this.applyUpdatedTransform(n),this._fireMoveEvents(e)}),(i=>{this._afterEase(e,i,t.freezeElevation)}),t),this}_prepareEase(t,e,i={},r){this._moving=!0,this.terrain&&r&&(this._prepareElevation(r.center,r.tr),r.freeze&&this.holdElevation(r.tr,"animation")),!e&&!i.moving&&this.fire(new Be("movestart",t)),this._zooming&&!i.zooming&&this.fire(new Be("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new Be("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new Be("pitchstart",t)),this._rolling&&!i.rolling&&this.fire(new Be("rollstart",t))}_prepareElevation(t,e){this._elevationCenter=t,this._elevationStart=e.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(t,e),this.elevationFreeze=!0}_updateElevation(t,e){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(e.center,e),e.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,e.tileZoom));let i=this.terrain.getElevationForLngLat(this._elevationCenter,e);if(t<1&&i!==this._elevationTarget){let e=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(e-(i-(e*t+this._elevationStart))/(1-t)),this._elevationTarget=i}this.getCenterClampedToGround()&&e.setElevation(Sr.number(this._elevationStart,this._elevationTarget,t))}holdElevation(t,e){this.elevationFreeze=!0;let i=!!this.terrain&&this.getCenterClampedToGround()&&!this.terrain.hasElevationForLngLat(t.center,t);this._elevationHold=new aE(e,i)}releaseElevation(){let t=this._elevationHold?.tookDem??!1;return this.elevationFreeze=!1,this._elevationHold=null,t}putCenterBackOnTerrain(t,e,i){if(i&&void 0===e.getDrawnElevationForLngLat(t.center,!0)){t.setElevation(e.getElevationForLngLat(t.center,t));let i=this._raiseCameraByPitchAndZoom(t);i!==t&&t.apply(i,!1)}else t.recalculateZoomAndCenter(e)}_takeLandedElevation(t){return!!(this._elevationHold&&this.terrain&&this.getCenterClampedToGround())&&this._elevationHold.take(t,this.terrain)}applyTerrainChange(){if(this.elevationFreeze){let t=this._requestedCameraState;return void("gesture"===this._elevationHold?.holder&&t&&this._takeLandedElevation(t)&&this.applyUpdatedTransform(t))}let t=this.transform;t.setMinElevationForCurrentTile(this.terrain?this.terrain.getMinTileElevationForLngLatZoom(t.center,t.tileZoom):0),this.getCenterClampedToGround()&&t.setElevation(this.terrain?this.terrain.getElevationForLngLat(t.center,t):0)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_keepCameraAboveTerrain(t){let e=this._elevationHold;if(!this.terrain||"gesture"!==e?.holder||t.pitch>=90||!this.getCenterClampedToGround()||t.getClippingPlane())return this._raiseCameraByPitchAndZoom(t);let i=e.lift&&e.lift.heldElevation+e.lift.height===t.elevation?e.lift:{heldElevation:t.elevation,height:0},r=Math.max(0,this._terrainHeightAboveCamera(t)+i.height);return r!==i.height&&t.setElevation(i.heldElevation+r),e.lift=r>0?{heldElevation:i.heldElevation,height:r}:null,t}_raiseCameraByPitchAndZoom(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90||t.getClippingPlane())return t;let e=t.getCameraLngLat(),i=this.terrain?this._terrainHeightAboveCamera(t):-t.getCameraAltitude();if(i<=0)return t;let r=t.clone();for(let t=0;t<3&&i>0;t++){let{zoom:t,pitch:n}=r.calculateCameraOptionsFromTo(e,r.getCameraAltitude()+i,r.center,r.elevation);r.setZoom(t),r.setPitch(n),i=this.terrain?this._terrainHeightAboveCamera(r):-r.getCameraAltitude()}return r}_terrainHeightAboveCamera(t){let e=this.terrain.getElevationForLngLat(t.getCameraLngLat(),t)-t.getCameraAltitude(),i=t.getClippingPlane()?null:this.terrain.getCoverageIndex();if(!i)return e;let[r,n,s,o]=t.getCameraFrustum().points;for(let t=0;t<=2;t++){let a=t/2;for(let t=0;t<=2;t++){let l=t/2,h=(1-l)*(1-a),u=l*(1-a),c=l*a,f=(1-l)*a,p=h*r[2]+u*n[2]+c*s[2]+f*o[2],d=jw(i,this.terrain.exaggeration,h*r[0]+u*n[0]+c*s[0]+f*o[0],h*r[1]+u*n[1]+c*s[1]+f*o[1]);d.covered&&(e=Math.max(e,d.elevation-p))}}return e}moveCenterOntoTerrain(t,e){if(!this.terrain||!this.getCenterClampedToGround()||t.getClippingPlane())return;let{center:i,elevation:r,zoom:n}=t;t.recalculateZoomAndCenter(this.terrain),(!(t.zoom>n-e&&t.zoom<t.maxZoom)||Math.abs(this.terrain.getElevationForLngLat(t.center,t)-t.elevation)>=1)&&(t.setZoom(n),t.setCenter(i),t.setElevation(r))}applyUpdatedTransform(t){this._takeLandedElevation(t);let e=this._keepCameraAboveTerrain(t);if(!this.transformCameraUpdate)return void(e!==this.transform&&this.transform.apply(e,!1));let i=e.clone(),{center:r,zoom:n,roll:s,pitch:o,bearing:a,elevation:l}=this.transformCameraUpdate(i);r&&i.setCenter(r),void 0!==l&&i.setElevation(l),void 0!==n&&i.setZoom(n),void 0!==s&&i.setRoll(s),void 0!==o&&i.setPitch(o),void 0!==a&&i.setBearing(a),this.transform.apply(void 0===l?i:this._raiseCameraByPitchAndZoom(i),!1)}applyTransformChange(t){let e=void 0!==this._requestedCameraState,i=this.getTransformForUpdate();t(i),this.applyUpdatedTransform(i),e||delete this._requestedCameraState}_fireMoveEvents(t){this.fire(new Be("move",t)),this._zooming&&this.fire(new Be("zoom",t)),this._rotating&&this.fire(new Be("rotate",t)),this._pitching&&this.fire(new Be("pitch",t)),this._rolling&&this.fire(new Be("roll",t))}_afterEase(t,e,i=!1){this._takeLandedElevation(this.transform);let r=this.releaseElevation();if(this.terrain&&i&&this.getCenterClampedToGround()&&this.putCenterBackOnTerrain(this.transform,this.terrain,r),this._easeId&&e&&this._easeId===e)return;delete this._easeId;let n=this._zooming,s=this._rotating,o=this._pitching,a=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new Be("zoomend",t)),s&&this.fire(new Be("rotateend",t)),o&&this.fire(new Be("pitchend",t)),a&&this.fire(new Be("rollend",t)),this.fire(new Be("moveend",t))}flyTo(t,e){if(!t.essential&&fe.prefersReducedMotion){let i=Ct(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,e)}this.stop(),void 0!==(t=St({offset:[0,0],speed:1.2,curve:1.42,easing:Et},t)).zoom&&this._zoomSnap&&(t.zoom=kt(t.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=i.bearing,n=i.pitch,s=i.roll,o=i.padding,a=void 0===t.bearing?r:this._normalizeBearing(t.bearing,r),l=void 0===t.pitch?n:+t.pitch,h=void 0===t.roll?s:this._normalizeBearing(t.roll,s),u=void 0===t.padding?i.padding:t.padding,c=f.convert(t.offset),p=i.centerPoint.add(c),d=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:a,pitch:l,roll:h,padding:u,locationAtOffset:d,offsetAsPoint:c,center:t.center,minZoom:t.minZoom,zoom:t.zoom}),_=t.curve,g=Math.max(i.width,i.height),y=g/m.scaleOfZoom,v=m.pixelPathLength;_=Math.min(_,Math.sqrt(g/m.scaleOfMinZoom/v*2));let w=_*_;function b(t){let e=(y*y-g*g+(t?-1:1)*w*w*v*v)/(2*(t?y:g)*w*v);return Math.log(Math.sqrt(e*e+1)-e)}function x(t){return(Math.exp(t)-Math.exp(-t))/2}function D(t){return(Math.exp(t)+Math.exp(-t))/2}let M=b(!1),E=function(t){return D(M)/D(M+_*t)},A=function(t){return g*((D(M)*function(t){return x(t)/D(t)}(M+_*t)-x(M))/w)/v},F=(b(!0)-M)/_;if(Math.abs(v)<2e-6||!isFinite(F)){if(Math.abs(g-y)<1e-6)return this.easeTo(t,e);let i=y<g?-1:1;F=Math.abs(Math.log(y/g))/_,A=()=>0,E=t=>Math.exp(i*_*t)}return t.duration=void 0!==t.duration?+t.duration:1e3*F/(void 0===t.screenSpeed?+t.speed:+t.screenSpeed/_),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=r!==a,this._pitching=l!==n,this._rolling=h!==s,this._padding=!i.isPaddingEqual(u),this._prepareEase(e,!1,{},{tr:i,center:m.targetCenter,freeze:t.freezeElevation}),this._ease((f=>{let d=f*F,_=1/E(d),g=A(d);this._rotating&&i.setBearing(Sr.number(r,a,f)),this._pitching&&i.setPitch(Sr.number(n,l,f)),this._rolling&&i.setRoll(Sr.number(s,h,f)),this._padding&&(i.interpolatePadding(o,u,f),p=i.centerPoint.add(c)),m.easeFunc(f,_,g,p),this.terrain&&!t.freezeElevation&&this._updateElevation(f,i),this.applyUpdatedTransform(i),this._fireMoveEvents(e)}),(()=>{this._afterEase(e,void 0,t.freezeElevation)}),t),this}isEasing(){return!!this._easeFrameId}stop(t){return this._stop(t)}_stop(t,e){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let t=this._onEaseEnd;delete this._onEaseEnd,t.call(this,e)}return t||this._stopHandlers(),this}_ease(t,e,i){!1===i.animate||0===i.duration?(t(1),e()):(this._easeStart=de(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,e){t=Ft(t,-180,180);let i=Math.abs(t-e);return Math.abs(t-360-e)<i&&(t-=360),Math.abs(t+360-e)<i&&(t+=360),t}isMoving(){return this._moving}isZooming(){return this._zooming}isRotating(){return this._rotating}};const hE={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var uE=class{constructor(t=hE){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&&("terrain"===t.type||"style"===t.dataType||"source"===t.dataType&&("metadata"===t.sourceDataType||"visibility"===t.sourceDataType))&&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=be.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=be.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=be.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){let 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){let t=this._map.style.stylesheet;this.styleOwner=t.owner,this.styleId=t.id}let e=this._map.style.tileManagers;for(let i in e){let r=e[i];if(r.used||r.usedForTerrain){let e=r.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 r=i+1;r<t.length;r++)if(t[r].includes(e))return!1;return!0}));let i=t.join(" | ");if(i!==this._attribHTML){if(this._attribHTML=i,t.length){let e=document.createDocumentFragment(),i=!0;for(let r of t){let t=be.sanitize(r);t.hasChildNodes()&&(i||e.append(" | "),e.append(t),i=!1)}this._innerContainer.replaceChildren(e),this._container.classList.remove("maplibregl-attrib-empty")}else this._container.classList.add("maplibregl-attrib-empty");this._updateCompact(),this._editLink=null}}},cE=class{constructor(t={}){this._updateCompact=()=>{let t=this._container.children;if(t.length){let 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){this._map=t,this._compact=this.options?.compact,this._container=be.create("div","maplibregl-ctrl");let e=be.create("a","maplibregl-ctrl-logo");return e.target="_blank",e.rel="noopener nofollow",e.href="https://maplibre.org/",e.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),e.setAttribute("rel","noopener nofollow"),this._container.appendChild(e),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}},fE=class{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let e=++this._id;return this._queue.push({callback:t,id:e,cancelled:!1}),e}remove(t){let e=this._currentlyRunning,i=e?this._queue.concat(e):this._queue;for(let e of i)if(e.id===t)return void(e.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw Error("Attempting to run(), but is already running.");let e=this._currentlyRunning=this._queue;this._queue=[];let i,r=!1;for(let n of e)if(!n.cancelled){try{n.callback(t)}catch(t){r||(r=!0,i=t)}if(this._cleared)break}if(this._cleared=!1,this._currentlyRunning=!1,r)throw i}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}};const pE=Ea([{name:"a_pos3d",type:"Int16",components:3}]);var dE=class extends Re{constructor(t){super(),this._lastTilesetChange=de(),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,this.releaseAllRTT()}getSource(){return this.tileManager._source}update(t,e){this.tileManager.update(t,e),this._renderableTilesKeys=[];let i={},r=!1;for(let n of lv(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e}))i[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float32Array(16),T(n.terrainRttPosMatrix32f,0,st,st,0,0,1),this._tiles[n.key]=new Xy(n,this.tileSize),this._lastTilesetChange=de(),r=!0);for(let t in this._tiles)i[t]||(this._tiles[t].releaseRTT(this.tileManager.map.painter),delete this._tiles[t],r=!0);return r}releaseRTT(t){for(let e in this._tiles){let i=this._tiles[e];(i.tileID.equals(t)||i.tileID.isChildOf(t)||t.isChildOf(i.tileID))&&i.releaseRTT(this.tileManager.map.painter)}}releaseAllRTT(){for(let t in this._tiles)this._tiles[t].releaseRTT(this.tileManager.map.painter)}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){let e={};for(let i of this._renderableTilesKeys){let r=this._tiles[i].tileID,n=t.clone(),s=ut();if(r.canonical.equals(t.canonical))T(s,0,st,st,0,0,1);else if(r.canonical.isChildOf(t.canonical)){let e=r.canonical.z-t.canonical.z,i=r.canonical.x-(r.canonical.x>>e<<e),n=r.canonical.y-(r.canonical.y>>e<<e),o=st>>e;T(s,0,o,o,0,0,1),E(s,s,[-i*o,-n*o,0])}else{if(!t.canonical.isChildOf(r.canonical))continue;{let e=t.canonical.z-r.canonical.z,i=t.canonical.x-(t.canonical.x>>e<<e),n=t.canonical.y-(t.canonical.y>>e<<e),o=st>>e;T(s,0,st,st,0,0,1),E(s,s,[i*o,n*o,0]),A(s,s,[1/2**e,1/2**e,0])}}n.terrainRttPosMatrix32f=new Float32Array(s),e[i]=n}return e}_getTerrainCoordsForTileRanges(t,e){let i={};for(let r of this._renderableTilesKeys){let n=this._tiles[r].tileID;if(!this._isWithinTileRanges(n,e))continue;let s=t.clone(),o=ut();if(n.canonical.z===t.canonical.z){let e=t.canonical.x-n.canonical.x+t.wrap*(1<<t.canonical.z),i=t.canonical.y-n.canonical.y;T(o,0,st,st,0,0,1),E(o,o,[e*st,i*st,0])}else if(n.canonical.z>t.canonical.z){let e=n.canonical.z-t.canonical.z,i=n.canonical.x-(n.canonical.x>>e<<e)+t.wrap*(1<<n.canonical.z),r=n.canonical.y-(n.canonical.y>>e<<e),s=t.canonical.x-(n.canonical.x>>e),a=t.canonical.y-(n.canonical.y>>e),l=st>>e;T(o,0,l,l,0,0,1),E(o,o,[-i*l+s*st,-r*l+a*st,0])}else{let e=t.canonical.z-n.canonical.z,i=t.canonical.x-(t.canonical.x>>e<<e)+t.wrap*(1<<t.canonical.z),r=t.canonical.y-(t.canonical.y>>e<<e),s=(t.canonical.x>>e)-n.canonical.x,a=(t.canonical.y>>e)-n.canonical.y,l=st<<e;T(o,0,l,l,0,0,1),E(o,o,[i*st+s*l,r*st+a*l,0])}s.terrainRttPosMatrix32f=new Float32Array(o),i[r]=s}return i}getSourceTile(t,e){let i=this.tileManager._source,r=t.overscaledZ-this.deltaZoom;if(r>i.maxzoom&&(r=i.maxzoom),r<i.minzoom)return;this._sourceTileCache[t.key]||=t.scaledTo(r).key;let n=this.findTileInCaches(this._sourceTileCache[t.key]);if(!n?.dem&&e)for(;r>=i.minzoom&&!n?.dem;)n=this.findTileInCaches(t.scaledTo(r--).key);return n}findTileInCaches(t){let e=this.tileManager.getTileByID(t);return e||(e=this.tileManager._outOfViewCache.getByKey(t),e)}anyTilesAfterTime(t=de()){return this._lastTilesetChange>=t}_isWithinTileRanges(t,e){let 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)}},mE=class{constructor(t,e,i,r="auto"){this._meshCache={},this.painter=t,this.tileManager=new dE(e),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this._terrainSkirtLength=r,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache=new Map,this.coverage=new $w(this.tileManager,this.exaggeration)}destroy(){this._fbo&&=(this._fbo.destroy(),null),this._heightMapFbo&&=(this._heightMapFbo.destroy(),null),this._fboDepthTexture&&=(this._fboDepthTexture.destroy(),null),this._emptyDemTexture&&=(this._emptyDemTexture.destroy(),null),this._emptyDepthTexture&&=(this._emptyDepthTexture.destroy(),null);for(let t in this._meshCache)this._meshCache[t].destroy();this._meshCache={},this.tileManager.destruct()}getDEMElevation(t,e,i,r=st){let n=t.normalizeCoordinates(e,i,r);if(!n)return 0;let s=this.coverage.getSampler(n.tileID);return s?s(n.x,n.y,r):0}getElevationForLngLatZoom(t,e){if(!Vm(e,t.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:n}=this._getOverscaledTileIDFromLngLatZoom(t,e);return this.getElevation(i,r%st,n%st,st)}getElevationForLngLat(t,e){let i=this.getDrawnElevationForLngLat(t);return void 0===i?this.getElevationForLngLatZoom(t,this._getFallbackZoom(e)):i}getDrawnElevationForLngLat(t,e=!1){return this.coverage.sample(t,e)}hasElevationForLngLat(t,e){if(void 0!==this.getDrawnElevationForLngLat(t))return!0;let i=this._getFallbackZoom(e);if(!Vm(i,t.wrap()))return!1;let{tileID:r}=this._getOverscaledTileIDFromLngLatZoom(t,i);return!!this.tileManager.getSourceTile(r,!0)?.dem}_getFallbackZoom(t){return Math.min(t.tileZoom,this.tileManager.maxzoom)}getElevation(t,e,i,r=st){return this.getDEMElevation(t,e,i,r)*this.exaggeration}resetElevationCache(){this.coverage.reset()}getCoverageIndex(){return this.coverage.getIndex()}_getDEMTileMatrix(t,e){let i=`${e.tileID.key}/${t.key}`,r=this._demMatrixCache.get(i);if(r)return r;let n=t.canonical.z-e.tileID.canonical.z,s=t.canonical.x-(t.canonical.x>>n<<n),o=t.canonical.y-(t.canonical.y>>n<<n),a=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}(new Float64Array(16),[1/(st<<n),1/(st<<n),0]);return E(a,a,[s*st,o*st,0]),this._demMatrixCache.set(i,a),a}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,e=new Xh({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new au(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new au(t,new Xh({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=x([])}let e=this.tileManager.getSourceTile(t,!0);if(e?.dem&&(!e.demTexture||e.needsTerrainPrepare)){let t=this.painter.context;e.demTexture||=this.painter.getTileTexture(e.dem.stride),e.demTexture?e.demTexture.update(e.dem.getPixels(),{premultiply:!1}):e.demTexture=new au(t,e.dem.getPixels(),t.gl.RGBA,{premultiply:!1}),e.demTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),e.needsTerrainPrepare=!1}let i=e?this._getDEMTileMatrix(t,e):this._emptyDemMatrix;return{u_depth:2,u_terrain:3,u_terrain_dim:e?.dem?.dim||1,u_terrain_matrix:i,u_terrain_unpack:e?.dem?.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(e?.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:e}}getFramebuffer(){let t=this.painter,e=t.width/devicePixelRatio,i=t.height/devicePixelRatio;return this._fbo&&(this._fbo.width!==e||this._fbo.height!==i)&&(this._fbo.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture),this._fboDepthTexture||(this._fboDepthTexture=new au(t.context,{width:e,height:i,data:null},t.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(t.context.gl.NEAREST,t.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=t.context.createFramebuffer(e,i,!0,!1),this._fbo.depthAttachment.set(t.context.createRenderbuffer(t.context.gl.DEPTH_COMPONENT16,e,i))),this._fbo.colorAttachment.set(this._fboDepthTexture.texture),this._fbo}getHeightMapFramebuffer(t){return this._heightMapFbo||=this.painter.context.createFramebuffer(1,1,!1,!1),this._heightMapFbo.colorAttachment.set(t),this._heightMapFbo}getTerrainMesh(t,e){let i=e&&0===t.canonical.y,r=e&&t.canonical.y===(1<<t.canonical.z)-1,n=`m_${i?"n":""}_${r?"s":""}`;if(this._meshCache[n])return this._meshCache[n];let s=this.painter.context,o=new ul,a=new Al,l=this.meshSize,h=st/l,u=l*l;for(let t=0;t<=l;t++)for(let e=0;e<=l;e++)o.emplaceBack(e*h,t*h,0);for(let t=0;t<u;t+=l+1)for(let e=0;e<l;e++)a.emplaceBack(e+t,l+e+t+1,l+e+t+2),a.emplaceBack(e+t,l+e+t+2,e+t+1);"none"!==this._terrainSkirtLength&&this._buildSkirts(o,a,l,h,i,r);let c=new p_(s.createVertexBuffer(o,pE.members),s.createIndexBuffer(a),zl.simpleSegment(0,0,o.length,a.length));return this._meshCache[n]=c,c}getSkirtLength(t){return 2*Math.PI*Sc/2**Math.max(t,0)/5}getMinTileElevationForLngLatZoom(t,e){if(!Vm(e,t.wrap()))return 0;let{tileID:i}=this._getOverscaledTileIDFromLngLatZoom(t,e);return this.getMinMaxElevation(i).minElevation??0}getMinMaxElevation(t){let e=this.tileManager.getSourceTile(t,!0),i={minElevation:null,maxElevation:null};return e?.dem&&(i.minElevation=e.dem.min*this.exaggeration,i.maxElevation=e.dem.max*this.exaggeration),i}_getOverscaledTileIDFromLngLatZoom(t,e){let i=Oc.fromLngLat(t.wrap()),r=(1<<e)*st,n=i.x*r,s=i.y*r;return{tileID:new Hm(e,0,e,Math.floor(n/st),Math.floor(s/st)),mercatorX:n,mercatorY:s}}_buildSkirts(t,e,i,r,n,s){let o=t.length,a=o+(i+1),l=(i+1)*i,h=n?ec:0,u=+!n,c=s?ic:st,f=+!s;for(let e=0;e<=i;e++)t.emplaceBack(e*r,h,u);for(let e=0;e<=i;e++)t.emplaceBack(e*r,c,f);for(let t=0;t<i;t++)e.emplaceBack(l+t,a+t,a+t+1),e.emplaceBack(l+t,a+t+1,l+t+1),e.emplaceBack(0+t,o+t+1,o+t),e.emplaceBack(0+t,0+t+1,o+t+1);let p=t.length,d=p+2*(i+1);for(let e of[0,1])for(let n=0;n<=i;n++)for(let i of[0,1])t.emplaceBack(e*st,n*r,i);for(let t=0;t<2*i;t+=2)e.emplaceBack(p+t,p+t+1,p+t+3),e.emplaceBack(p+t,p+t+3,p+t+2),e.emplaceBack(d+t,d+t+3,d+t+1),e.emplaceBack(d+t,d+t+2,d+t+3)}};const _E=["none","zoom","sourceTiles","visibleLayers","revision"];var gE=class{constructor(t,e,i,r){this._tileKeys=t.map((t=>t.key)).sort().join(),this._revision=e,this._zoom=i,this._visibleLayerIds=r}difference(t){return this._revision===t?._revision?this._visibleLayerIds===t._visibleLayerIds?this._tileKeys===t._tileKeys?this._zoom===t._zoom?"none":"zoom":"sourceTiles":"visibleLayers":"revision"}};const yE={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};function vE(t){return Jd(t)?`custom-layer:${t.id}`:t.source}function wE(t){return Jd(t)?void 0!==t.implementation.renderToTerrainTile:!0===yE[t.type]}var bE=class{constructor(t,e){this.needsFollowUpFrame=!1,this.painter=t,this.terrain=e,this.rttSize=e.tileManager.tileSize*e.qualityFactor}getTexture(t){return t.getRTT(this._stacks.length-1).texture}prepareForRender(t,e,i){let r=e!==this._lastPrepareZoom;this._lastPrepareZoom=e,this._stacks=[],this._prevRenderedToTexture=!1,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e)));let n=this._renderableLayerIds.join(),s=new Set;for(let e of this._renderableLayerIds){let i=t._layers[e],r=i.source;r&&yE[i.type]&&s.add(r)}this._coordsAscending={},this._rttFingerprints={};for(let i of s){let r=t.tileManagers[i];if(!r)continue;this._coordsAscending[i]={};let s=this._coordsAscending[i],o=r.getSource(),a=o instanceof __?o.terrainTileRanges:null;for(let t of r.getVisibleCoordinates()){let e=this.terrain.tileManager.getTerrainCoords(t,a);for(let t in e)s[t]||=[],s[t].push(e[t])}this._rttFingerprints[i]={};let l=this._rttFingerprints[i],h=r.getState().revision;for(let t in s)l[t]=new gE(s[t],h,e,n)}for(let i of this._renderableLayerIds){let r=t._layers[i];if(!Jd(r)||!wE(r))continue;let s=r.implementation.terrainTileRevision??0,o={};for(let t of this._renderableTiles)o[t.tileID.key]=new gE([t.tileID],s,e,n);this._rttFingerprints[vE(r)]=o}this.needsFollowUpFrame=!1;let o=r||i,a=!1;for(let t of this._renderableTiles){let e=this._textureDifference(t);"none"!==e&&("zoom"===e&&o||"visibleLayers"===e&&r?this.needsFollowUpFrame=!0:"zoom"===e||"sourceTiles"===e?(a?this.needsFollowUpFrame=!0:t.releaseRTT(this.painter),a=!0):t.releaseRTT(this.painter))}}_textureDifference(t){let e="none";for(let i in this._rttFingerprints){let r=this._rttFingerprints[i][t.tileID.key];if(!r)continue;let n=r.difference(t.rttFingerprint[i]);_E.indexOf(n)>_E.indexOf(e)&&(e=n)}return e}renderLayer(t,e,i){if(t.isHidden(i.transform.zoom))return!1;let r=wE(t),n=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(r&&(this._prevRenderedToTexture||this._stacks.push([]),this._prevRenderedToTexture=!0,this._stacks[this._stacks.length-1].push(t.id),!s))return!0;if(this._prevRenderedToTexture||r&&s){this._prevRenderedToTexture=r;let t=this._stacks.length-1,s=this._stacks[t]||[];i.isRenderingToTexture=!0,Mx(n.context.frameUniformBuffer,this.rttSize,this.rttSize);for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(t))continue;let o=r.acquireRTT(n,t,this.rttSize);n.bindRTT(o),n.context.clear({color:nr.transparent,stencil:0}),i.invalidateTileClippingMasks();for(let t of s){let s=e._layers[t],o=s.source?this._coordsAscending[s.source][r.tileID.key]:[r.tileID];n.context.viewport.set([0,0,this.rttSize,this.rttSize]),i.renderTileClippingMasks(s,o),n.renderLayer(n,e.tileManagers[s.source],s,o,i);let a=vE(s);a&&(r.rttFingerprint[a]=this._rttFingerprints[a][r.tileID.key])}o.texture.generateMipmap()}return i.isRenderingToTexture=!1,Mx(n.context.frameUniformBuffer,n.context.gl.drawingBufferWidth,n.context.gl.drawingBufferHeight),function(t,e,i,r){let{isRenderingGlobe:n}=r.data,s=t.context,o=s.gl,a=r.transform,l=r.colorModeForRenderPass(),h=r.getDepthModeFor3D(),u=r.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,t.width,t.height]);for(let c of i){let i=e.getTerrainMesh(c.tileID,n),f=t.renderToTexture.getTexture(c),p=e.getTerrainData(c.tileID);s.activeTexture.set(o.TEXTURE0),f.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let d=e.getSkirtLength(a.zoom),m=a.calculateFogMatrix(c.tileID.toUnwrapped()),_=zx(d,m,r.data.sky,a.pitch,n),g=r.getProjectionDataForTile(c.tileID,{applyTerrainMatrix:!1});u.draw(s,o.TRIANGLES,h,fD.disabled,l,dD.backCCW,_,p,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],r}return!1}};const xE={"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"},DE=c,ME={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:hE,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:xe.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,transformConstrain:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,rollEnabled:!1,rotateSpeed:.8,pitchSpeed:-.5,reduceMotion:void 0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0,centerClampedToGround:!0,terrainSkirtLength:"auto",zoomLevelsToOverscale:4,anisotropicFilterPitch:20};var EE=class extends Re{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new fE,this._controls=[],this._mapId=Tt(),this._styleUrl=null,this._missingStyleImageResolver=null,this._lostContextStyle={style:null,images:null},this._contextLost=t=>{if(t.preventDefault(),this._frameRequest&&=(this._frameRequest.abort(),null),this.painter.destroy(),this._lostContextStyle=this._getStyleAndImages(),this.style){for(let 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(let[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 Ye("webglcontextlost",{originalEvent:t}))}else this.fire(new Ye("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{if(this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&this.style){this.style.imageManager.images=this._lostContextStyle.images;for(let t in this._lostContextStyle.images){let e=this._lostContextStyle.images[t];e.isWebGLImage&&this.style.imageManager.updateImage(t,e,!1)}}this._lostContextStyle={style:null,images:null};try{this._setupPainter()}catch(t){return void this.fire(new je(t))}this.resize(),this._update(),this._resizeInternal(),this.fire(new Ye("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()};let e={...ME,...t,canvasContextAttributes:{...ME.canvasContextAttributes,...t.canvasContextAttributes}};if(null!=e.minZoom&&null!=e.maxZoom&&e.minZoom>e.maxZoom)throw Error("maxZoom must be greater than or equal to minZoom");if(null!=e.minPitch&&null!=e.maxPitch&&e.minPitch>e.maxPitch)throw Error("maxPitch must be greater than or equal to minPitch");if(null!=e.minPitch&&e.minPitch<0)throw Error("minPitch must be greater than or equal to 0");if(null!=e.maxPitch&&e.maxPitch>180)throw Error("maxPitch must be less than or equal to 180");this._camera=new lE({minZoom:e.minZoom,maxZoom:e.maxZoom,minPitch:e.minPitch,maxPitch:e.maxPitch,bearingSnap:e.bearingSnap,zoomSnap:e.zoomSnap,renderWorldCopies:e.renderWorldCopies,centerClampedToGround:e.centerClampedToGround,terrain:this.terrain,transformConstrain:e.transformConstrain,requestRenderFrame:t=>this._requestRenderFrame(t),cancelRenderFrame:t=>this._cancelRenderFrame(t),transformCameraUpdate:e.transformCameraUpdate,stopHandlers:()=>this._handlers?.stop(!1)}),this._camera.setEventedParent(this),this._interactive=e.interactive,this._maxTileCacheSize=e.maxTileCacheSize,this._maxTileCacheZoomLevels=e.maxTileCacheZoomLevels,this._canvasContextAttributes={...e.canvasContextAttributes},this._trackResize=!0===e.trackResize,this._terrainSkirtLength=e.terrainSkirtLength,this._refreshExpiredTiles=!0===e.refreshExpiredTiles,this._fadeDuration=e.fadeDuration,this._crossSourceCollisions=!0===e.crossSourceCollisions,this._collectResourceTiming=!0===e.collectResourceTiming,this._locale={...xE,...e.locale},this._clickTolerance=e.clickTolerance,this._overridePixelRatio=e.pixelRatio,this._maxCanvasSize=e.maxCanvasSize,this._zoomLevelsToOverscale=e.zoomLevelsToOverscale,this.cancelPendingTileRequestsWhileZooming=!0===e.cancelPendingTileRequestsWhileZooming,this.setAnisotropicFilterPitch(e.anisotropicFilterPitch),void 0!==e.reduceMotion&&(fe.prefersReducedMotion=e.reduceMotion),this._requestManager=new Pe(e.transformRequest),this._container=this._resolveContainer(e.container),e.maxBounds&&this.setMaxBounds(e.maxBounds),this._setupContainer();try{this._setupPainter()}catch(t){throw this._cleanupContainer(),t}this._imageQueueHandle=Te.addThrottleControl((()=>this.isMoving())),this.on("move",(()=>this._update(!1))),this.on("moveend",(()=>this._update(!1))),this.on("zoom",(()=>this._update(!0))),this.on("terrain",(()=>{this.painter.markTerrainDepthDirty(),this._update(!0)})),this.once("idle",(()=>this._idleTriggered=!0)),this._handlers=new oE(this,this._camera,e),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this._hash=e.hash?new pM("string"==typeof e.hash&&e.hash||void 0).addTo(this):void 0,this._hash?._onHashChange()||(this.jumpTo({center:e.center,elevation:e.elevation,zoom:e.zoom,bearing:e.bearing,pitch:e.pitch,roll:e.roll}),e.bounds&&(this.resize(),this.fitBounds(e.bounds,St({},e.fitBoundsOptions,{duration:0}))));let i="string"==typeof e.style||"globe"!==e.style?.projection?.type;this.resize(null,i),this._localIdeographFontFamily=e.localIdeographFontFamily,this._validateStyle=e.validateStyle,e.style&&this.setStyle(e.style,{localIdeographFontFamily:e.localIdeographFontFamily}),e.attributionControl&&this.addControl(new uE("boolean"==typeof e.attributionControl?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new cE,e.logoPosition),this.on("style.load",(()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=Ct(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(t)}})),this.on("data",(t=>{this._update("style"===t.dataType),this.fire("style"===t.dataType?new Ue("styledata",t):new Ne("sourcedata",t))})),this.on("dataloading",(t=>{this.fire("style"===t.dataType?new Ue("styledataloading",t):new Ne("sourcedataloading",t))})),this.on("dataabort",(t=>{this.fire(new Ne("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,e){if(void 0===e&&(e=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t?.onAdd)return this.fire(new je(Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let i=t.onAdd(this);this._controls.push(t);let r=this._controlPositions[e];return e.includes("bottom")?r.insertBefore(i,r.firstChild):r.appendChild(i),this}removeControl(t){if(!t?.onRemove)return this.fire(new je(Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let e=this._controls.indexOf(t);return e>-1&&this._controls.splice(e,1),t.onRemove(this),this}hasControl(t){return this._controls.includes(t)}coveringTiles(t){return lv(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new Cc(this._camera.transform.center.lng,this._camera.transform.center.lat)}setCenter(t,e){return this._camera.setCenter(t,e),this}getCenterElevation(){return this._camera.transform.elevation}setCenterElevation(t,e){return this._camera.setCenterElevation(t,e),this}setCenterClampedToGround(t){this._camera.setCenterClampedToGround(t)}panBy(t,e,i){return this._camera.panBy(t,e,i),this}panTo(t,e,i){return this._camera.panTo(t,e,i),this}getZoom(){return this._camera.transform.zoom}setZoom(t,e){return this._camera.setZoom(t,e),this}zoomTo(t,e,i){return this._camera.zoomTo(t,e,i),this}zoomIn(t,e){return this._camera.zoomIn(t,e),this}zoomOut(t,e){return this._camera.zoomOut(t,e),this}getVerticalFieldOfView(){return this._camera.transform.fov}setVerticalFieldOfView(t,e){return this._camera.setVerticalFieldOfView(t,e),this}getBearing(){return this._camera.transform.bearing}setBearing(t,e){return this._camera.setBearing(t,e),this}getZoomSnap(){return this._camera.getZoomSnap()}setZoomSnap(t){return this._camera.setZoomSnap(t),this}getPadding(){return this._camera.transform.padding}setPadding(t,e){return this._camera.setPadding(t,e),this}rotateTo(t,e,i){return this._camera.rotateTo(t,e,i),this}resetNorth(t,e){return this._camera.resetNorth(t,e),this}resetNorthPitch(t,e){return this._camera.resetNorthPitch(t,e),this}snapToNorth(t,e){return this._camera.snapToNorth(t,e),this}getPitch(){return this._camera.transform.pitch}setPitch(t,e){return this._camera.setPitch(t,e),this}getRoll(){return this._camera.transform.roll}setRoll(t,e){return this._camera.setRoll(t,e),this}cameraForBounds(t,e){return this._camera.cameraForBounds(t,e)}fitBounds(t,e,i){return this._camera.fitBounds(t,e,i),this}fitScreenCoordinates(t,e,i,r,n){return this._camera.fitScreenCoordinates(t,e,i,r,n),this}jumpTo(t,e){return this._camera.jumpTo(t,e),this}calculateAnchoredCameraOptions(t){return this._camera.calculateAnchoredCameraOptions(t)}calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n){return this._camera.calculateCameraOptionsFromCameraLngLatAltRotation(t,e,i,r,n)}easeTo(t,e){return this._camera.easeTo(t,e),this}flyTo(t,e){return this._camera.flyTo(t,e),this}stop(){return this._camera.stop(),this}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLat(Cc.convert(t),this._camera.transform):null}getCenterClampedToGround(){return this._camera.getCenterClampedToGround()}calculateCameraOptionsFromTo(t,e,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLat(i,this._camera.transform)),this._camera.transform.calculateCameraOptionsFromTo(t,e,i,r??0)}resize(t,e=!0){if(null!==this._lostContextStyle.style)return this;this._resizeInternal(e);let i=!this._camera._moving;return i&&(this.stop(),this.fire(new Be("movestart",t)).fire(new Be("move",t))),this.fire(new Oe("resize",t)),i&&this.fire(new Be("moveend",t)),this}_resizeInternal(t=!0){let[e,i]=this._containerDimensions();if(this._clampedPixelRatio=this._getClampedPixelRatio(e,i),this._resizeCanvas(e,i,this._clampedPixelRatio),this.painter.resize(e,i,this._clampedPixelRatio),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight],this._clampedPixelRatio=this._getClampedPixelRatio(e,i),this._resizeCanvas(e,i,this._clampedPixelRatio),this.painter.resize(e,i,this._clampedPixelRatio)}this.style?.resize(),this._resizeTransform(t)}_resizeTransform(t=!0){let[e,i]=this._containerDimensions();this._camera.transform.resize(e,i,t),this._camera._requestedCameraState?.resize(e,i,t)}_getClampedPixelRatio(t,e){let{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),s=t*n,o=e*n,a=Math.min(s>i?i/s:1,o>r?r/o:1);return a<1&&Lt("The canvas is larger than maxCanvasSize and is rendered at a lower pixel ratio to fit. Increase maxCanvasSize, within MAX_TEXTURE_SIZE, to render at full resolution."),a*n}getPixelRatio(){return this._overridePixelRatio??devicePixelRatio}setPixelRatio(t){this._overridePixelRatio=t,this.resize()}getBounds(){return this._camera.transform.getBounds()}getMaxBounds(){return this._camera.transform.getMaxBounds()}setMaxBounds(t){return this._camera.applyTransformChange((e=>e.setMaxBounds(Um.convert(t)))),this._update()}setMinZoom(t){if(t??=-2,t>=-2&&t<=this._camera.transform.maxZoom){let e=this._camera.transform.zoom;return this._camera.applyTransformChange((e=>e.setMinZoom(t))),this._update(),e!==this._camera.transform.zoom&&this.fire(new Be("zoomstart")).fire(new Be("zoom")).fire(new Be("zoomend")).fire(new Be("movestart")).fire(new Be("move")).fire(new Be("moveend")),this}throw Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(t=!1){let e=this._camera.transform;return t?e.applyConstrain(e.center,e.minZoom).zoom:e.minZoom}setMaxZoom(t){if(t??=22,t>=this._camera.transform.minZoom){let e=this._camera.transform.zoom;return this._camera.applyTransformChange((e=>e.setMaxZoom(t))),this._update(),e!==this._camera.transform.zoom&&this.fire(new Be("zoomstart")).fire(new Be("zoom")).fire(new Be("zoomend")).fire(new Be("movestart")).fire(new Be("move")).fire(new Be("moveend")),this}throw Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this._camera.transform.maxZoom}setMinPitch(t){if(t??=0,t<0)throw Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this._camera.transform.maxPitch){let e=this._camera.transform.pitch;return this._camera.applyTransformChange((e=>e.setMinPitch(t))),this._update(),e!==this._camera.transform.pitch&&this.fire(new Be("pitchstart")).fire(new Be("pitch")).fire(new Be("pitchend")).fire(new Be("movestart")).fire(new Be("move")).fire(new Be("moveend")),this}throw Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this._camera.transform.minPitch}setMaxPitch(t){if(t??=60,t>180)throw Error("maxPitch must be less than or equal to 180");if(t>=this._camera.transform.minPitch){let e=this._camera.transform.pitch;return this._camera.applyTransformChange((e=>e.setMaxPitch(t))),this._update(),e!==this._camera.transform.pitch&&this.fire(new Be("pitchstart")).fire(new Be("pitch")).fire(new Be("pitchend")).fire(new Be("movestart")).fire(new Be("move")).fire(new Be("moveend")),this}throw Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this._camera.transform.maxPitch}getAnisotropicFilterPitch(){return this._anisotropicFilterPitch}setAnisotropicFilterPitch(t){if(t??=20,t>180)throw Error("anisotropicFilterPitch must be less than or equal to 180");if(t<0)throw Error("anisotropicFilterPitch must be greater than or equal to 0");return this._anisotropicFilterPitch=t,this._update()}getRenderWorldCopies(){return this._camera.transform.renderWorldCopies}setRenderWorldCopies(t){return this._camera.applyTransformChange((e=>e.setRenderWorldCopies(t))),this._update()}setTransformConstrain(t){return this._camera.applyTransformChange((e=>e.setConstrainOverride(t))),this._update()}project(t){return this._camera.transform.locationToScreenPoint(Cc.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(f.convert(t),this.terrain)}isMoving(){return this._camera.isMoving()||this._handlers?.isMoving()||!1}isZooming(){return this._camera.isZooming()||this._handlers?.isZooming()||!1}isRotating(){return this._camera.isRotating()||this._handlers?.isRotating()||!1}_createDelegates(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;return{mousemove:n=>{let s=e.filter((t=>this.getLayer(t))),o=0===s.length?[]:this.queryRenderedFeatures(n.point,{layers:s});o.length?r||(r=!0,i.call(this,new Ge(t,this,n.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}if("mouseleave"===t||"mouseout"===t){let r=!1;return{mousemove:n=>{let s=e.filter((t=>this.getLayer(t)));(0===s.length?[]:this.queryRenderedFeatures(n.point,{layers:s})).length?r=!0:r&&(r=!1,i.call(this,new Ge(t,this,n.originalEvent)))},mouseout:e=>{r&&(r=!1,i.call(this,new Ge(t,this,e.originalEvent)))}}}{let r=t=>{let r=e.filter((t=>this.getLayer(t))),n=0===r.length?[]:this.queryRenderedFeatures(t.point,{layers:r});n.length&&(t.features=n,i.call(this,t),delete t.features)};return{[t]:r}}}_addDelegatedListener(t,e){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(e);for(let t in e.delegates)this.on(t,e.delegates[t])}_removeDelegatedListener(t,e,i){if(!this._delegatedListeners?.[t])return;let r=this._delegatedListeners[t];for(let t=0;t<r.length;t++){let n=r[t];if(n.listener===i&&n.layers.length===e.length&&n.layers.every((t=>e.includes(t)))){for(let t in n.delegates)this.off(t,n.delegates[t]);return void r.splice(t,1)}}}on(t,e,i){if(void 0===i)return super.on(t,e);let r="string"==typeof e?[e]:e,n={layers:r,listener:i,delegates:this._createDelegates(t,r,i)};return this._addDelegatedListener(t,n),{unsubscribe:()=>{this._removeDelegatedListener(t,r,i)}}}once(t,e,i){if(void 0===i)return super.once(t,e);let r="string"==typeof e?[e]:e,n={layers:r,listener:i,delegates:this._createDelegates(t,r,(e=>{this._removeDelegatedListener(t,r,i),i.call(this,e)}))};return this._addDelegatedListener(t,n),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,e){if(!this.style)return[];let i,r=t instanceof f||Array.isArray(t),n=r?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(e||=(r?{}:t)||{},n instanceof f||"number"==typeof n[0])i=[f.convert(n)];else{let t=f.convert(n[0]),e=f.convert(n[1]);i=[t,new f(e.x,t.y),e,new f(t.x,e.y),t]}return this.style.queryRenderedFeatures(i,e,this._camera.transform)}querySourceFeatures(t,e){return this.style.querySourceFeatures(t,e)}setStyle(t,e){return e=St({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},e),this._styleUrl="string"==typeof t?t:null,!1!==e.diff&&e.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&t?(this._diffStyle(t,e),this):(this._localIdeographFontFamily=e.localIdeographFontFamily,this._updateStyle(t,e))}setTransformRequest(t){return this._requestManager.setTransformRequest(t),this}_getUIString(t){let e=this._locale[t];if(null==e)throw Error(`Missing UI string '${t}'`);return e}_updateStyle(t,e){if(this._diffStyleRequest?.abort(),this._diffStyleRequest=null,e.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",(()=>this._updateStyle(t,e)));let i=this.style&&e.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!t)),t?(this.style=new Ab(this,e||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof t?this.style.loadURL(t,e,i):this.style.loadJSON(t,e,i),this):(this._frameRequest&&=(this._frameRequest.abort(),null),this.style?.projection?.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ab(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}async _diffStyle(t,e){if(this._diffStyleRequest?.abort(),"string"==typeof t){let i=t;this._diffStyleRequest=new AbortController;let r=this._diffStyleRequest;try{let t=await this._requestManager.transformRequest(i,"Style");if(r.signal.aborted)return void(this._diffStyleRequest=null);let n=await Se(t,r);this._diffStyleRequest=null,this._updateDiff(n.data,e)}catch(t){this._diffStyleRequest=null,ae(t)||this.fire(new je(at(t)))}}else"object"==typeof t&&(this._diffStyleRequest=null,this._updateDiff(t,e))}_updateDiff(t,e){try{this.style.setState(t,e)&&this._update(!0)}catch(i){Lt(`Unable to perform style diff: ${at(i).message}. Rebuilding the style from scratch.`),this._updateStyle(t,e)}}getStyle(){if(this.style)return this.style.serialize()}getStyleUrl(){return this._styleUrl}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){if(this.style)return this.style.loaded();Lt("There is no style added to the map.")}addSource(t,e){return this._lazyInitEmptyStyle(),this.style.addSource(t,e),this._update(!0)}isSourceLoaded(t){let e=this.style?.tileManagers[t];if(void 0!==e)return e.loaded();this.fire(new je(Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t,e={}){if(this.style._checkLoaded(),t&&No(this,Oo.terrain,{value:t},e))return this;if(this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),t){let e=this.style.tileManagers[t.source];if(!e)throw Error(`cannot load terrain, because there exists no source with ID: ${t.source}`);null===this.terrain&&e.reload();for(let e in this.style._layers){let i=this.style._layers[e];"hillshade"===i.type&&i.source===t.source&&Lt("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"===i.type&&i.source===t.source&&Lt("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&&this.terrain.destroy(),this.terrain=new mE(this.painter,e,t,this._terrainSkirtLength),this.painter.renderToTexture=new bE(this.painter,this.terrain),this._camera.setTerrain(this.terrain),this._terrainDataCallback=e=>this._handleTerrainDataEvent(e,t.source),this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.destroy(),this.terrain=null,this.painter.renderToTexture=null,this.painter.destroyRTTResources(),this._camera.setTerrain(null);return this.style.triggerSymbolPlacement(),this.fire(new We({terrain:t})),this}_handleTerrainDataEvent(t,e){if("style"===t.dataType)return void this.terrain.tileManager.releaseAllRTT();let i=t.sourceId===e;if(i&&(this.terrain.resetElevationCache(),this.style.triggerSymbolPlacement()),i&&t.tile&&(this.painter.markTerrainDepthDirty(),this._camera.applyTerrainChange()),t.tile){if("image"===t.source?.type)return void this.terrain.tileManager.releaseAllRTT();this.terrain.tileManager.releaseRTT(t.tile.tileID)}}getTerrain(){return this.terrain?.options??null}areTilesLoaded(){let t=this.style?.tileManagers;for(let e of Object.values(t))if(!e.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){let r=this.getSource(i);if(!r)throw Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=nv(Math.max(1,t),Math.max(1,e))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=nv(Math.max(1,t),Math.max(1,e));return this._update(!0),this}refreshTiles(t,e){let i=this.style.tileManagers[t];if(!i)throw Error(`There is no tile manager with ID "${t}", cannot refresh tile`);void 0===e?i.reload(!0):i.refreshTiles(e.map((t=>new Zm(t.z,t.x,t.y))))}addImage(t,e,i={}){this._lazyInitEmptyStyle();let r=this._createStyleImage(e,i);return r?(this.style.addImage(t,r),r.userImage?.onAdd&&r.userImage.onAdd(this,t),this):this}setMissingStyleImageResolver(t){return this._missingStyleImageResolver=t,this.style?.setMissingImageResolver(t),this}_createStyleImage(t,e={}){let{pixelRatio:i=1,sdf:r=!1,stretchX:n,stretchY:s,content:o,textFitWidth:a,textFitHeight:l}=e;if(t instanceof HTMLImageElement||Zt(t)){let{width:e,height:h,data:u}=fe.getImageData(t);return{data:new Xh({width:e,height:h},u),pixelRatio:i,stretchX:n,stretchY:s,content:o,textFitWidth:a,textFitHeight:l,sdf:r,version:0}}if(void 0===t.width||void 0===t.height)return this.fire(new je(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`"))),null;{let{width:e,height:h,data:u}=t,c=t,f=Tp(c.data);return{data:f?new Xh({width:e,height:h}):new Xh({width:e,height:h},new Uint8Array(u)),pixelRatio:i,stretchX:n,stretchY:s,content:o,textFitWidth:a,textFitHeight:l,sdf:r,version:0,isWebGLImage:f,userImage:c}}}updateImage(t,e){let i=this.style.getImage(t);if(!i)return this.fire(new je(Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let{width:r,height:n,data:s}=e instanceof HTMLImageElement||Zt(e)?fe.getImageData(e):e;if(void 0===r||void 0===n)return this.fire(new je(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!==i.data.width||n!==i.data.height)return this.fire(new je(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=Tp(s),i.isWebGLImage)i.userImage=e;else{let t=!(e instanceof HTMLImageElement||Zt(e));i.data.replace(s,t)}return this.style.updateImage(t,i),this}getImage(t){return this.style.getImage(t)}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new je(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){let e=await Te.getImage(await this._requestManager.transformRequest(t,"Image"),new AbortController);if(!e.data)throw Error(`Could not load image ${t}: the response is empty`);return e}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,r={}){return this.style?.setPaintProperty(t,e,i,r),this._update(!0)}getPaintProperty(t,e){return this.style.getPaintProperty(t,e)}setLayoutProperty(t,e,i,r={}){return this.style.setLayoutProperty(t,e,i,r),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()}setFontFaces(t){return this._lazyInitEmptyStyle(),this.style.setFontFaces(t),this._update(!0)}getFontFaces(){return this.style.getFontFaces()}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=Math.floor(this._container.clientWidth)||400,e=Math.floor(this._container.clientHeight)||300),[t,e]}_shouldHandleInitialResize(){if(!this._container?.clientWidth||!this._container.clientHeight)return!1;let[t,e]=this._containerDimensions();return t!==this._camera.transform.width||e!==this._camera.transform.height}_setupResizeObserver(){let t=!1,e=fM((t=>{this._trackResize&&!this._removed&&(this.resize(t),this.redraw())}),50),i=this._ownerWindow.ResizeObserver??ResizeObserver;this._resizeObserver=new i((i=>{!t&&(t=!0,!this._shouldHandleInitialResize())||e(i)})),this._resizeObserver.observe(this._container)}_resolveContainer(t){if("string"==typeof t){let e=document.getElementById(t);if(!e)throw Error(`Container '${t}' not found.`);return e}if(t instanceof HTMLElement||t&&"object"==typeof t&&1===t.nodeType)return t;throw Error("Invalid type: 'container' must be a String or HTMLElement.")}_setupContainer(){let t=this._containerDimensions(),e=this._getClampedPixelRatio(t[0],t[1]),i=this._container;i.classList.add("maplibregl-map");let r=this._canvasContainer=be.create("div","maplibregl-canvas-container",i);this._interactive&&r.classList.add("maplibregl-interactive"),this._canvas=be.create("canvas","maplibregl-canvas",r),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"),this._resizeCanvas(t[0],t[1],e);let n=this._controlContainer=be.create("div","maplibregl-control-container",i),s=this._controlPositions={};for(let t of["top-left","top-right","bottom-left","bottom-right"])s[t]=be.create("div",`maplibregl-ctrl-${t} `,n);this._container.addEventListener("scroll",this._onMapScroll,!1)}_cleanupContainer(){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")}_resizeCanvas(t,e,i){let r=Math.round(i*t),n=Math.round(i*e);this._canvas.width=r,this._canvas.height=n,this._canvas.style.width=r/i+"px",this._canvas.style.height=n/i+"px"}_setupPainter(){let t={...this._canvasContextAttributes,alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0},e=null;this._canvas.addEventListener("webglcontextcreationerror",(t=>{e=t}),{once:!0});let i=this._canvas.getContext("webgl2",t);if(!i)throw new cM(t,e);this.painter=new uM(i)}migrateProjection(t,e){this._camera.migrateProjection(t,e),this.fire(new He({newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(t){return this.style?._loaded?(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){let e=this._idleTriggered?this._fadeDuration:0,i=this.style.projection?.transitionState>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(t),this._removed)return;let r=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let t=this._camera.transform.zoom,i=de();this.style.zoomHistory.update(t,i);let n=new Ko(t,{now:i,fadeDuration:e,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=n.crossFadingFactor();(1!==s||s!==this._crossFadingFactor)&&(r=!0,this._crossFadingFactor=s),this.style.update(n)}let n=this.style.projection?.transitionState>0!==i;this._camera.transform.setTransitionState(this.style.projection?.transitionState),this.style&&(this._sourcesDirty||n)&&(this._sourcesDirty=!1,this.style._updateSources(this._camera.transform)),this.terrain?(this.terrain.tileManager.update(this._camera.transform,this.terrain)&&this.terrain.resetElevationCache(),this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),!this._camera.elevationFreeze&&this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))):(this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0)),this._placementDirty=this.style?._updatePlacement(this._camera.transform,this.showCollisionBoxes,e,this._crossSourceCollisions,n);let s=this.style.projection,o=s?.transitionState??0;this.painter.render(this.style,this._camera.transform,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,symbolFadeChange:this.style.placement.symbolFadeChange(de()),variableOffsets:this.style.placement.variableOffsets,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch(),projectionTransition:o,isRenderingGlobe:o>0,projectionShaderVariant:s?{name:s.shaderVariantName,define:s.shaderDefine,prelude:s.shaderPreludeCode}:void 0,useSubdivision:s?.useSubdivision??!1,pixelRatio:this._clampedPixelRatio,light:this.style.light?.getEvaluated(),sky:this.style.sky?.getEvaluated()}),this.fire(new Oe("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new Oe("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let a=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return a||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new Oe("idle")),this._loaded&&!this._fullyLoaded&&!a&&(this._fullyLoaded=!0),this}redraw(){return this.style&&(this._frameRequest&&=(this._frameRequest.abort(),null),this._render(0)),this}remove(){this._hash&&this._hash.remove();for(let t of this._controls)t.onRemove(this);this._controls=[],this._frameRequest&&=(this._frameRequest.abort(),null),this._renderTaskQueue.clear(),this._diffStyleRequest?.abort(),this.painter.destroy(),this._handlers.destroy(),this.setStyle(null),typeof window<"u"&&this._ownerWindow.removeEventListener("online",this._onWindowOnline,!1),Te.removeThrottleControl(this._imageQueueHandle),this._resizeObserver?.disconnect();let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._cleanupContainer(),this._removed=!0,this.fire(new Oe("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,fe.frame(this._frameRequest,(t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!ae(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 DE}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}},AE=t||e,FE=AE.Layer.extend({options:{updateInterval:32,padding:.1,interactive:!1,pane:"tilePane"},initialize:function(t){AE.setOptions(this,t),this._throttledUpdate=AE.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&&AE.DomEvent.on(t._proxy,AE.DomUtil.TRANSITION_END,this._transitionEnd,this)},onRemove:function(t){this._map._proxy&&this._map.options.zoomAnimation&&AE.DomEvent.off(this._map._proxy,AE.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 AE.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=AE.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);AE.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=AE.extend({},this.options,{container:this._container,center:[t.lng,t.lat],zoom:this._map.getZoom()-1,attributionControl:!1});this._glMap=new EE(e);var i=this._map,r=this.getAttribution(),n=this.getAttribution.bind(this);if(this._glMap.on("load",(function(){i&&i.attributionControl&&(i.attributionControl.removeAttribution(r),i.attributionControl.addAttribution(n()))})),this._glMap.setTransformConstrain)this._glMap.setTransformConstrain((function(t,e){return{center:t,zoom:e}}));else{var s=this._glMap.transform,o=Object.getPrototypeOf(s),a=Object.getOwnPropertyDescriptor(o,"latRange");(!a||a.set||a.writable)&&(s.latRange=null);var l=Object.getOwnPropertyDescriptor(o,"maxValidLatitude");(!l||l.set||l.writable)&&(s.maxValidLatitude=1/0),s._helper&&s._helper._latRange&&(s._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 h=this._glMap._actualCanvas;AE.DomUtil.addClass(h,"leaflet-image-layer"),AE.DomUtil.addClass(h,"leaflet-zoom-animated"),this.options.interactive&&AE.DomUtil.addClass(h,"leaflet-interactive"),this.options.className&&AE.DomUtil.addClass(h,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),r=this._map.containerPointToLayerPoint([0,0]).subtract(i);AE.DomUtil.setPosition(t,this._roundPoint(r)),this._transformGL(e)}},_transformGL:function(t){var e=this._map.getCenter();t.jumpTo({center:[e.lng,e.lat],zoom:this._map.getZoom()-1})},_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),r=this.getSize()._divideBy(2),n=this._map.project(t.center,t.zoom)._subtract(r)._add(this._map._getMapPanePos().add(i))._round(),s=this._map.project(this._map.getBounds().getNorthWest(),t.zoom)._subtract(n);AE.DomUtil.setTransform(this._glMap._actualCanvas,s.subtract(this._offset),e)},_zoomStart:function(){this._zooming=!0},_zoomEnd:function(){var t=this._map.getZoomScale(this._map.getZoom());AE.DomUtil.setTransform(this._glMap._actualCanvas,null,t),this._zooming=!1,this._update()},_transitionEnd:function(){AE.Util.requestAnimFrame((function(){var t=this._map.getZoom(),e=this._map.getCenter(),i=this._map.latLngToContainerPoint(this._map.getBounds().getNorthWest());this._resizeContainer(),AE.DomUtil.setTransform(this._glMap._actualCanvas,i,1),this._glMap.once("moveend",AE.Util.bind((function(){this._zoomEnd()}),this)),this._glMap.jumpTo({center:e,zoom:t-1})}),this)},_resize:function(t){this._transitionEnd(t)}}),SE=function(t){return new FE(t)};Object.isExtensible(AE)&&(AE.MaplibreGL=FE,AE.maplibreGL=SE);export{FE as MaplibreGL,SE as default,SE as maplibreGL}