xv-webcomponents 1.25.1 → 2.0.0-beta.28
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.
- package/LICENSE +21 -21
- package/README.md +249 -129
- package/dist/angular/angular-component-lib/utils.d.ts +9 -0
- package/dist/angular/angular-component-lib/utils.js +58 -0
- package/dist/angular/index.d.ts +4 -0
- package/dist/angular/index.js +56 -0
- package/dist/angular/proxies.d.ts +696 -0
- package/dist/angular/proxies.js +1642 -0
- package/dist/angular/web-components.module.d.ts +7 -0
- package/dist/angular/web-components.module.js +168 -0
- package/dist/cjs/_vars-DMytunQw.js +26 -0
- package/dist/cjs/{index-Cb30DBqk.js → index-DaTpiyaU.js} +2 -0
- package/dist/cjs/{index-DpLAFt0R.js → index-Dwhgrew8.js} +401 -1805
- package/dist/cjs/index.cjs.js +4 -1
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/maplibre-gl-BIvnXGyX.js +884 -0
- package/dist/cjs/{xv-accordion-v2_50.cjs.entry.js → xv-accordion-v2_49.cjs.entry.js} +2046 -694
- package/dist/cjs/xv-header-next.cjs.entry.js +10 -89
- package/dist/cjs/xv-mega-menu-next.cjs.entry.js +4 -4
- package/dist/cjs/xv-webcomponents.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/xv-accordion/xv-accordion.js +1 -1
- package/dist/collection/components/xv-accordion-item/xv-accordion-item.js +1 -1
- package/dist/collection/components/xv-breadcrumbs/xv-breadcrumbs.js +1 -1
- package/dist/collection/components/xv-button/xv-button.js +2 -1
- package/dist/collection/components/xv-button-group/xv-button-group.js +3 -3
- package/dist/collection/components/xv-card/xv-card.js +1 -1
- package/dist/collection/components/xv-checkbox/xv-checkbox.js +4 -3
- package/dist/collection/components/xv-content-switcher/xv-content-switcher-item/xv-content-switcher-item.js +1 -1
- package/dist/collection/components/xv-content-switcher/xv-content-switcher.js +7 -6
- package/dist/collection/components/xv-data-table/xv-data-table-cell/xv-data-table-cell.js +5 -3
- package/dist/collection/components/xv-data-table/xv-data-table-row/xv-data-table-row.js +4 -3
- package/dist/collection/components/xv-data-table/xv-data-table.js +5 -3
- package/dist/collection/components/xv-date-picker/xv-date-picker.js +16 -8
- package/dist/collection/components/xv-datepicker/xv-datepicker.js +5 -4
- package/dist/collection/components/xv-dropdown/xv-dropdown-item/xv-dropdown-item.js +9 -5
- package/dist/collection/components/xv-dropdown/xv-dropdown.js +9 -5
- package/dist/collection/components/xv-file-uploader/xv-file-uploader.css +3 -3
- package/dist/collection/components/xv-file-uploader/xv-file-uploader.js +6 -4
- package/dist/collection/components/xv-footer/xv-footer.js +1 -1
- package/dist/collection/components/xv-geo-map/xv-geo-map.css +43 -67
- package/dist/collection/components/xv-geo-map/xv-geo-map.js +10 -10
- package/dist/collection/components/xv-header/xv-header.js +7 -88
- package/dist/collection/components/xv-header-next/xv-header-next.js +10 -91
- package/dist/collection/components/xv-link/xv-link.js +1 -1
- package/dist/collection/components/xv-loader/xv-loader.js +2 -1
- package/dist/collection/components/xv-login-modal/xv-login-modal.css +7 -7
- package/dist/collection/components/xv-mega-menu/xv-mega-menu.js +2 -2
- package/dist/collection/components/xv-mega-menu-next/xv-mega-menu-next.js +5 -4
- package/dist/collection/components/xv-modal/xv-modal.js +3 -2
- package/dist/collection/components/xv-notification/xv-notification.js +3 -2
- package/dist/collection/components/xv-number-input/xv-number-input.js +4 -3
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu-item/xv-overflow-menu-item.js +7 -4
- package/dist/collection/components/xv-overflow-menu/xv-overflow-menu.js +14 -11
- package/dist/collection/components/xv-pagination/xv-pagination.css +2 -2
- package/dist/collection/components/xv-pagination/xv-pagination.js +7 -4
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator-item/xv-progress-indicator-item.js +3 -2
- package/dist/collection/components/xv-progress-indicator/xv-progress-indicator.js +6 -5
- package/dist/collection/components/xv-radio/xv-radio.js +4 -3
- package/dist/collection/components/xv-slider/xv-slider.js +1 -1
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.css +129 -61
- package/dist/collection/components/xv-table/xv-table-cell/xv-table-cell.js +279 -78
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.css +138 -24
- package/dist/collection/components/xv-table/xv-table-row/xv-table-row.js +334 -162
- package/dist/collection/components/xv-table/xv-table.css +240 -99
- package/dist/collection/components/xv-table/xv-table.js +2058 -64
- package/dist/collection/components/xv-table/xv-table.model.js +10 -0
- package/dist/collection/components/xv-table/xv-table.utils.js +243 -0
- package/dist/collection/components/xv-tabs/xv-tab/xv-tab.js +1 -1
- package/dist/collection/components/xv-tabs/xv-tabs.js +2 -1
- package/dist/collection/components/xv-tag/xv-tag.js +1 -1
- package/dist/collection/components/xv-tag-combobox/xv-tag-combobox.js +6 -4
- package/dist/collection/components/xv-text-input/xv-text-input.js +4 -3
- package/dist/collection/components/xv-textarea/xv-textarea.js +4 -3
- package/dist/collection/components/xv-tile/xv-tile.css +1 -1
- package/dist/collection/components/xv-tile/xv-tile.js +2 -2
- package/dist/collection/components/xv-toggle/xv-toggle.js +3 -2
- package/dist/collection/components/xv-toggle-tip/xv-toggle-tip.js +3 -2
- package/dist/collection/components/xv-tooltip/xv-tooltip.js +4 -3
- package/dist/collection/index.js +3 -0
- package/dist/collection/utils/table-layout.js +130 -0
- package/dist/components/index.d.ts +35 -0
- package/dist/components/index.js +1 -0
- package/dist/components/p-A3B7AR96.js +9 -0
- package/dist/components/p-B0kwaJ8n.js +1 -0
- package/dist/components/p-B9zHwwFm.js +1 -0
- package/dist/components/p-BEoh0dZI.js +1 -0
- package/dist/components/p-BaZ-srfu.js +1 -0
- package/dist/components/p-Bej2l-wN.js +1 -0
- package/dist/components/p-BfP9ezJQ.js +1 -0
- package/dist/components/p-BfhvpeQh.js +1 -0
- package/dist/components/p-BiiqsbVQ.js +1 -0
- package/dist/components/p-CSYnNMKb.js +1 -0
- package/dist/components/p-CspyoLL9.js +1 -0
- package/dist/components/p-CvgDDcjp.js +1 -0
- package/dist/components/p-D4FwGeDJ.js +1 -0
- package/dist/components/p-DCvH_Br_.js +1 -0
- package/dist/components/p-DFe9Mtw_.js +1 -0
- package/dist/components/p-DFtMwE-h.js +1 -0
- package/dist/components/p-DIvi4fI3.js +1 -0
- package/dist/components/p-DNRISLNf.js +1 -0
- package/dist/components/p-DPnvoOYj.js +1 -0
- package/dist/components/p-Dwbe941A.js +1 -0
- package/dist/components/p-HjYAjHna.js +1 -0
- package/dist/components/p-JClekcEh.js +1 -0
- package/dist/components/p-NoM9oIJn.js +1 -0
- package/dist/components/p-SvgdO2VS.js +1 -0
- package/dist/components/p-XEk4dHG3.js +1 -0
- package/dist/components/p-e0i0f6QA.js +1 -0
- package/dist/components/p-i7_81si-.js +1 -0
- package/dist/components/p-i82EFiq6.js +1 -0
- package/dist/components/p-jD7nSJaM.js +1 -0
- package/dist/components/xv-accordion-v2-item.d.ts +11 -0
- package/dist/components/xv-accordion-v2-item.js +1 -0
- package/dist/components/xv-accordion-v2.d.ts +11 -0
- package/dist/components/xv-accordion-v2.js +1 -0
- package/dist/components/xv-breadcrumbs-v2.d.ts +11 -0
- package/dist/components/xv-breadcrumbs-v2.js +1 -0
- package/dist/components/xv-button-group-v2.d.ts +11 -0
- package/dist/components/xv-button-group-v2.js +1 -0
- package/dist/components/xv-button-v2.d.ts +11 -0
- package/dist/components/xv-button-v2.js +1 -0
- package/dist/components/xv-card-v2.d.ts +11 -0
- package/dist/components/xv-card-v2.js +1 -0
- package/dist/components/xv-checkbox-v2.d.ts +11 -0
- package/dist/components/xv-checkbox-v2.js +1 -0
- package/dist/components/xv-content-switcher-item-v2.d.ts +11 -0
- package/dist/components/xv-content-switcher-item-v2.js +1 -0
- package/dist/components/xv-content-switcher-v2.d.ts +11 -0
- package/dist/components/xv-content-switcher-v2.js +1 -0
- package/dist/components/xv-data-table-cell.d.ts +11 -0
- package/dist/components/xv-data-table-cell.js +1 -0
- package/dist/components/xv-data-table-collapse.d.ts +11 -0
- package/dist/components/xv-data-table-collapse.js +1 -0
- package/dist/components/xv-data-table-row.d.ts +11 -0
- package/dist/components/xv-data-table-row.js +1 -0
- package/dist/components/xv-data-table.d.ts +11 -0
- package/dist/components/xv-data-table.js +7 -0
- package/dist/components/xv-date-picker.d.ts +11 -0
- package/dist/components/xv-date-picker.js +1 -0
- package/dist/components/xv-datepicker.d.ts +11 -0
- package/dist/components/xv-datepicker.js +1 -0
- package/dist/components/xv-dropdown-v2-item.d.ts +11 -0
- package/dist/components/xv-dropdown-v2-item.js +1 -0
- package/dist/components/xv-dropdown-v2.d.ts +11 -0
- package/dist/components/xv-dropdown-v2.js +1 -0
- package/dist/components/xv-file-uploader.d.ts +11 -0
- package/dist/components/xv-file-uploader.js +1 -0
- package/dist/components/xv-footer.d.ts +11 -0
- package/dist/components/xv-footer.js +1 -0
- package/dist/components/xv-geo-map-v2.d.ts +11 -0
- package/dist/components/xv-geo-map-v2.js +1 -0
- package/dist/components/xv-header-next.d.ts +11 -0
- package/dist/components/xv-header-next.js +1 -0
- package/dist/components/xv-header.d.ts +11 -0
- package/dist/components/xv-header.js +1 -0
- package/dist/components/xv-image-viewer.d.ts +11 -0
- package/dist/components/xv-image-viewer.js +1 -0
- package/dist/components/xv-link-v2.d.ts +11 -0
- package/dist/components/xv-link-v2.js +1 -0
- package/dist/components/xv-loader-v2.d.ts +11 -0
- package/dist/components/xv-loader-v2.js +1 -0
- package/dist/components/xv-login-modal.d.ts +11 -0
- package/dist/components/xv-login-modal.js +1 -0
- package/dist/components/xv-mega-menu-next.d.ts +11 -0
- package/dist/components/xv-mega-menu-next.js +1 -0
- package/dist/components/xv-mega-menu.d.ts +11 -0
- package/dist/components/xv-mega-menu.js +1 -0
- package/dist/components/xv-modal-v2.d.ts +11 -0
- package/dist/components/xv-modal-v2.js +1 -0
- package/dist/components/xv-notification-v2.d.ts +11 -0
- package/dist/components/xv-notification-v2.js +1 -0
- package/dist/components/xv-number-input-v2.d.ts +11 -0
- package/dist/components/xv-number-input-v2.js +1 -0
- package/dist/components/xv-overflow-menu-v2-item.d.ts +11 -0
- package/dist/components/xv-overflow-menu-v2-item.js +1 -0
- package/dist/components/xv-overflow-menu-v2.d.ts +11 -0
- package/dist/components/xv-overflow-menu-v2.js +1 -0
- package/dist/components/xv-pagination.d.ts +11 -0
- package/dist/components/xv-pagination.js +1 -0
- package/dist/components/xv-progress-indicator-v2-item.d.ts +11 -0
- package/dist/components/xv-progress-indicator-v2-item.js +1 -0
- package/dist/components/xv-progress-indicator-v2.d.ts +11 -0
- package/dist/components/xv-progress-indicator-v2.js +1 -0
- package/dist/components/xv-radio-v2.d.ts +11 -0
- package/dist/components/xv-radio-v2.js +1 -0
- package/dist/components/xv-slider-v2.d.ts +11 -0
- package/dist/components/xv-slider-v2.js +1 -0
- package/dist/components/xv-tab-v2.d.ts +11 -0
- package/dist/components/xv-tab-v2.js +1 -0
- package/dist/components/xv-table-cell.d.ts +11 -0
- package/dist/components/xv-table-cell.js +1 -0
- package/dist/components/xv-table-row.d.ts +11 -0
- package/dist/components/xv-table-row.js +1 -0
- package/dist/components/xv-table.d.ts +11 -0
- package/dist/components/xv-table.js +1 -0
- package/dist/components/xv-tabs-v2.d.ts +11 -0
- package/dist/components/xv-tabs-v2.js +1 -0
- package/dist/components/xv-tag-combobox.d.ts +11 -0
- package/dist/components/xv-tag-combobox.js +1 -0
- package/dist/components/xv-tag-v2.d.ts +11 -0
- package/dist/components/xv-tag-v2.js +1 -0
- package/dist/components/xv-text-input-v2.d.ts +11 -0
- package/dist/components/xv-text-input-v2.js +1 -0
- package/dist/components/xv-textarea.d.ts +11 -0
- package/dist/components/xv-textarea.js +1 -0
- package/dist/components/xv-tile.d.ts +11 -0
- package/dist/components/xv-tile.js +1 -0
- package/dist/components/xv-toggle-tip.d.ts +11 -0
- package/dist/components/xv-toggle-tip.js +1 -0
- package/dist/components/xv-toggle.d.ts +11 -0
- package/dist/components/xv-toggle.js +1 -0
- package/dist/components/xv-tooltip-v2.d.ts +11 -0
- package/dist/components/xv-tooltip-v2.js +1 -0
- package/dist/custom-elements.json +11561 -0
- package/dist/docs.d.ts +480 -0
- package/dist/docs.json +17181 -0
- package/dist/esm/_vars-CDEU4jkD.js +23 -0
- package/dist/esm/{index-CQm2sRKT.js → index-ClusqSO5.js} +2 -0
- package/dist/esm/{index-DmxA2ysB.js → index-DJC3-dS3.js} +400 -1806
- package/dist/esm/index.js +2 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/maplibre-gl-A3B7AR96.js +826 -0
- package/dist/esm/maplibre-gl-shared.mjs +2 -2
- package/dist/esm/maplibre-gl-worker.mjs +2 -2
- package/dist/esm/{xv-accordion-v2_50.entry.js → xv-accordion-v2_49.entry.js} +2044 -691
- package/dist/esm/xv-header-next.entry.js +10 -89
- package/dist/esm/xv-mega-menu-next.entry.js +4 -4
- package/dist/esm/xv-webcomponents.js +4 -4
- package/dist/react/components.d.ts +55 -0
- package/dist/react/components.js +56 -0
- package/dist/react/create-component.d.ts +24 -0
- package/dist/react/runtime.d.ts +2 -0
- package/dist/react/runtime.js +43 -0
- package/dist/react/tag-transformer.d.ts +3 -0
- package/dist/react/tag-transformer.js +12 -0
- package/dist/react/xv-accordion-v2-item.d.ts +12 -0
- package/dist/react/xv-accordion-v2-item.js +14 -0
- package/dist/react/xv-accordion-v2.d.ts +15 -0
- package/dist/react/xv-accordion-v2.js +14 -0
- package/dist/react/xv-breadcrumbs-v2.d.ts +9 -0
- package/dist/react/xv-breadcrumbs-v2.js +14 -0
- package/dist/react/xv-button-group-v2.d.ts +12 -0
- package/dist/react/xv-button-group-v2.js +14 -0
- package/dist/react/xv-button-v2.d.ts +9 -0
- package/dist/react/xv-button-v2.js +14 -0
- package/dist/react/xv-card-v2.d.ts +9 -0
- package/dist/react/xv-card-v2.js +14 -0
- package/dist/react/xv-checkbox-v2.d.ts +15 -0
- package/dist/react/xv-checkbox-v2.js +19 -0
- package/dist/react/xv-content-switcher-item-v2.d.ts +9 -0
- package/dist/react/xv-content-switcher-item-v2.js +14 -0
- package/dist/react/xv-content-switcher-v2.d.ts +12 -0
- package/dist/react/xv-content-switcher-v2.js +14 -0
- package/dist/react/xv-data-table-cell.d.ts +12 -0
- package/dist/react/xv-data-table-cell.js +14 -0
- package/dist/react/xv-data-table-collapse.d.ts +12 -0
- package/dist/react/xv-data-table-collapse.js +14 -0
- package/dist/react/xv-data-table-row.d.ts +12 -0
- package/dist/react/xv-data-table-row.js +14 -0
- package/dist/react/xv-data-table.d.ts +12 -0
- package/dist/react/xv-data-table.js +14 -0
- package/dist/react/xv-date-picker.d.ts +14 -0
- package/dist/react/xv-date-picker.js +18 -0
- package/dist/react/xv-datepicker.d.ts +13 -0
- package/dist/react/xv-datepicker.js +17 -0
- package/dist/react/xv-dropdown-v2-item.d.ts +12 -0
- package/dist/react/xv-dropdown-v2-item.js +14 -0
- package/dist/react/xv-dropdown-v2.d.ts +13 -0
- package/dist/react/xv-dropdown-v2.js +17 -0
- package/dist/react/xv-file-uploader.d.ts +13 -0
- package/dist/react/xv-file-uploader.js +17 -0
- package/dist/react/xv-footer.d.ts +9 -0
- package/dist/react/xv-footer.js +14 -0
- package/dist/react/xv-geo-map-v2.d.ts +13 -0
- package/dist/react/xv-geo-map-v2.js +17 -0
- package/dist/react/xv-header-next.d.ts +12 -0
- package/dist/react/xv-header-next.js +14 -0
- package/dist/react/xv-header.d.ts +12 -0
- package/dist/react/xv-header.js +14 -0
- package/dist/react/xv-image-viewer.d.ts +12 -0
- package/dist/react/xv-image-viewer.js +14 -0
- package/dist/react/xv-link-v2.d.ts +9 -0
- package/dist/react/xv-link-v2.js +14 -0
- package/dist/react/xv-loader-v2.d.ts +9 -0
- package/dist/react/xv-loader-v2.js +14 -0
- package/dist/react/xv-login-modal.d.ts +12 -0
- package/dist/react/xv-login-modal.js +14 -0
- package/dist/react/xv-mega-menu-next.d.ts +12 -0
- package/dist/react/xv-mega-menu-next.js +14 -0
- package/dist/react/xv-mega-menu.d.ts +12 -0
- package/dist/react/xv-mega-menu.js +14 -0
- package/dist/react/xv-modal-v2.d.ts +12 -0
- package/dist/react/xv-modal-v2.js +14 -0
- package/dist/react/xv-notification-v2.d.ts +12 -0
- package/dist/react/xv-notification-v2.js +14 -0
- package/dist/react/xv-number-input-v2.d.ts +12 -0
- package/dist/react/xv-number-input-v2.js +14 -0
- package/dist/react/xv-overflow-menu-v2-item.d.ts +12 -0
- package/dist/react/xv-overflow-menu-v2-item.js +14 -0
- package/dist/react/xv-overflow-menu-v2.d.ts +13 -0
- package/dist/react/xv-overflow-menu-v2.js +17 -0
- package/dist/react/xv-pagination.d.ts +15 -0
- package/dist/react/xv-pagination.js +14 -0
- package/dist/react/xv-progress-indicator-v2-item.d.ts +9 -0
- package/dist/react/xv-progress-indicator-v2-item.js +14 -0
- package/dist/react/xv-progress-indicator-v2.d.ts +9 -0
- package/dist/react/xv-progress-indicator-v2.js +14 -0
- package/dist/react/xv-radio-v2.d.ts +9 -0
- package/dist/react/xv-radio-v2.js +14 -0
- package/dist/react/xv-slider-v2.d.ts +12 -0
- package/dist/react/xv-slider-v2.js +14 -0
- package/dist/react/xv-tab-v2.d.ts +9 -0
- package/dist/react/xv-tab-v2.js +14 -0
- package/dist/react/xv-table-cell.d.ts +9 -0
- package/dist/react/xv-table-cell.js +14 -0
- package/dist/react/xv-table-row.d.ts +9 -0
- package/dist/react/xv-table-row.js +14 -0
- package/dist/react/xv-table.d.ts +18 -0
- package/dist/react/xv-table.js +22 -0
- package/dist/react/xv-tabs-v2.d.ts +12 -0
- package/dist/react/xv-tabs-v2.js +14 -0
- package/dist/react/xv-tag-combobox.d.ts +13 -0
- package/dist/react/xv-tag-combobox.js +17 -0
- package/dist/react/xv-tag-v2.d.ts +12 -0
- package/dist/react/xv-tag-v2.js +14 -0
- package/dist/react/xv-text-input-v2.d.ts +12 -0
- package/dist/react/xv-text-input-v2.js +14 -0
- package/dist/react/xv-textarea.d.ts +12 -0
- package/dist/react/xv-textarea.js +14 -0
- package/dist/react/xv-tile.d.ts +15 -0
- package/dist/react/xv-tile.js +14 -0
- package/dist/react/xv-toggle-tip.d.ts +12 -0
- package/dist/react/xv-toggle-tip.js +14 -0
- package/dist/react/xv-toggle.d.ts +12 -0
- package/dist/react/xv-toggle.js +14 -0
- package/dist/react/xv-tooltip-v2.d.ts +9 -0
- package/dist/react/xv-tooltip-v2.js +14 -0
- package/dist/types/components/xv-header/xv-header.d.ts +13 -29
- package/dist/types/components/xv-header-next/xv-header-next.d.ts +13 -29
- package/dist/types/components/xv-table/xv-table-cell/xv-table-cell.d.ts +43 -8
- package/dist/types/components/xv-table/xv-table-row/xv-table-row.d.ts +57 -18
- package/dist/types/components/xv-table/xv-table.d.ts +298 -9
- package/dist/types/components/xv-table/xv-table.model.d.ts +78 -0
- package/dist/types/components/xv-table/xv-table.utils.d.ts +47 -0
- package/dist/types/components.d.ts +1498 -209
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +126 -57
- package/dist/types/utils/table-layout.d.ts +7 -0
- package/dist/vscode-data.json +3293 -0
- package/dist/xv-webcomponents/index.esm.js +1 -1
- package/dist/xv-webcomponents/{p-fe9b38f8.entry.js → p-0c30d09f.entry.js} +1 -1
- package/dist/xv-webcomponents/p-6b58979e.entry.js +8 -0
- package/dist/xv-webcomponents/p-A3B7AR96.js +9 -0
- package/dist/xv-webcomponents/p-CDEU4jkD.js +1 -0
- package/dist/xv-webcomponents/p-DJC3-dS3.js +3 -0
- package/dist/xv-webcomponents/p-DSFVdw3w.js +1 -0
- package/dist/xv-webcomponents/p-c4173686.entry.js +1 -0
- package/dist/xv-webcomponents/xv-webcomponents.css +6 -6
- package/dist/xv-webcomponents/xv-webcomponents.esm.js +1 -1
- package/loader/index.d.ts +1 -1
- package/package.json +139 -61
- package/dist/cjs/_vars-Cyrk3TAl.js +0 -3423
- package/dist/cjs/maplibre-gl-CCZS3Rg5.js +0 -900
- package/dist/collection/components/xv-header/_vars.js +0 -51
- package/dist/collection/components/xv-table/_vars.js +0 -2
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.css +0 -58
- package/dist/collection/components/xv-table/xv-table-expand/xv-table-expand.js +0 -75
- package/dist/esm/_vars-BkYBzv3h.js +0 -3413
- package/dist/esm/maplibre-gl-CS4Eagm9.js +0 -813
- package/dist/types/components/xv-header/_vars.d.ts +0 -47
- package/dist/types/components/xv-table/_vars.d.ts +0 -15
- package/dist/types/components/xv-table/xv-table-expand/xv-table-expand.d.ts +0 -8
- package/dist/xv-webcomponents/p-7832549c.entry.js +0 -8
- package/dist/xv-webcomponents/p-BkYBzv3h.js +0 -1
- package/dist/xv-webcomponents/p-CQm2sRKT.js +0 -1
- package/dist/xv-webcomponents/p-CS4Eagm9.js +0 -10
- package/dist/xv-webcomponents/p-DmxA2ysB.js +0 -2
- package/dist/xv-webcomponents/p-f46bb687.entry.js +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MapLibre GL JS
|
|
3
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.9.0/LICENSE.txt
|
|
4
|
+
*/
|
|
5
|
+
var t=Object.create,e=Object.defineProperty,i=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,o=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports),a=(t,n,o,a)=>{if(n&&"object"==typeof n||"function"==typeof n)for(var l,h=r(n),u=0,c=h.length;u<c;u++)!s.call(t,l=h[u])&&l!==o&&e(t,l,{get:(t=>n[t]).bind(null,l),enumerable:!(a=i(n,l))||a.enumerable});return t};function l(t,e){this.x=t,this.y=e}let h,u;function c(){return h??=typeof OffscreenCanvas<"u"&&!!new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap,h}function f(){if(null==u&&(u=!1,c())){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){u=!0;break}}}return u||!1}l.prototype={clone(){return new l(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:l},l.convert=function(t){if(t instanceof l)return t;if(Array.isArray(t))return new l(+t[0],+t[1]);if(void 0!==t.x&&void 0!==t.y)return new l(+t.x,+t.y);throw Error("Expected [x, y] or {x, y} point format")};var p=typeof Float32Array<"u"?Float32Array:Array;function d(){var t=new p(9);return p!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function m(){var t=new p(16);return p!=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 _(t){var e=new p(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 g(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 y(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 v(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 w(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 b(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 x(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 D(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 M(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 E=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},A=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 F(){var t=new p(3);return p!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function S(t){var e=new p(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function C(t){var e=t[0],i=t[1],r=t[2];return Math.sqrt(e*e+i*i+r*r)}function z(t,e,i){var r=new p(3);return r[0]=t,r[1]=e,r[2]=i,r}function T(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t}function P(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function I(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function k(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 $(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 j(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function R(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 O(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 B(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 L(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 U(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 N=P,G=C;function q(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}F();function V(){var t=new p(4);return p!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Z(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 p(4);p!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var W=function(t,e,i,r){var n=new p(4);return n[0]=t,n[1]=e,n[2]=i,n[3]=r,n};function H(){var t=new p(2);return p!=Float32Array&&(t[0]=0,t[1]=0),t}function Y(t,e){var i=new p(2);return i[0]=t,i[1]=e,i}function X(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t}function J(t){var e=t[0],i=t[1];return Math.sqrt(e*e+i*i)}function K(t){return t[0]=0,t[1]=0,t}F(),z(1,0,0),z(0,1,0),V(),V(),d();var Q=function(t){var e=t[0],i=t[1];return e*e+i*i};H();const tt=8192;function et(t,e,i){return e*(tt/(t.tileSize*2**(i-t.tileID.overscaledZ)))}function it(t){return t instanceof Error?t:Error("string"==typeof t?t:String(t))}function rt(){return new Float64Array(4)}function nt(){return new Float64Array(3)}function st(){return new Float64Array(16)}function ot(){let t=new Float64Array(16);return g(t),t}function at(){let t=new Float32Array(16);return g(t),t}function lt(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]:et(e,i[0],t.zoom),n?i[1]:et(e,i[1],t.zoom)]}function ht(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function ut(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=R([],[e[0],e[1],e[2]],[i[0],i[1],i[2]]),s=R([],[i[0],i[1],i[2]],[t[0],t[1],t[2]]),o=R([],[t[0],t[1],t[2]],[e[0],e[1],e[2]]),a=I([],n,-t[3]);return T(a,a,I([],s,-e[3])),T(a,a,I([],o,-i[3])),I(a,a,1/r),a}function ct(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 ft(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 pt(t,e){let i=mt(t,360),r=mt(e,360),n=r-i,s=r>i?n-360:n+360;return Math.abs(n)<Math.abs(s)?n:s}function dt(t,e){let i=mt(t,2*Math.PI),r=mt(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 mt(t,e){return(t%e+e)%e}function _t(t,e,i,r,n){return gt(r,n,bt((t-e)/(i-e),0,1))}function gt(t,e,i){return t*(1-i)+e*i}function yt(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 vt(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 wt=vt(.25,.1,.25,1);function bt(t,e,i){return Math.min(i,Math.max(e,t))}function xt(t,e,i){let r=i-e,n=((t-e)%r+r)%r+e;return n===e?i:n}function Dt(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function Mt(t,e){let i={};for(let r of e)r in t&&(i[r]=t[r]);return i}let Et=1;function At(){return Et++}function Ft(t){return 2**t}function St(t){return Math.log(t)/Math.LN2}function Ct(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 zt(t,e){let i={};for(let r in t)i[r]=e.call(this,t[r],r,t);return i}function Tt(t,e){let i={};for(let r in t)e.call(this,t[r],r,t)&&(i[r]=t[r]);return i}function Pt(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(!Pt(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(!Pt(t[i],e[i]))return!1;return!0}return t===e}function It(t){return Array.isArray(t)?t.map(It):"object"==typeof t&&t?zt(t,It):t}const kt={};function $t(t){kt[t]||(typeof console<"u"&&console.warn(t),kt[t]=!0)}function jt(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}function Rt(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,h=o*s-a*n;if(0===h)return null;let u=(a*(t.y-i.y)-o*(t.x-i.x))/h;return new l(t.x+u*s,t.y+u*n)}function Ot(t){return typeof WorkerGlobalScope<"u"&&void 0!==t&&t instanceof WorkerGlobalScope}let Bt=null;function Lt(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap}function Ut(t,e,i,r){return t.addEventListener(e,i,r),{unsubscribe:()=>{t.removeEventListener(e,i,r)}}}function Nt(t){return t*Math.PI/180}function Gt(t){return t/Math.PI*180}function qt(t,e){return t.roll==e.roll&&t.pitch==e.pitch&&t.bearing==e.bearing}function Vt(t,e,i){let r=Y(e.x-i.x,e.y-i.y),n=Y(t.x-i.x,t.y-i.y);return Gt(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 Zt(t,e,i){let r=new Float64Array(4);return Z(r,t,e-90,i),r}const Wt=85.051129,Ht={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},Yt={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0};function Xt(t,e){return Ht[e]&&"touches"in t}function Jt(t,e){if(!Yt[e])return!1;let i=t,r=(i?.target)?.ownerDocument?.defaultView||window;return i instanceof r.MouseEvent||i instanceof r.WheelEvent}function Kt(t){return Ht[t]||Yt[t]}const Qt="AbortError";var te=class extends Error{constructor(t=Qt){super(t instanceof Error?t.message:t),this.name=Qt,t instanceof Error&&t.stack&&(this.stack=t.stack)}};function ee(t){return t instanceof Error&&"AbortError"===t.name}function ie(t){if(t.aborted)throw new te(t.reason)}const re={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ne(t){return re.REGISTERED_PROTOCOLS[t.substring(0,t.indexOf("://"))]}const se="global-dispatcher";var oe=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(Ot(self))return self.worker?.referrer;if("blob:"===window.location.protocol)try{return window.parent.location.href}catch{}return window.location.href}const le=async function(t,e){if(t.url.includes("://")&&!/^https?:|^file:/.test(t.url)){let i=ne(t.url);if(i){let r=await i(t,e);return r.data||"arrayBuffer"!==t.type?r:Dt(r,{data:new ArrayBuffer(0)})}if(Ot(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,targetMapId:se},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 ee(e)?e:new oe(0,it(e).message,t.url,new Blob)}if(!i.ok){let e=await i.blob();throw new oe(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 ie(e.signal),{data:s,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),etag:i.headers.get("ETag")}}(t,e);if(Ot(self)&&self.worker?.actor)return self.worker.actor.sendAsync({type:"GR",data:t,mustQueue:!0,targetMapId:se},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 oe(n.status,n.statusText,t.url,e))}},e.signal.addEventListener("abort",(()=>{n.abort(),r(new te(e.signal.reason))})),n.send(t.body)}))}(t,e)},he=(t,e)=>le(Dt(t,{type:"json"}),e),ue=(t,e)=>le(Dt(t,{type:"arrayBuffer"}),e);function ce(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}function fe(t,e,i){i[t]?.includes(e)||(i[t]||=[],i[t].push(e))}function pe(t,e,i){if(i?.[t]){let r=i[t].indexOf(e);-1!==r&&i[t].splice(r,1)}}var de=class{constructor(t,e={}){Dt(this,e),this.type=t}},me=class extends de{constructor(t,e={}){super("error",Dt({error:t},e))}},_e=class{on(t,e){return this._listeners||={},fe(t,e,this._listeners),{unsubscribe:()=>{this.off(t,e)}}}off(t,e){return pe(t,e,this._listeners),pe(t,e,this._oneTimeListeners),this}once(t,e){return e?(this._oneTimeListeners||={},fe(t,e,this._oneTimeListeners),this):new Promise((e=>this.once(t,e)))}fire(t,e){let i="string"==typeof t?new de(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)pe(r,t,this._oneTimeListeners),t.call(this,i);let n=this._eventedParent;n&&(Dt(i,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(i))}else i instanceof me&&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}},ge={$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 ye=ge,ve=["type","source","source-layer","minzoom","maxzoom","filter","layout"];var we=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 be={kind:"null"},xe={kind:"number"},De={kind:"string"},Me={kind:"boolean"},Ee={kind:"color"},Ae={kind:"projectionDefinition"},Fe={kind:"object"},Se={kind:"value"},Ce={kind:"collator"},ze={kind:"formatted"},Te={kind:"padding"},Pe={kind:"colorArray"},Ie={kind:"numberArray"},ke={kind:"resolvedImage"},$e={kind:"variableAnchorOffsetCollection"};function je(t,e){return{kind:"array",itemType:t,N:e}}function Re(t){if("array"===t.kind){let e=Re(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Oe=[be,xe,De,Me,Ee,Ae,ze,Fe,je(Se),Te,Ie,Pe,ke,$e];function Be(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Be(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 Oe)if(!Be(t,e))return null}return`Expected ${Re(t)} but found ${Re(e)} instead.`}function Le(t,e){return e.some((e=>e.kind===t.kind))}function Ue(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 Ne(t,e){return"array"===t.kind&&"array"===e.kind?t.itemType.kind===e.itemType.kind&&"number"==typeof t.N:t.kind===e.kind}const Ge=.96422,qe=.82521,Ve=4/29,Ze=6/29,We=3*Ze*Ze,He=Math.PI/180,Ye=180/Math.PI;function Xe(t){return(t%=360)<0&&(t+=360),t}function Je([t,e,i,r]){let n,s,o=Qe((.2225045*(t=Ke(t))+.7168786*(e=Ke(e))+.0606169*(i=Ke(i)))/1);t===e&&e===i?n=s=o:(n=Qe((.4360747*t+.3850649*e+.1430804*i)/Ge),s=Qe((.0139322*t+.0971045*e+.7141733*i)/qe));let a=116*o-16;return[a<0?0:a,500*(n-o),200*(o-s),r]}function Ke(t){return t<=.04045?t/12.92:((t+.055)/1.055)**2.4}function Qe(t){return t>.008856451679035631?t**(1/3):t/We+Ve}function ti([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*ii(n),s=Ge*ii(s),o=qe*ii(o),[ei(3.1338561*s-1.6168667*n-.4906146*o),ei(-.9787684*s+1.9161415*n+.033454*o),ei(.0719453*s-.2289914*n+1.4052427*o),r]}function ei(t){return(t=t<=.00304?12.92*t:1.055*t**(1/2.4)-.055)<0?0:t>1?1:t}function ii(t){return t>Ze?t*t*t:We*(t-Ve)}const ri=Object.hasOwn||function(t,e){return Object.prototype.hasOwnProperty.call(t,e)};function ni(t,e){return ri(t,e)?t[e]:void 0}function si(t){return parseInt(t.padEnd(2,t),16)/255}function oi(t,e){return ai(e?t/100:t,0,1)}function ai(t,e,i){return Math.min(Math.max(e,t),i)}function li(t){return!t.some(Number.isNaN)}const hi={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 ui(t,e,i){return t+i*(e-t)}function ci(t,e,i){return t.map(((t,r)=>ui(t,e[r],i)))}var fi=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=ni(hi,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[si(t.slice(i,i+=e)),si(t.slice(i,i+=e)),si(t.slice(i,i+=e)),si(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=[ai(+i/e,0,1),ai(+s/e,0,1),ai(+l/e,0,1),c?oi(+c,f):1];if(li(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,ai(+n,0,100),ai(+o,0,100),l?oi(+l,h):1];if(li(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=Xe(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]=Je(t),s=Math.sqrt(i*i+r*r);return[Math.round(1e4*s)?Xe(Math.atan2(r,i)*Ye):NaN,s,e,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",Je(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]=ci(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*He,ti([i,Math.cos(t)*e,Math.sin(t)*e,r])}([n,s??ui(a,c,r),ui(l,f,r),ui(h,p,r)]);return new t(d,m,_,g,!1)}case"lab":{let[n,s,o,a]=ti(ci(e.lab,i.lab,r));return new t(n,s,o,a,!1)}}}};const pi=["bottom","center","top"];var di=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}},mi=class t{constructor(t){this.sections=t}static fromString(e){return new t([new di(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("")}},_i=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(ci(e.values,i.values,r))}},gi=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(ci(e.values,i.values,r))}},yi=class t{constructor(t){this.values=t.slice()}static parse(e){if(e instanceof t)return e;if("string"==typeof e){let i=fi.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=fi.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(fi.interpolate(e.values[t],i.values[t],r,n));return new t(s)}},vi=class extends Error{constructor(t,e){super(t),this.name="RuntimeError",this.path=e}toJSON(){return this.message}};const wi=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);var bi=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||!wi.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 vi(`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 vi(`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([ui(e,l,r),ui(i,h,r)])}return new t(a)}},xi=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}},Di=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}},Mi=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 Ei(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 Ai(t){if(null===t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t||t instanceof Di||t instanceof fi||t instanceof Mi||t instanceof mi||t instanceof _i||t instanceof gi||t instanceof yi||t instanceof bi||t instanceof xi)return!0;if(Array.isArray(t)){for(let e of t)if(!Ai(e))return!1;return!0}if("object"==typeof t){for(let e in t)if(!Ai(t[e]))return!1;return!0}return!1}function Fi(t){if(null===t)return be;if("string"==typeof t)return De;if("boolean"==typeof t)return Me;if("number"==typeof t)return xe;if(t instanceof fi)return Ee;if(t instanceof Di)return Ae;if(t instanceof Mi)return Ce;if(t instanceof mi)return ze;if(t instanceof _i)return Te;if(t instanceof gi)return Ie;if(t instanceof yi)return Pe;if(t instanceof bi)return $e;if(t instanceof xi)return ke;if(Array.isArray(t)){let e,i=t.length;for(let i of t){let t=Fi(i);if(e){if(e===t)continue;e=Se;break}e=t}return je(e||Se,i)}return Fe}function Si(t){let e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof fi||t instanceof Di||t instanceof mi||t instanceof _i||t instanceof gi||t instanceof yi||t instanceof bi||t instanceof xi?t.toString():JSON.stringify(t)}var Ci=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(!Ai(e[1]))return i.error(`invalid value of type "${typeof e[1]}"`);let r=e[1],n=Fi(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 zi=["Unknown","Point","LineString","Polygon"];var Ti=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?zi[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=fi.parse(t),this._parseColorCache.set(t,e)),e}};function Pi(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 vi("Input is not a number.",i);a=l-1}return 0}var Ii=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,xe);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[Pi(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()))}},ki=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=$i(e,t.base,i,r);else if("linear"===t.name)n=$i(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])($i(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,xe),!s)return null;let a=[],l=null;"interpolate-hcl"!==r&&"interpolate-lab"!==r||i.expectedType==Pe?i.expectedType&&"value"!==i.expectedType.kind&&(l=i.expectedType):l=Ee;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 Ne(l,xe)||Ne(l,Ae)||Ne(l,Ee)||Ne(l,Te)||Ne(l,Ie)||Ne(l,Pe)||Ne(l,$e)||Ne(l,je(xe))?new t(l,r,n,s,a,i.key):i.error(`Type ${Re(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=Pi(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 ui(l,h,a);case"color":return fi.interpolate(l,h,a);case"padding":return _i.interpolate(l,h,a);case"colorArray":return yi.interpolate(l,h,a);case"numberArray":return gi.interpolate(l,h,a);case"variableAnchorOffsetCollection":return bi.interpolate(l,h,a,this.key);case"array":return ci(l,h,a);case"projectionDefinition":return Di.interpolate(l,h,a)}case"interpolate-hcl":switch(this.type.kind){case"color":return fi.interpolate(l,h,a,"hcl");case"colorArray":return yi.interpolate(l,h,a,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return fi.interpolate(l,h,a,"lab");case"colorArray":return yi.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 $i(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 ji={color:fi.interpolate,number:ui,padding:_i.interpolate,numberArray:gi.interpolate,colorArray:yi.interpolate,variableAnchorOffsetCollection:bi.interpolate,array:ci};var Ri=class t{constructor(t){this.type=ze,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,xe),!t))return null;let e=null;if(r["text-font"]&&(e=i.parse(r["text-font"],1,je(De)),!e))return null;let o=null;if(r["text-color"]&&(o=i.parse(r["text-color"],1,Ee),!o))return null;let a=null;if(r["vertical-align"]){if("string"==typeof r["vertical-align"]&&!pi.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,De),!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,Se);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 mi(this.sections.map((e=>{let i=e.content.evaluate(t);return Fi(i)===ke?new di("",i,null,null,null,e.verticalAlign?e.verticalAlign.evaluate(t):null):new di(Si(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 Oi(t,e,i=0,r=t.length-1,n=Li){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);Oi(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(Bi(t,i,e),n(t[r],s)>0&&Bi(t,i,r);o<a;){for(Bi(t,o,a),o++,a--;n(t[o],s)<0;)o++;for(;n(t[a],s)>0;)a--}0===n(t[i],s)?Bi(t,i,a):(a++,Bi(t,a,r)),a<=e&&(i=a+1),e<=a&&(r=a-1)}}function Bi(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Li(t,e){return t<e?-1:+(t>e)}function Ui(t,e){if(t.length<=1)return[t];let i,r,n=[];for(let e of t){let t=Gi(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||(Oi(n[t],e,1,n[t].length-1,Ni),n[t]=n[t].slice(0,e));return n}function Ni(t,e){return e.area-t.area}function Gi(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 qi={string:De,number:xe,boolean:Me,object:Fe};var Vi=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 qi)||"object"===r)return i.error('The item type argument of "array" must be one of string, number, boolean',1);t=qi[r],n++}else t=Se;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=je(t,s)}else{if(!qi[s])throw Error(`Types doesn't contain name = ${s}`);r=qi[s]}let o=[];for(;n<e.length;n++){let t=i.parse(e[n],n,Se);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(!Be(this.type,Fi(i)))return i;if(e===this.args.length-1)throw new vi(`Expected value to be of type ${Re(this.type)}, but found ${Re(Fi(i))} instead.`,this.key)}throw Error()}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}};const Zi={"to-boolean":Me,"to-color":Ee,"to-number":xe,"to-string":De};var Wi=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(!Zi[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=Zi[r],s=[];for(let t=1;t<e.length;t++){let r=i.parse(e[t],t,Se);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 fi)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.`:Ei(e[0],e[1],e[2],e[3]),!i))return new fi(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new vi(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=_i.parse(e);if(r)return r}throw new vi(`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=gi.parse(e);if(r)return r}throw new vi(`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=yi.parse(e);if(r)return r}throw new vi(`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=bi.parse(e);if(r)return r}throw new vi(`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 vi(`Could not convert ${JSON.stringify(e)} to number.`,this.key)}case"formatted":return mi.fromString(Si(this.args[0].evaluate(t)));case"resolvedImage":return xi.fromString(Si(this.args[0].evaluate(t)));case"projectionDefinition":{let e=this.args[0].evaluate(t);if(Di.parse(e))return e;throw new vi(`Could not parse projectionDefinition from value '${"string"==typeof e?e:JSON.stringify(e)}'`,this.key)}default:return Si(this.args[0].evaluate(t))}}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}},Hi=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()}},Yi=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}},Xi=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=>Be(n,t.type)))?new t(Se,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 xi&&!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 Ji(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 Ki(t,e,i,r){return 0===r.compare(e,i)}function Qi(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=Me,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,Se);if(!s)return null;if(!Ji(i,s.type))return e.concat(1).error(`"${i}" comparisons are not supported for type '${Re(s.type)}'.`);let o=e.parse(t[2],2,Se);if(!o)return null;if(!Ji(i,o.type))return e.concat(2).error(`"${i}" comparisons are not supported for type '${Re(o.type)}'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return e.error(`Cannot compare types '${Re(s.type)}' and '${Re(o.type)}'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Vi(o.type,[s],e.key):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Vi(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,Ce),!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=Fi(s),i=Fi(o);if(e.kind!==i.kind||"string"!==e.kind&&"number"!==e.kind)throw new vi(`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=Fi(s),i=Fi(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 tr=Qi("==",(function(t,e,i){return e===i}),Ki),er=Qi("!=",(function(t,e,i){return e!==i}),(function(t,e,i,r){return!Ki(0,e,i,r)})),ir=Qi("<",(function(t,e,i){return e<i}),(function(t,e,i,r){return r.compare(e,i)<0})),rr=Qi(">",(function(t,e,i){return e>i}),(function(t,e,i,r){return r.compare(e,i)>0})),nr=Qi("<=",(function(t,e,i){return e<=i}),(function(t,e,i,r){return r.compare(e,i)<=0})),sr=Qi(">=",(function(t,e,i){return e>=i}),(function(t,e,i,r){return r.compare(e,i)>=0}));var or=class t{constructor(t,e,i){this.type=Ce,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,Me);if(!n)return null;let s=i.parse(void 0!==r["diacritic-sensitive"]&&r["diacritic-sensitive"],1,Me);if(!s)return null;let o=null;return r.locale&&(o=i.parse(r.locale,1,De),!o)?null:new t(n,s,o)}evaluate(t){return new Mi(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 ar=8192;function lr(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*ar),Math.round(r*n*ar)]}function hr(t,e){let i=2**e.z,r=(t[1]/ar+e.y)/i;return[ur((t[0]/ar+e.x)/i),cr(r)]}function ur(t){return 360*t-180}function cr(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function fr(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 pr(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function dr(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 mr(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 _r(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]])&&!(!xr(t,e,i,r)||!xr(i,r,t,e))}function gr(t,e,i){for(let r of i)for(let i=0;i<r.length-1;++i)if(_r(t,e,r[i],r[i+1]))return!0;return!1}function yr(t,e,i=!1){let r=!1;for(let n of e)for(let e=0;e<n.length-1;e++){if(mr(t,n[e],n[e+1]))return i;dr(t,n[e],n[e+1])&&(r=!r)}return r}function vr(t,e){for(let i of e)if(yr(t,i))return!0;return!1}function wr(t,e){for(let i of t)if(!yr(i,e))return!1;for(let i=0;i<t.length-1;++i)if(gr(t[i],t[i+1],e))return!1;return!0}function br(t,e){for(let i of e)if(wr(t,i))return!0;return!1}function xr(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 Dr(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=lr(t[n][r],i);fr(e,o),s.push(o)}r.push(s)}return r}function Mr(t,e,i){let r=[];for(let n=0;n<t.length;n++){let s=Dr(t[n],e,i);r.push(s)}return r}function Er(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}fr(e,t)}function Ar(t,e,i,r){let n=2**r.z*ar,s=[r.x*ar,r.y*ar],o=[];for(let r of t)for(let t of r){let r=[t.x+s[0],t.y+s[1]];Er(r,e,i,n),o.push(r)}return o}function Fr(t,e,i,r){let n=2**r.z*ar,s=[r.x*ar,r.y*ar],o=[];for(let i of t){let t=[];for(let r of i){let i=[r.x+s[0],r.y+s[1]];fr(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)Er(r,e,i,n)}return o}var Sr=class t{constructor(t,e){this.type=Me,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(Ai(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=Dr(e.coordinates,r,n),o=Ar(t.geometry(),i,r,n);if(!pr(i,r))return!1;for(let t of o)if(!yr(t,s))return!1}if("MultiPolygon"===e.type){let s=Mr(e.coordinates,r,n),o=Ar(t.geometry(),i,r,n);if(!pr(i,r))return!1;for(let t of o)if(!vr(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=Dr(e.coordinates,r,n),o=Fr(t.geometry(),i,r,n);if(!pr(i,r))return!1;for(let t of o)if(!wr(t,s))return!1}if("MultiPolygon"===e.type){let s=Mr(e.coordinates,r,n),o=Fr(t.geometry(),i,r,n);if(!pr(i,r))return!1;for(let t of o)if(!br(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}},Cr=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 zr=Math.PI/180;var Tr=class{constructor(t){let e=6378.137*zr*1e3,i=Math.cos(t*zr),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 Pr(t,e){return e[0]-t[0]}function Ir(t){return t[1]-t[0]+1}function kr(t,e){return t[1]>=t[0]&&t[1]<e}function $r(t,e){if(t[0]>t[1])return[null,null];let i=Ir(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 jr(t,e){if(!kr(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)fr(i,t[r]);return i}function Rr(t){let e=[1/0,1/0,-1/0,-1/0];for(let i of t)for(let t of i)fr(e,t);return e}function Or(t){return t[0]!==-1/0&&t[1]!==-1/0&&t[2]!==1/0&&t[3]!==1/0}function Br(t,e,i){if(!Or(t)||!Or(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 Lr(t,e,i){let r=i.pointOnLine(e,t);return i.distance(t,r.point)}function Ur(t,e,i,r,n){let s=Math.min(Lr(t,[i,r],n),Lr(e,[i,r],n)),o=Math.min(Lr(i,[t,e],n),Lr(r,[t,e],n));return Math.min(s,o)}function Nr(t,e,i,r,n){if(!kr(e,t.length)||!kr(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(_r(e,a,r,o))return 0;s=Math.min(s,Ur(e,a,r,o,n))}}return s}function Gr(t,e,i,r,n){if(!kr(e,t.length)||!kr(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 qr(t,e,i){if(yr(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,Lr(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 Vr(t,e,i,r){if(!kr(e,t.length))return NaN;for(let r=e[0];r<=e[1];++r)if(yr(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(_r(e,o,s,l))return 0;n=Math.min(n,Ur(e,o,s,l,r))}}return n}function Zr(t,e){for(let i of t)for(let t of i)if(yr(t,e,!0))return!0;return!1}function Wr(t,e,i,r=1/0){let n=Rr(t),s=Rr(e);if(r!==1/0&&Br(n,s,i)>=r)return r;if(pr(n,s)){if(Zr(t,e))return 0}else if(Zr(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(_r(n,a,r,l))return 0;o=Math.min(o,Ur(n,a,r,l,i))}}return o}function Hr(t,e,i,r,n,s){if(!s)return;let o=Br(jr(r,s),n,i);o<e&&t.push([o,s,[0,0]])}function Yr(t,e,i,r,n,s,o){if(!s||!o)return;let a=Br(jr(r,s),jr(n,o),i);a<e&&t.push([a,s,o])}function Xr(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 Cr([[0,[0,t.length-1],[0,0]]],Pr),a=Rr(i);for(;o.length>0;){let n=o.pop();if(n[0]>=s)continue;let l=n[1],h=e?50:100;if(Ir(l)<=h){if(!kr(l,t.length))return NaN;if(e){let e=Vr(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=qr(t[e],i,r);if(s=Math.min(s,n),0===s)return 0}}else{let i=$r(l,e);Hr(o,s,r,t,a,i[0]),Hr(o,s,r,t,a,i[1])}}return s}function Jr(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 Cr([[0,[0,t.length-1],[0,i.length-1]]],Pr);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(Ir(l)<=u&&Ir(h)<=c){if(!kr(l,t.length)&&kr(h,i.length))return NaN;let s;if(e&&r)s=Nr(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=Lr(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=Lr(t[i],e,n),o=Math.min(o,s),0===o)return o}else s=Gr(t,l,i,h,n),o=Math.min(o,s)}else{let s=$r(l,e),u=$r(h,r);Yr(a,o,n,t,i,s[0],u[0]),Yr(a,o,n,t,i,s[0],u[1]),Yr(a,o,n,t,i,s[1],u[0]),Yr(a,o,n,t,i,s[1],u[1])}}return o}function Kr(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 Qr=class t{constructor(t,e){this.type=xe,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(Ai(e[1])){let i=e[1];if("FeatureCollection"===i.type)return new t(i,i.features.map((t=>Kr(t.geometry))).flat());if("Feature"===i.type)return new t(i,Kr(i.geometry));if("type"in i&&"coordinates"in i)return new t(i,Kr(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=>hr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let n=new Tr(r[0][1]),s=1/0;for(let t of e){switch(t.type){case"Point":s=Math.min(s,Jr(r,!1,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Jr(r,!1,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Xr(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=>hr([e.x,e.y],t.canonical)));if(0===i.length)return NaN;let n=new Tr(r[0][1]),s=1/0;for(let t of e){switch(t.type){case"Point":s=Math.min(s,Jr(r,!0,[t.coordinates],!1,n,s));break;case"LineString":s=Math.min(s,Jr(r,!0,t.coordinates,!0,n,s));break;case"Polygon":s=Math.min(s,Xr(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=Ui(i,0).map((e=>e.map((e=>e.map((e=>hr([e.x,e.y],t.canonical))))))),n=new Tr(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,Xr([t.coordinates],!1,e,n,s));break;case"LineString":s=Math.min(s,Xr(t.coordinates,!0,e,n,s));break;case"Polygon":s=Math.min(s,Wr(e,t.coordinates,n,s))}if(0===s)return s}return s}(t,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}},tn=class t{constructor(t){this.key=t,this.type=Se}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?ni(e,this.key)??null:null}eachChild(){}outputDefined(){return!1}};const en={"==":tr,"!=":er,">":rr,"<":ir,">=":sr,"<=":nr,array:Vi,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,xe),n=i.parse(e[2],2,je(i.expectedType||Se));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 vi(`Array index out of bounds: ${e} < 0.`,this.key);if(e>=i.length)throw new vi(`Array index out of bounds: ${e} > ${i.length-1}.`,this.key);if(e!==Math.floor(e))throw new vi(`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:Vi,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,Me);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:Xi,collator:or,format:Ri,image:class t{constructor(t){this.type=ke,this.input=t}static parse(e,i){if(2!==e.length)return i.error("Expected two arguments.");let r=i.parse(e[1],1,De);return r?new t(r):i.error("No image name provided.")}evaluate(t){let e=this.input.evaluate(t),i=xi.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=Me}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,Se),n=i.parse(e[2],2,Se);return r&&n?Le(r.type,[Me,De,xe,be,Se])?new t(r,n,i.key):i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Re(r.type)} instead`):null}evaluate(t){let e=this.needle.evaluate(t),i=this.haystack.evaluate(t);if(!i)return!1;if(!Ue(e,["boolean","string","number","null"]))throw new vi(`Expected first argument to be of type boolean, string, number or null, but found ${Re(Fi(e))} instead.`,this.key);if(!Ue(i,["string","array"]))throw new vi(`Expected second argument to be of type array or string, but found ${Re(Fi(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=xe}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,Se),n=i.parse(e[2],2,Se);if(!r||!n)return null;if(!Le(r.type,[Me,De,xe,be,Se]))return i.error(`Expected first argument to be of type boolean, string, number or null, but found ${Re(r.type)} instead`);if(4===e.length){let s=i.parse(e[3],3,xe);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(!Ue(i,["boolean","string","number","null"]))throw new vi(`Expected first argument to be of type boolean, string, number or null, but found ${Re(Fi(i))} instead.`,this.key);if(this.fromIndex&&(e=this.fromIndex.evaluate(t)),Ue(r,["string"])){let t=r.indexOf(i,e);return-1===t?-1:[...r.slice(0,t)].length}if(Ue(r,["array"]))return r.indexOf(i,e);throw new vi(`Expected second argument to be of type array or string, but found ${Re(Fi(r))} instead.`,this.key)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}},interpolate:ki,"interpolate-hcl":ki,"interpolate-lab":ki,length:class t{constructor(t,e){this.input=t,this.key=e,this.type=xe}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 ${Re(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 vi(`Expected value to be of type string or array, but found ${Re(Fi(e))} instead.`,this.key)}eachChild(t){t(this.input)}outputDefined(){return!1}},let:Hi,literal:Ci,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,Fi(t)))return null}else r=Fi(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,Se);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(Fi(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:Vi,"number-format":class t{constructor(t,e,i,r,n,s){this.type=De,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,xe);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,De),!s))return null;let o=null;if(n.currency&&(o=i.parse(n.currency,1,De),!o))return null;let a=null;if(n.unit&&(a=i.parse(n.unit,1,De),!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,xe),!l))return null;let h=null;return n["max-fraction-digits"]&&(h=i.parse(n["max-fraction-digits"],1,xe),!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:Vi,semiliteral:class t{constructor(t){let e=null;for(let i of t){if(e){if(e===i.type)continue;e=Se;break}e=i.type}this.type=je(e??Se,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(!Ai(e[1]))return i.error(`invalid value of type "${typeof e[1]}"`);let r=e[1],n=Fi(r);if("array"===n.kind){let e=r.map((t=>i.parse(t,null,Se)));return new t(e)}return new Ci(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,Se),n=i.parse(e[2],2,xe);if(!r||!n)return null;if(!Le(r.type,[je(Se),De,Se]))return i.error(`Expected first argument to be of type array or string, but found ${Re(r.type)} instead`);if(4===e.length){let s=i.parse(e[3],3,xe);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)),Ue(i,["string"]))return[...i].slice(r,e).join("");if(Ue(i,["array"]))return i.slice(r,e);throw new vi(`Expected first argument to be of type array or string, but found ${Re(Fi(i))} instead.`,this.key)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}},step:Ii,string:Vi,"to-boolean":Wi,"to-color":Wi,"to-number":Wi,"to-string":Wi,var:Yi,within:Sr,distance:Qr,"global-state":tn};var rn=class extends Error{constructor(t,e){super(e),this.message=e,this.key=t}},nn=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)}},sn=class t{constructor(t,e,i=[],r,n=new nn,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 e?this.concat(e,i,r)._parse(t,n):this._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 Vi(e,[t],i):"coerce"===r?new Wi(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 Ci)&&"resolvedImage"!==i.type.kind&&this._isConstant(i)){let e=new Ti;try{i=new Ci(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 rn(i,t))}checkSubtype(t,e){let i=Be(t,e);return i&&this.error(i),i}},on=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 sn(i.registry,cn,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(Re).join(", ")})`:`(${Re(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(Re(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 an(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=Ei(e,i,r,o);if(a)throw new vi(a,s);return new fi(e/255,i/255,r/255,o,!1)}function ln(t,e){return t in e&&void 0!==e[t]}function hn(t,e){let i=e[t];return void 0===i?null:i}function un(t){return{type:t}}function cn(t){if(t instanceof Yi)return cn(t.boundExpression);if(t instanceof on&&"error"===t.name||t instanceof or||t instanceof Sr||t instanceof Qr||t instanceof tn)return!1;let e=t instanceof Wi||t instanceof Vi,i=!0;return t.eachChild((t=>{i&&=e?cn(t):t instanceof Ci})),!!i&&fn(t)&&dn(t,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function fn(t){if(t instanceof on&&("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 Sr||t instanceof Qr)return!1;let e=!0;return t.eachChild((t=>{e&&!fn(t)&&(e=!1)})),e}function pn(t){if(t instanceof on&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!pn(t)&&(e=!1)})),e}function dn(t,e){if(t instanceof on&&e.indexOf(t.name)>=0)return!1;let i=!0;return t.eachChild((t=>{i&&!dn(t,e)&&(i=!1)})),i}function mn(t){return"data-driven"===t["property-type"]||"cross-faded-data-driven"===t["property-type"]}function _n(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}function gn(t){return!!t.expression&&t.expression.interpolated}on.register(en,{error:[{kind:"error"},[De],(t,[e],i)=>{throw new vi(e.evaluate(t),i)}],typeof:[De,[Se],(t,[e])=>Re(Fi(e.evaluate(t)))],"to-rgba":[je(xe,4),[Ee],(t,[e])=>{let[i,r,n,s]=e.evaluate(t).rgb;return[255*i,255*r,255*n,s]}],rgb:[Ee,[xe,xe,xe],an],rgba:[Ee,[xe,xe,xe,xe],an],has:{type:Me,overloads:[[[De],(t,[e])=>ln(e.evaluate(t),t.properties())],[[De,Fe],(t,[e,i])=>ln(e.evaluate(t),i.evaluate(t))]]},get:{type:Se,overloads:[[[De],(t,[e])=>hn(e.evaluate(t),t.properties())],[[De,Fe],(t,[e,i])=>hn(e.evaluate(t),i.evaluate(t))]]},"feature-state":[Se,[De],(t,[e])=>hn(e.evaluate(t),t.featureState||{})],properties:[Fe,[],t=>t.properties()],"geometry-type":[De,[],t=>t.geometryType()],id:[Se,[],t=>t.id()],zoom:[xe,[],t=>t.globals.zoom],"heatmap-density":[xe,[],t=>t.globals.heatmapDensity||0],elevation:[xe,[],t=>t.globals.elevation||0],"line-progress":[xe,[],t=>t.globals.lineProgress||0],accumulated:[Se,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[xe,un(xe),(t,e)=>{let i=0;for(let r of e)i+=r.evaluate(t);return i}],"*":[xe,un(xe),(t,e)=>{let i=1;for(let r of e)i*=r.evaluate(t);return i}],"-":{type:xe,overloads:[[[xe,xe],(t,[e,i])=>e.evaluate(t)-i.evaluate(t)],[[xe],(t,[e])=>-e.evaluate(t)]]},"/":[xe,[xe,xe],(t,[e,i])=>e.evaluate(t)/i.evaluate(t)],"%":[xe,[xe,xe],(t,[e,i])=>e.evaluate(t)%i.evaluate(t)],ln2:[xe,[],()=>Math.LN2],pi:[xe,[],()=>Math.PI],e:[xe,[],()=>Math.E],"^":[xe,[xe,xe],(t,[e,i])=>e.evaluate(t)**+i.evaluate(t)],sqrt:[xe,[xe],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))],log2:[xe,[xe],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[xe,[xe],(t,[e])=>Math.sin(e.evaluate(t))],cos:[xe,[xe],(t,[e])=>Math.cos(e.evaluate(t))],tan:[xe,[xe],(t,[e])=>Math.tan(e.evaluate(t))],asin:[xe,[xe],(t,[e])=>Math.asin(e.evaluate(t))],acos:[xe,[xe],(t,[e])=>Math.acos(e.evaluate(t))],atan:[xe,[xe],(t,[e])=>Math.atan(e.evaluate(t))],min:[xe,un(xe),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[xe,un(xe),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[xe,[xe],(t,[e])=>Math.abs(e.evaluate(t))],round:[xe,[xe],(t,[e])=>{let i=e.evaluate(t);return i<0?-Math.round(-i):Math.round(i)}],floor:[xe,[xe],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[xe,[xe],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[Me,[De,Se],(t,[e,i])=>t.properties()[e.value]===i.value],"filter-id-==":[Me,[Se],(t,[e])=>t.id()===e.value],"filter-type-==":[Me,[De],(t,[e])=>t.geometryType()===e.value],"filter-<":[Me,[De,Se],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<n}],"filter-id-<":[Me,[Se],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<r}],"filter->":[Me,[De,Se],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Me,[Se],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>r}],"filter-<=":[Me,[De,Se],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Me,[Se],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i<=r}],"filter->=":[Me,[De,Se],(t,[e,i])=>{let r=t.properties()[e.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Me,[Se],(t,[e])=>{let i=t.id(),r=e.value;return typeof i==typeof r&&i>=r}],"filter-has":[Me,[Se],(t,[e])=>{let i=e.value,r=t.properties();return i in r&&void 0!==r[i]}],"filter-has-id":[Me,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Me,[je(De)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[Me,[je(Se)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[Me,[De,je(Se)],(t,[e,i])=>i.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[Me,[De,je(Se)],(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:Me,overloads:[[[Me,Me],(t,[e,i])=>e.evaluate(t)&&i.evaluate(t)],[un(Me),(t,e)=>{for(let i of e)if(!i.evaluate(t))return!1;return!0}]]},any:{type:Me,overloads:[[[Me,Me],(t,[e,i])=>e.evaluate(t)||i.evaluate(t)],[un(Me),(t,e)=>{for(let i of e)if(i.evaluate(t))return!0;return!1}]]},"!":[Me,[Me],(t,[e])=>!e.evaluate(t)],"is-supported-script":[Me,[De],(t,[e])=>{let i=t.globals&&t.globals.isSupportedScript;return!i||i(e.evaluate(t))}],upcase:[De,[De],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[De,[De],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[De,un(Se),(t,e)=>e.map((e=>Si(e.evaluate(t)))).join("")],split:[je(De),[De,De],(t,[e,i])=>e.evaluate(t).split(i.evaluate(t))],join:[De,[je(De),De],(t,[e,i])=>e.evaluate(t).join(i.evaluate(t))],"resolved-locale":[De,[Ce],(t,[e])=>e.evaluate(t).resolvedLocale()]});const yn=/^(.*)-transition$/;function vn(t,...e){for(let i of e)for(let e in i)t[e]=i[e];return t}function wn(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function bn(t){return"object"==typeof t&&!!t&&!Array.isArray(t)&&Fi(t)===Fe}function xn(t){return t}function Dn(t,e){let i=t.stops&&"object"==typeof t.stops[0][0],r=i||!(i||void 0!==t.property),n=t.type||(gn(e)?"exponential":"interval"),s=function(t){switch(t.type){case"color":return fi.parse;case"padding":return _i.parse;case"numberArray":return gi.parse;case"colorArray":return yi.parse;default:return null}}(e);if(s&&((t=vn({},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 Fn;case"interval":return An;case"categorical":return En;case"identity":return Sn;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,Dn(i[t],e)]);let s={name:"linear"};return{kind:"composite",interpolationType:s,interpolationFactor:ki.interpolationFactor.bind(void 0,s),zoomStops:n.map((t=>t[0])),evaluate:({zoom:i},r)=>Fn({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:ki.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?Mn(t.default,e.default):l(t,e,n,o,a)}}}function Mn(t,e,i){return void 0!==t?t:void 0!==e?e:void 0!==i?i:void 0}function En(t,e,i,r,n){return Mn(typeof i===n?r[i]:void 0,t.default,e.default)}function An(t,e,i){if("number"!==wn(i))return Mn(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=Pi(t.stops.map((t=>t[0])),i,"");return t.stops[n][1]}function Fn(t,e,i){let r=void 0===t.base?1:t.base;if("number"!==wn(i))return Mn(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=Pi(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=ji[e.type]||xn;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 Sn(t,e,i){switch(e.type){case"color":i=fi.parse(i);break;case"formatted":i=mi.fromString(i.toString());break;case"resolvedImage":i=xi.fromString(i.toString());break;case"padding":i=_i.parse(i);break;case"colorArray":i=yi.parse(i);break;case"numberArray":i=gi.parse(i);break;default:wn(i)!==e.type&&("enum"!==e.type||!e.values[i])&&(i=void 0)}return Mn(i,t.default,e.default)}function Cn(t){return{result:"success",value:t}}function zn(t){return{result:"error",value:t}}var Tn=class{constructor(t,e,i,r){this.expression=t,this._warningHistory={},this._evaluator=new Ti,this._defaultValue=i?Nn(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=Gn(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=Gn(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 vi(`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 vi?t.path:"",i=`${e}|${t.message}`;return this._warningHistory[i]||(this._warningHistory[i]=!0,typeof console<"u"&&console.warn(Pn(this._rootKey,e,t.message,this._defaultValue))),this._defaultValue}}};function Pn(t,e,i,r){return`${t}${e}: ${i}${null==r?"":` Falling back to ${String(r)}.`}`}function In(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 kn(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in en}function $n(t,e,i,r){In(e);let n=new sn(en,cn,[],i?function(t){let e={color:Ee,string:De,number:xe,enum:De,boolean:Me,formatted:ze,padding:Te,numberArray:Ie,colorArray:Pe,projectionDefinition:Ae,resolvedImage:ke,variableAnchorOffsetCollection:$e};return"array"===t.type?je(e[t.value]||Se,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?Cn(new Tn(s,e,i,r)):zn(n.errors)}var jn=class{constructor(t,e,i){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!pn(e.expression),this.globalStateRefs=Un(e.expression),this._globalState=i}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=Gn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=Gn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}},Rn=class{constructor(t,e,i,r,n){this.kind=t,this.zoomStops=i,this._styleExpression=e,this.isStateDependent="camera"!==t&&!pn(e.expression),this.globalStateRefs=Un(e.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(t,e,i,r,n,s){return this._globalState&&(t=Gn(t,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(t,e,i,r,n,s)}evaluate(t,e,i,r,n,s){return this._globalState&&(t=Gn(t,this._globalState)),this._styleExpression.evaluate(t,e,i,r,n,s)}interpolationFactor(t,e,i){return this.interpolationType?ki.interpolationFactor(this.interpolationType,t,e,i):0}};function On(t,e,i,r){let n=$n(t,e,i,r);if("error"===n.result)return n;let s=n.value.expression,o=fn(s);if(!o&&!mn(i))return zn([new rn("","data expressions not supported")]);let a=dn(s,["zoom"]);if(!a&&!_n(i))return zn([new rn("","zoom expressions not supported")]);let l=Ln(s);return l||a?l instanceof rn?zn([l]):l instanceof ki&&!gn(i)?zn([new rn("",'"interpolate" expressions cannot be used with this property')]):Cn(l?new Rn(o?"camera":"composite",n.value,l.labels,l instanceof ki?l.interpolation:void 0,r):new jn(o?"constant":"source",n.value,r)):zn([new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}var Bn=class t{constructor(t,e,i){this.isStateDependent=!1,this.globalStateRefs=new Set,this._globalState=null,In(e),this._parameters=t,this._specification=i,this._rootKey=e,this._defaultValue=Nn(i),this._warningHistory={};let r=Dn(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(Pn(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 Ln(t){let e=null;if(t instanceof Hi)e=Ln(t.result);else if(t instanceof Xi){for(let i of t.args)if(e=Ln(i),e)break}else(t instanceof Ii||t instanceof ki)&&t.input instanceof on&&"zoom"===t.input.name&&(e=t);return e instanceof rn||t.eachChild((t=>{let i=Ln(t);i instanceof rn?e=i:!e&&i?e=new rn("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new rn("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),e}function Un(t,e=new Set){return t instanceof tn&&e.add(t.key),t.eachChild((t=>{Un(t,e)})),e}function Nn(t){if("color"===t.type&&bn(t.default))return new fi(0,0,0,0);switch(t.type){case"color":return fi.parse(t.default)||null;case"padding":return _i.parse(t.default)||null;case"numberArray":return gi.parse(t.default)||null;case"colorArray":return yi.parse(t.default)||null;case"variableAnchorOffsetCollection":return bi.parse(t.default)||null;case"projectionDefinition":return Di.parse(t.default)||null;default:return void 0===t.default?null:t.default}}function Gn(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 qn(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=qn(i);if("expression"===t)return"expression";"legacy"===t&&(e=!0)}return e?"legacy":"neutral"}(t.slice(1));default:return"expression"}}function Vn(t){return"legacy"!==qn(t)}function Zn(t){return"$type"===t?["geometry-type"]:"$id"===t?["id"]:["get",t]}function Wn(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],Zn(t[1]),t[2]];case"in":case"!in":{if(t.length<2||"string"!=typeof t[1])return null;let e=["in",Zn(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 Hn(t,e,i){let r=i[t];return Array.isArray(r)?Vn(r)?Yn(r,e.concat(t)):{path:e.concat(t),legacyFilter:r}:null}function Yn(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=Hn(i,e,t);if(r)return r}break;case"!":{let i=Hn(1,e,t);if(i)return i;break}case"case":for(let i=1;i<t.length-1;i+=2){let r=Hn(i,e,t);if(r)return r}}return null}const Xn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function Jn(t,e,i){if(null==t)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};Vn(t)?function(t,e){let i=Yn(t);if(!i||typeof console>"u")return;let r=i.path.map((t=>`[${t}]`)).join("");console.warn(`${e}${r}: ${Wn(i.legacyFilter)}`)}(t,e):t=ts(t);let r=$n(t,e,Xn,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:Qn(t),getGlobalStateRefs:()=>Un(r.value.expression)}}function Kn(t,e){return t<e?-1:+(t>e)}function Qn(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(Qn(t[e]))return!0;return!1}function ts(t){if(!t)return!0;let e=t[0];return t.length<=1?"any"!==e:"=="===e?es(t[1],t[2],"=="):"!="===e?ns(es(t[1],t[2],"==")):"<"===e||">"===e||"<="===e||">="===e?es(t[1],t[2],e):"any"===e?function(t){return["any"].concat(t.map(ts))}(t.slice(1)):"all"===e?["all"].concat(t.slice(1).map(ts)):"none"===e?["all"].concat(t.slice(1).map(ts).map(ns)):"in"===e?is(t[1],t.slice(2)):"!in"===e?ns(is(t[1],t.slice(2))):"has"===e?rs(t[1]):"!has"!==e||ns(rs(t[1]))}function es(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 is(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(Kn)]]:["filter-in-small",t,["literal",e]]}}function rs(t){switch(t){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",t]}}function ns(t){return["!",t]}function ss(t){let e=t.value;return e?[new we(t.key,e,"constants have been deprecated as of v8")]:[]}function os(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}function as(t){if(Array.isArray(t))return t.map(as);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){let e={};for(let i in t)e[i]=as(t[i]);return e}return os(t)}function ls(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=wn(i);if("object"!==h)return[new we(e,i,`object expected, ${h} found`)];for(let t in i){let h,u=t.split(".")[0],c=ni(r,u)||r["*"];if(ni(n,u))h=n[u];else if(ni(r,u)){if(void 0===i[t])continue;h=a}else if(n["*"])h=n["*"];else{if(!r["*"]){l.push(new we(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 we(e,i,`missing required property "${t}"`));return l}function hs(t){let e=t.value,i=t.valueSpec,r=t.style,n=t.styleSpec,s=t.key,o=t.arrayElementValidator||t.validateSpec;if("array"!==wn(e))return[new we(s,e,`array expected, ${wn(e)} found`)];if(i.length&&e.length!==i.length)return[new we(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"===wn(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 us(t){let e=t.key,i=t.value,r=t.valueSpec,n=wn(i);return"number"===n&&i!=i&&(n="NaN"),"number"===n?"minimum"in r&&i<r.minimum?[new we(e,i,`${i} is less than the minimum value ${r.minimum}`)]:"maximum"in r&&i>r.maximum?[new we(e,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]:[new we(e,i,`number expected, ${n} found`)]}function cs(t){let e,i,r,n=t.valueSpec,s=os(t.value.type),o={},a="categorical"!==s&&void 0===t.value.property,l=!a,h="array"===wn(t.value.stops)&&"array"===wn(t.value.stops[0])&&"object"===wn(t.value.stops[0][0]),u=ls({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 we(t.key,t.value,'identity function may not have a "stops" property')];let e=[],i=t.value;return e=e.concat(hs({key:t.key,value:i,valueSpec:t.valueSpec,validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:c})),"array"===wn(i)&&0===i.length&&e.push(new we(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 we(t.key,t.value,'missing required property "property"')),"identity"!==s&&!t.value.stops&&u.push(new we(t.key,t.value,'missing required property "stops"')),"exponential"===s&&t.valueSpec.expression&&!gn(t.valueSpec)&&u.push(new we(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(l&&!mn(t.valueSpec)?u.push(new we(t.key,t.value,"property functions not supported")):a&&!_n(t.valueSpec)&&u.push(new we(t.key,t.value,"zoom functions not supported"))),("categorical"===s||h)&&void 0===t.value.property&&u.push(new we(t.key,t.value,'"property" property is required')),u;function c(t){let e=[],s=t.value,a=t.key;if("array"!==wn(s))return[new we(a,s,`array expected, ${wn(s)} found`)];if(2!==s.length)return[new we(a,s,`array length 2 expected, length ${s.length} found`)];if(h){if("object"!==wn(s[0]))return[new we(a,s,`object expected, ${wn(s[0])} found`)];if(void 0===s[0].zoom)return[new we(a,s,"object stop key must have zoom")];if(void 0===s[0].value)return[new we(a,s,"object stop key must have value")];if(r&&r>os(s[0].zoom))return[new we(a,s[0].zoom,"stop zoom values must appear in ascending order")];os(s[0].zoom)!==r&&(r=os(s[0].zoom),i=void 0,o={}),e=e.concat(ls({key:`${a}[0]`,value:s[0],valueSpec:{zoom:{}},validateSpec:t.validateSpec,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:us,value:f}}))}else e=e.concat(f({key:`${a}[0]`,value:s[0]},s));return kn(as(s[1]))?e.concat([new we(`${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=wn(t.value),l=os(t.value),h=null===t.value?r:t.value;if(e){if(a!==e)return[new we(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 we(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 mn(n)&&void 0===s&&(e+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new we(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 we(t.key,h,"stop domain values must appear in ascending order")]:(i=l,"categorical"===s&&l in o?[new we(t.key,h,"stop domain values must be unique")]:(o[l]=!0,[])):[new we(t.key,h,`integer expected, found ${l}`)]}}function fs(t){let e=("property"===t.expressionContext?On:$n)(as(t.value),t.key,t.valueSpec);if("error"===e.result)return e.value.map((e=>new we(`${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 we(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&&!pn(i))return[new we(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext&&!pn(i))return[new we(t.key,t.value,'"feature-state" data expressions are not supported with filters.')];if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!dn(i,["zoom","feature-state"]))return[new we(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!fn(i))return[new we(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function ps(t){let e=t.key,i=t.value,r=wn(i);return"string"===r?fi.parse(String(i))?[]:[new we(e,i,`color expected, "${i}" found`)]:[new we(e,i,`color expected, ${r} found`)]}function ds(t){let e=t.key,i=t.value,r=t.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(os(i))&&n.push(new we(e,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(os(i))&&n.push(new we(e,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function ms(t,e){let i=t;for(let t of e)i=i[t];return i}function _s(t,e){let i=Yn(e);return i?[new we(`${t.key}${i.path.map((t=>`[${t}]`)).join("")}`,ms(t.value,i.path),Wn(i.legacyFilter),null,"warning")]:[]}function gs(t){let e=as(t.value);return Vn(e)?[..._s(t,e),...fs(vn({},t,{expressionContext:"filter",valueSpec:{value:"boolean"}}))]:ys(t)}function ys(t){let e=t.value,i=t.key;if("array"!==wn(e))return[new we(i,e,`array expected, ${wn(e)} found`)];let r,n=t.styleSpec,s=[];if(e.length<1)return[new we(i,e,"filter array must have at least 1 element")];switch(s=s.concat(ds({key:`${i}[0]`,value:e[0],valueSpec:n.filter_operator})),os(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&"$type"===os(e[1])&&s.push(new we(i,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":3!==e.length&&s.push(new we(i,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(r=wn(e[1]),"string"!==r&&s.push(new we(`${i}[1]`,e[1],`string expected, ${r} found`)));for(let t=2;t<e.length;t++)r=wn(e[t]),"$type"===os(e[1])?s=s.concat(ds({key:`${i}[${t}]`,value:e[t],valueSpec:n.geometry_type})):"string"!==r&&"number"!==r&&"boolean"!==r&&s.push(new we(`${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(ys({key:`${i}[${r}]`,value:e[r],styleSpec:t.styleSpec}));break;case"has":case"!has":r=wn(e[1]),2===e.length?"string"!==r&&s.push(new we(`${i}[1]`,e[1],`string expected, ${r} found`)):s.push(new we(i,e,`filter array for "${e[0]}" operator must have 2 elements`))}return s}function vs(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(yn);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 we(i,o,`unknown property "${a}"`)];if("string"===wn(o)&&mn(c)&&!c.tokens&&(u=/^{([^}]+)}$/.exec(o)))return[new we(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&&bn(as(o))&&"identity"===os(o.type)&&f.push(new we(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 ws(t){return vs(t,"paint")}function bs(t){return vs(t,"layout")}function xs(t){let e=[],i=t.value,r=t.key,n=t.style,s=t.styleSpec;if("object"!==wn(i))return[new we(r,i,`object expected, ${wn(i)} found`)];!i.type&&!i.ref&&e.push(new we(r,i,'either "type" or "ref" is required'));let o=os(i.type),a=os(i.ref);if(i.id){let s=os(i.id);for(let o=0;o<t.arrayIndex;o++){let t=n.layers[o];os(t.id)===s&&e.push(new we(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 we(r,i[t],`"${t}" is prohibited for ref layers`))})),n.layers.forEach((e=>{os(e.id)===a&&(t=e)})),t?t.ref?e.push(new we(r,i.ref,"ref cannot reference another ref layer")):o=os(t.type):e.push(new we(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&&os(t.type);t?"vector"===s&&"raster"===o?e.push(new we(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==s&&"hillshade"===o||"raster-dem"!==s&&"color-relief"===o?e.push(new we(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===s&&"raster"!==o?e.push(new we(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 we(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 we(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new we(r,i,`layer "${i.id}" must specify a "source-layer"`)):e.push(new we(r,i.source,`source "${i.source}" not found`))}else e.push(new we(r,i,'missing required property "source"'));return"raster"===o&&i.paint?.resampling&&i.paint?.["raster-resampling"]&&e.push(new we(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(ls({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:gs,layout:t=>ls({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>bs(vn({layerType:o},t))}}),paint:t=>ls({layer:i,key:t.key,value:t.value,style:t.style,styleSpec:t.styleSpec,validateSpec:t.validateSpec,objectElementValidators:{"*":t=>ws(vn({layerType:o},t))}})}})),e}function Ds(t){let e=t.value,i=t.key,r=wn(e);return"string"===r?[]:[new we(i,e,`string expected, ${r} found`)]}const Ms={promoteId:function({key:t,value:e}){if("string"===wn(e))return Ds({key:t,value:e});{let i=[];for(let r in e)i.push(...Ds({key:`${t}.${r}`,value:e[r]}));return i}}};function Es(t){let e=t.value,i=t.key,r=t.styleSpec,n=t.style,s=t.validateSpec;if(!e.type)return[new we(i,e,'"type" is required')];let o,a=os(e.type);switch(a){case"vector":case"raster":return o=ls({key:i,value:e,valueSpec:r[`source_${a.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:Ms,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=wn(i);if(void 0===i)return o;if("object"!==a)return o.push(new we("source_raster_dem",i,`object expected, ${a} found`)),o;let l="custom"===os(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 we(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 we(a,i[a],`unknown property "${a}"`));return o}({sourceName:i,value:e,style:t.style,styleSpec:r,validateSpec:s}),o;case"geojson":if(o=ls({key:i,value:e,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:s,objectElementValidators:Ms}),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(...fs({key:`${i}.${t}.map`,value:n,expressionContext:"cluster-map"})),o.push(...fs({key:`${i}.${t}.reduce`,value:s,expressionContext:"cluster-reduce"}))}return o;case"video":return ls({key:i,value:e,valueSpec:r.source_video,style:n,validateSpec:s,styleSpec:r});case"image":return ls({key:i,value:e,valueSpec:r.source_image,style:n,validateSpec:s,styleSpec:r});case"canvas":return[new we(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return ds({key:`${i}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function As(t){let e=t.value,i=t.styleSpec,r=i.light,n=t.style,s=[],o=wn(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new we("light",e,`object expected, ${o} found`)]),s;for(let o in e){let a=o.match(yn);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 we(o,e[o],`unknown property "${o}"`)])}return s}function Fs(t){let e=t.value,i=t.styleSpec,r=i.sky,n=t.style,s=wn(e);if(void 0===e)return[];if("object"!==s)return[new we("sky",e,`object expected, ${s} found`)];let o=[];for(let s in e){let a=s.match(yn);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 we(s,e[s],`unknown property "${s}"`)])}return o}function Ss(t){let e=t.value,i=t.styleSpec,r=i.terrain,n=t.style,s=[],o=wn(e);if(void 0===e)return s;if("object"!==o)return s=s.concat([new we("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 we(o,e[o],`unknown property "${o}"`)]);return s}function Cs(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 we(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 we(r,i,`all the sprites' URLs must be unique, but ${i[o].url} is duplicated`)),s.push(i[o].url),e=e.concat(ls({key:`${r}[${o}]`,value:i[o],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:t.validateSpec}));return e}return Ds({key:r,value:i})}function zs(t){return!!t&&t.constructor===Object}function Ts(t){return zs(t.value)?[]:[new we(t.key,t.value,`object expected, ${wn(t.value)} found`)]}const Ps=1114111,Is=/^u\+(?:([0-9a-f]{1,6})(?:-([0-9a-f]{1,6}))?|([0-9a-f]{0,5}\?{1,6}))$/i;function ks(t,e){if("string"!==wn(e))return[];let i=`${e}`,r=()=>[new we(t,e,'invalid unicode range, expected a value such as "U+26", "U+0-10FFFF" or "U+4??"')],n=i.match(Is);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>Ps||h>Ps?[new we(t,e,"unicode range is out of bounds, the maximum code point is U+10FFFF")]:l>h?[new we(t,e,`unicode range start must not be greater than its end, but ${i} is`)]:[]}function $s(t){let e=t.key??"font-faces",i=t.value,r=t.validateSpec,n=t.styleSpec??ge,s=t.style;if(!zs(i))return[new we(e,i,`object expected, ${wn(i)} found`)];let o=[];for(let t in i){let a=i[t],l=wn(a);if("string"===l)o.push(...Ds({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(...ls({key:a,value:h,valueSpec:i,styleSpec:n,style:s,validateSpec:r}));let u=zs(h)?h["unicode-range"]:void 0;if("array"===wn(u))for(let[t,e]of u.entries())o.push(...ks(`${a}.unicode-range[${t}]`,e))}}else o.push(new we(`${e}.${t}`,a,`string or array expected, ${l} found`))}return o}const js={"*":()=>[],array:hs,boolean:function(t){let e=t.value,i=t.key,r=wn(e);return"boolean"===r?[]:[new we(i,e,`boolean expected, ${r} found`)]},number:us,color:ps,constants:ss,enum:ds,filter:gs,function:cs,layer:xs,object:ls,source:Es,light:As,sky:Fs,terrain:Ss,projection:function(t){let e=t.value,i=t.styleSpec,r=i.projection,n=t.style,s=wn(e);if(void 0===e)return[];if("object"!==s)return[new we("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 we(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=wn(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 we(e,i,`projection expected, invalid type "${r}" found`)]:[new we(e,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:Ds,formatted:function(t){return 0===Ds(t).length?[]:fs(t)},resolvedImage:function(t){return 0===Ds(t).length?[]:fs(t)},padding:function(t){let e=t.key,i=t.value;if("array"===wn(i)){if(i.length<1||i.length>4)return[new we(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 us({key:e,value:i,valueSpec:{}})},numberArray:function(t){let e=t.key,i=t.value;if("array"===wn(i)){let r={type:"number"};if(i.length<1)return[new we(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 us({key:e,value:i,valueSpec:{}})},colorArray:function(t){let e=t.key,i=t.value;if("array"===wn(i)){if(i.length<1)return[new we(e,i,"array length at least 1 expected, length 0 found")];let t=[];for(let r=0;r<i.length;r++)t=t.concat(ps({key:`${e}[${r}]`,value:i[r]}));return t}return ps({key:e,value:i})},variableAnchorOffsetCollection:function(t){let e=t.key,i=t.value,r=wn(i),n=t.styleSpec;if("array"!==r||i.length<1||i.length%2!=0)return[new we(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(ds({key:`${e}[${r}]`,value:i[r],valueSpec:n.layout_symbol["text-anchor"]})),s=s.concat(hs({key:`${e}[${r+1}]`,value:i[r+1],valueSpec:{length:2,value:"number"},validateSpec:t.validateSpec,style:t.style,styleSpec:n}));return s},sprite:Cs,state:Ts,fontFaces:$s};function Rs(t){let e=t.value,i=t.valueSpec,r=t.styleSpec;return t.validateSpec=Rs,i.expression&&bn(os(e))?cs(t):i.expression&&kn(as(e))?fs(t):i.type&&js[i.type]?js[i.type](t):ls(vn({},t,{valueSpec:i.type?r[i.type]:i}))}function Os(t){let e=t.value,i=t.key,r=Ds(t);return r.length||(-1===e.indexOf("{fontstack}")&&r.push(new we(i,e,'"glyphs" url must include a "{fontstack}" token')),-1===e.indexOf("{range}")&&r.push(new we(i,e,'"glyphs" url must include a "{range}" token'))),r}function Bs(t,e=ye){let i=[];return i=i.concat(Rs({key:"",value:t,valueSpec:e.$root,styleSpec:e,style:t,validateSpec:Rs,objectElementValidators:{glyphs:Os,"*":()=>[]}})),t.constants&&(i=i.concat(ss({key:"constants",value:t.constants}))),Us(i)}function Ls(t){return function(e){return t(Object.assign({},e,{validateSpec:Rs}))}}function Us(t){return[].concat(t).sort(((t,e)=>t.line-e.line))}function Ns(t){return function(...e){return Us(t.apply(this,e))}}Bs.source=Ns(Ls(Es)),Bs.sprite=Ns(Ls(Cs)),Bs.glyphs=Ns(Ls(Os)),Bs.fontFaces=Ns(Ls($s)),Bs.light=Ns(Ls(As)),Bs.sky=Ns(Ls(Fs)),Bs.terrain=Ns(Ls(Ss)),Bs.state=Ns(Ls(Ts)),Bs.layer=Ns(Ls(xs)),Bs.filter=Ns(Ls(gs)),Bs.paintProperty=Ns(Ls(ws)),Bs.layoutProperty=Ns(Ls(bs));const Gs={type:"enum","property-type":"data-constant",expression:{interpolated:!1,parameters:["global-state"]},values:{visible:{},none:{}},transition:!1,default:"visible"};var qs=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=$n(t,this._rootKey,Gs,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=Un(e.value.expression)}getGlobalStateRefs(){return this._globalStateRefs}};const Vs=Bs,Zs=new Set(Object.keys(ye).filter((t=>t.startsWith("source_"))).map((t=>t.slice(7).replaceAll("_","-"))));function Ws(t,e){let i=function(t){return Object.entries(t.sources??{}).filter((([,t])=>!Zs.has(t.type))).map((([t])=>`sources.${t}`))}(e);return Hs(t,Vs(e).filter((({message:t})=>!i.some((e=>t.startsWith(`${e}:`)||t.startsWith(`${e}.`))))))}function Hs(t,e){let i=!1;for(let r of e)"warning"!==r.severity?(t.fire(new me(Error(r.message))),i=!0):$t(r.message);return i}function Ys(t,e,i,r){return!1!==r?.validate&&Hs(t,e({styleSpec:ye,...i}))}var Xs=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 Js={};function Ks(t,e,i={}){if(Js[t])throw Error(`${t} is already registered.`);Object.defineProperty(e,"_classRegistryKey",{value:t,writeable:!1}),Js[t]={klass:e,omit:i.omit||[],shallow:i.shallow||[]}}Ks("Object",Object),Ks("Set",Set),Ks("TransferableGridIndex",Xs),Ks("Color",fi),Ks("Error",Error),Ks("AJAXError",oe),Ks("ResolvedImage",xi),Ks("StylePropertyFunction",Bn),Ks("StyleExpression",Tn,{omit:["_evaluator"]}),Ks("ZoomDependentExpression",Rn),Ks("ZoomConstantExpression",jn),Ks("CompoundExpression",on,{omit:["_evaluate"]});for(let t in en)en[t]._classRegistryKey||Ks(`Expression_${t}`,en[t]);function Qs(t){return t&&typeof ArrayBuffer<"u"&&(t instanceof ArrayBuffer||"ArrayBuffer"===t.constructor?.name)}function to(t){return t.$name||t.constructor._classRegistryKey}function eo(t){return!function(t){if("object"!=typeof t||!t)return!1;let e=to(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||Qs(t)||Lt(t)||ArrayBuffer.isView(t)||t instanceof ImageData)}function io(t,e){if(eo(t))return(Qs(t)||Lt(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(io(r,e));return i}if("object"!=typeof t)throw Error("can't serialize object of type "+typeof t);let i=to(t);if(!i)throw Error(`can't serialize object of unregistered class ${t.constructor.name}`);if(!Js[i])throw Error(`${i} is not registered.`);let{klass:r}=Js[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)||Js[i].omit.includes(r))continue;let s=t[r];void 0!==s&&(n[r]=Js[i].shallow.includes(r)?s:io(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 ro(t){if(eo(t))return t;if(Array.isArray(t))return t.map(ro);if("object"!=typeof t)throw Error("can't deserialize object of type "+typeof t);let e=to(t)||"Object";if(!Js[e])throw Error(`can't deserialize unregistered class ${e}`);let{klass:i}=Js[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]=Js[e].shallow.includes(i)?n:ro(n)}return r}var no=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))}},so=class{constructor(t,e){this.zoom=t,e?(this.now=e.now||0,this.fadeDuration=e.fadeDuration||0,this.zoomHistory=e.zoomHistory||new no,this.transition=e.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new no,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}}};var oo=class{constructor(t,e,i,r){this.property=t,this.value=e,this.expression=function(t,e,i,r){if(bn(t))return new Bn(t,e,i);if(kn(t)){let n=On(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=fi.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=bi.parse(t):"projectionDefinition"===i.type&&"string"==typeof t&&(e=Di.parse(t)):e=yi.parse(t):e=gi.parse(t):e=_i.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}possiblyEvaluate(t,e,i){return this.property.possiblyEvaluate(this,t,e,i)}},ao=class{constructor(t,e,i){this.property=t,this.value=new oo(t,void 0,e,i)}transitioned(t,e){return new ho(this.property,this.value,e,Dt({},t.transition,this.transition),t.now)}untransitioned(){return new ho(this.property,this.value,null,{},0)}},lo=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 It(this._values[t].value.value)}setValue(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new ao(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].value=new oo(this._values[t].property,null===e?void 0:It(e),this._propertyRootKey(t),this._globalState)}getTransition(t){return It(this._values[t].transition)}setTransition(t,e){Object.hasOwn(this._values,t)||(this._values[t]=new ao(this._values[t].property,this._propertyRootKey(t),this._globalState)),this._values[t].transition=It(e)||void 0}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 uo(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 uo(this._properties);for(let e of Object.keys(this._values))t._values[e]=this._values[e].untransitioned();return t}},ho=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))}}},uo=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,e,i){let r=new po(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}},co=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 It(this._values[t].value)}setValue(t,e){this._values[t]=new oo(this._values[t].property,null===e?void 0:It(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 po(this._properties);for(let n of Object.keys(this._values))r._values[n]=this._values[n].possiblyEvaluate(t,e,i);return r}},fo=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)}},po=class{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}};function mo(t){if(Array.isArray(t))return t.length;let e=t?.values;return Array.isArray(e)?e.length:void 0}function _o(t,e){let i=mo(t),r=mo(e);return void 0!==i&&void 0!==r&&i!==r}var go=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(_o(t,e))return $t(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=ji[this.specification.type];return r?r(t,e,i):t}},yo=class{constructor(t,e,i){this.specification=t,this.name=e,this.overrides=i}possiblyEvaluate(t,e,i,r){return new fo(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 fo(this,{kind:"constant",value:void 0},t.parameters);if(_o(t.value.value,e.value.value))return $t(`Property "${this.name}" is trying to interpolate arrays of different lengths. Rendering may 'jump'.`),e;let r=ji[this.specification.type];if(r){let n=r(t.value.value,e.value.value,i);return new fo(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)}},vo=class extends yo{possiblyEvaluate(t,e,i,r){if(void 0===t.value)return new fo(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 fo(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 fo(this,{kind:"constant",value:i},e)}return new fo(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}},wo=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 so(Math.floor(e.zoom-1),e)),t.expression.evaluate(new so(Math.floor(e.zoom),e)),t.expression.evaluate(new so(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}},bo=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}},xo=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 oo(i,void 0,i.name,void 0),n=this.defaultTransitionablePropertyValues[e]=new ao(i,i.name,void 0);this.defaultTransitioningPropertyValues[e]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[e]=r.possiblyEvaluate({})}}};Ks("DataDrivenProperty",yo),Ks("DataConstantProperty",go),Ks("CrossFadedDataDrivenProperty",vo),Ks("CrossFadedProperty",wo),Ks("ColorRampProperty",bo);const Do=" is a PAINT property not a LAYOUT property. Use get/setPaintProperty instead?",Mo=" is a LAYOUT property not a PAINT property. Use get/setLayoutProperty instead?";var Eo=class extends _e{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 qs(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=Jn(t.filter,`layers[${this.id}].filter`,i)),e.layout&&(this._unevaluatedLayout=new co(e.layout,`layers[${this.id}].layout`,i)),e.paint)){this._transitionablePaint=new lo(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 po(e.paint)}}setFilter(t){this.filter=t,this._featureFilter=Jn(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+Do);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 me(Error(t+Do))):null!=e&&this._validate(Vs.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+Mo);return this._transitionablePaint.getTransition(e)}if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))throw Error(t+Mo);return this._transitionablePaint.getValue(t)}setPaintProperty(t,e,i={}){if("visibility"===t||this._unevaluatedLayout?.hasProperty(t))return this.fire(new me(Error(t+Mo))),!1;if(null!=e&&this._validate(Vs.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)}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),Tt(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 Ys(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 fo&&mn(e.property.specification)&&("source"===e.value.kind||"composite"===e.value.kind)&&e.value.isStateDependent)return!0}return!1}};let Ao;var Fo={get paint(){return Ao||=new xo({"raster-opacity":new go(ye.paint_raster["raster-opacity"],"raster-opacity"),"raster-hue-rotate":new go(ye.paint_raster["raster-hue-rotate"],"raster-hue-rotate"),"raster-brightness-min":new go(ye.paint_raster["raster-brightness-min"],"raster-brightness-min"),"raster-brightness-max":new go(ye.paint_raster["raster-brightness-max"],"raster-brightness-max"),"raster-saturation":new go(ye.paint_raster["raster-saturation"],"raster-saturation"),"raster-contrast":new go(ye.paint_raster["raster-contrast"],"raster-contrast"),resampling:new go(ye.paint_raster.resampling,"resampling"),"raster-resampling":new go(ye.paint_raster["raster-resampling"],"raster-resampling"),"raster-fade-duration":new go(ye.paint_raster["raster-fade-duration"],"raster-fade-duration")})}};const So=t=>"raster"===t.type;var Co=class extends Eo{constructor(t,e){super(t,Fo,e)}};const zo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};var To=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}},Po=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 Io(t,e=1){let i=0,r=0;return{members:t.map((t=>{let n=function(t){return zo[t].BYTES_PER_ELEMENT}(t.type),s=i=ko(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:ko(i,Math.max(r,e)),alignment:e}}function ko(t,e){return Math.ceil(t/e)*e}var $o=class extends Po{_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}};$o.prototype.bytesPerElement=4,Ks("StructArrayLayout2i4",$o);var jo=class extends Po{_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}};jo.prototype.bytesPerElement=6,Ks("StructArrayLayout3i6",jo);var Ro=class extends Po{_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}};Ro.prototype.bytesPerElement=8,Ks("StructArrayLayout4i8",Ro);var Oo=class extends Po{_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}};Oo.prototype.bytesPerElement=12,Ks("StructArrayLayout2i4i12",Oo);var Bo=class extends Po{_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=4*t,l=8*t;return this.int16[a+0]=e,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=s,this.uint8[l+7]=o,t}};Bo.prototype.bytesPerElement=8,Ks("StructArrayLayout2i4ub8",Bo);var Lo=class extends Po{_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}};Lo.prototype.bytesPerElement=8,Ks("StructArrayLayout2f8",Lo);var Uo=class extends Po{_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}};Uo.prototype.bytesPerElement=20,Ks("StructArrayLayout10ui20",Uo);var No=class extends Po{_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}};No.prototype.bytesPerElement=16,Ks("StructArrayLayout8ui16",No);var Go=class extends Po{_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}};Go.prototype.bytesPerElement=28,Ks("StructArrayLayout4i4ui4i1f28",Go);var qo=class extends Po{_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}};qo.prototype.bytesPerElement=12,Ks("StructArrayLayout3f12",qo);var Vo=class extends Po{_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}};Vo.prototype.bytesPerElement=4,Ks("StructArrayLayout1ul4",Vo);var Zo=class extends Po{_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}};Zo.prototype.bytesPerElement=20,Ks("StructArrayLayout6i1ul2ui20",Zo);var Wo=class extends Po{_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}};Wo.prototype.bytesPerElement=12,Ks("StructArrayLayout2i2i2i12",Wo);var Ho=class extends Po{_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}};Ho.prototype.bytesPerElement=16,Ks("StructArrayLayout2f1f2i16",Ho);var Yo=class extends Po{_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}};Yo.prototype.bytesPerElement=16,Ks("StructArrayLayout2ub2f2i16",Yo);var Xo=class extends Po{_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}};Xo.prototype.bytesPerElement=6,Ks("StructArrayLayout3ui6",Xo);var Jo=class extends Po{_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}};Jo.prototype.bytesPerElement=52,Ks("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i1f52",Jo);var Ko=class extends Po{_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}};Ko.prototype.bytesPerElement=68,Ks("StructArrayLayout8i15ui1ul2f2ui1f68",Ko);var Qo=class extends Po{_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}};Qo.prototype.bytesPerElement=4,Ks("StructArrayLayout1f4",Qo);var ta=class extends Po{_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}};ta.prototype.bytesPerElement=12,Ks("StructArrayLayout1ui2f12",ta);var ea=class extends Po{_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}};ea.prototype.bytesPerElement=8,Ks("StructArrayLayout1ul2ui8",ea);var ia=class extends Po{_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}};ia.prototype.bytesPerElement=4,Ks("StructArrayLayout2ui4",ia);var ra=class extends Po{_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}};ra.prototype.bytesPerElement=2,Ks("StructArrayLayout1ui2",ra);var na=class extends Po{_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}};na.prototype.bytesPerElement=16,Ks("StructArrayLayout4f16",na);var sa=class extends To{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 l(this.anchorPointX,this.anchorPointY)}};sa.prototype.size=20;var oa=class extends Zo{get(t){return new sa(this,t)}};Ks("CollisionBoxArray",oa);var aa=class extends To{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]}};aa.prototype.size=52;var la=class extends Jo{get(t){return new aa(this,t)}};Ks("PlacedSymbolArray",la);var ha=class extends To{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]}};ha.prototype.size=68;var ua=class extends Ko{get(t){return new ha(this,t)}};Ks("SymbolInstanceArray",ua);var ca=class extends Qo{getoffsetX(t){return this.float32[1*t+0]}};Ks("GlyphOffsetArray",ca);var fa=class extends jo{getx(t){return this.int16[3*t+0]}gety(t){return this.int16[3*t+1]}gettileUnitDistanceFromAnchor(t){return this.int16[3*t+2]}};Ks("SymbolLineVertexArray",fa);var pa=class extends To{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]}};pa.prototype.size=12;var da=class extends ta{get(t){return new pa(this,t)}};Ks("TextAnchorOffsetArray",da);var ma=class extends To{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]}};ma.prototype.size=8;var _a=class extends ea{get(t){return new ma(this,t)}};Ks("FeatureIndexArray",_a);var ga=class extends $o{},ya=class extends jo{},va=class extends Ro{},wa=class extends $o{},ba=class extends $o{},xa=class extends Oo{},Da=class extends Bo{},Ma=class extends Lo{},Ea=class extends Uo{},Aa=class extends No{},Fa=class extends Go{},Sa=class extends qo{},Ca=class extends Vo{},za=class extends Wo{},Ta=class extends Ho{},Pa=class extends Yo{},Ia=class extends Xo{},ka=class extends Xo{},$a=class extends ia{},ja=class extends ra{};const Ra=Io([{name:"a_pos",components:2,type:"Int16"}],4).members;var Oa=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&&$t(`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 Ba(t,e){return 256*(t=bt(Math.floor(t),0,255))+bt(Math.floor(e),0,255)}Oa.MAX_VERTEX_ARRAY_LENGTH=65535,Ks("SegmentVector",Oa);const La=Io([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),Ua=Io([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var Na=o(((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})})),Ga=o(((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}})),qa=((i,r,s)=>(s=null==i?{}:t(n(i)),a(e(s,"default",{value:i,enumerable:!0}),i)))(o(((t,e)=>{var i=Na(),r=Ga();e.exports=i,e.exports.murmur3=i,e.exports.murmur2=r}))()),Va=class t{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,e,i,r){this.ids.push(Za(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=Za(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 Wa(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 Za(t){let e=+t;return!isNaN(e)&&e<=2**53-1?e:(0,qa.default)(String(t))}function Wa(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;Ha(t,s,o),Ha(e,3*s,3*o),Ha(e,3*s+1,3*o+1),Ha(e,3*s+2,3*o+2)}o-i<r-o?(Wa(t,e,i,o),i=o+1):(Wa(t,e,o+1,r),r=o)}}function Ha(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}Ks("FeaturePositionMap",Va);var Ya=class{constructor(t,e){this.gl=t.gl,this.location=e}},Xa=class extends Ya{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1i(this.location,t))}},Ja=class extends Ya{constructor(t,e){super(t,e),this.current=0}set(t){this.current!==t&&(this.current=t,this.gl.uniform1f(this.location,t))}},Ka=class extends Ya{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]))}},Qa=class extends Ya{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]))}},tl=class extends Ya{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]))}},el=class extends Ya{constructor(t,e){super(t,e),this.current=fi.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))}},il=class extends Ya{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)}}},rl=class extends Ya{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 nl=new Float32Array(16);var sl=class extends Ya{constructor(t,e){super(t,e),this.current=nl}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 ol(t){return[Ba(255*t.r,255*t.g),Ba(255*t.b,255*t.a)]}var al=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 el(t,e):new Ja(t,e)}},ll=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 tl(t,e):new Ja(t,e)}},hl=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 so(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 so(0,n),i,r);this._setPaintValue(t,e,s)}_setPaintValue(t,e,i){if("color"===this.type){let r=ol(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()}},ul=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 so(this.zoom,i),e,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new so(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 so(this.zoom,n),i,r),o=this.expression.evaluate(new so(this.zoom+1,n),i,r);this._setPaintValue(t,e,s,o)}_setPaintValue(t,e,i,r){if("color"===this.type){let n=ol(i),s=ol(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=bt(this.expression.interpolationFactor(i,this.zoom,this.zoom+1),0,1);t.set(r)}getBinding(t,e,i){return new Ja(t,e)}},cl=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()}},fl=class extends cl{getPositions(t){return t.imagePositions}getPositionIds(t){return t.patterns?.[this.layerId]}getVertexAttributes(){return La.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)}},pl=class extends cl{getPositions(t){return t.dashPositions}getPositionIds(t){return t.dashes?.[this.layerId]}getVertexAttributes(){return Ua.members}emplace(t,e,i,r){t.emplace(e,0,i.y,i.height,i.width,0,r.y,r.height,r.width)}},dl=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 fo&&mn(s.property.specification)))continue;let o=_l(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 ll(a.value,o):new al(a.value,o,l),r.push(`/u_${n}`);else if("source"===a.kind||c){let i=gl(n,l,"source");this.binders[n]=c?"line-dasharray"===n?new pl(a,l,h,e,i,t.id):new fl(a,l,h,e,i,t.id):new hl(a,o,l,i),r.push(`/a_${n}`)}else{let t=gl(n,l,"composite");this.binders[n]=new ul(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 hl||e instanceof ul?e.maxValue:0}populatePaintArrays(t,e,i){for(let r in this.binders){let n=this.binders[r];(n instanceof hl||n instanceof ul||n instanceof cl)&&n.populatePaintArray(t,e,i)}}setConstantPatternPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof ll&&r.setConstantPatternPositions(t,e)}}setConstantDashPositions(t,e){for(let i in this.binders){let r=this.binders[i];r instanceof ll&&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 hl||a instanceof ul||a instanceof cl)&&!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 al||i instanceof ll)&&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 hl||i instanceof ul)for(let e of i.paintVertexAttributes)t.push(e.name);else if(i instanceof cl){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 al||i instanceof ll||i instanceof ul)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 al||n instanceof ll||n instanceof ul)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 cl){let e=2===t.fromScale?i.zoomInPaintVertexBuffer:i.zoomOutPaintVertexBuffer;e&&this._buffers.push(e)}else(i instanceof hl||i instanceof ul)&&i.paintVertexBuffer&&this._buffers.push(i.paintVertexBuffer)}}upload(t){for(let e in this.binders){let i=this.binders[e];(i instanceof hl||i instanceof ul||i instanceof cl)&&i.upload(t)}this.updatePaintBuffers()}destroy(){for(let t in this.binders){let e=this.binders[t];(e instanceof hl||e instanceof ul||e instanceof cl)&&e.destroy()}}},ml=class{constructor(t,e,i=()=>!0){this.programConfigurations={};for(let r of t)this.programConfigurations[r.id]=new dl(r,e,i);this.needsUpload=!1,this._featureMap=new Va,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 _l(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 gl(t,e,i){let r={color:{source:Lo,composite:na},number:{source:Qo,composite:Lo}};return function(t){return{"line-pattern":{source:Ea,composite:Ea},"fill-pattern":{source:Ea,composite:Ea},"fill-extrusion-pattern":{source:Ea,composite:Ea},"line-dasharray":{source:Aa,composite:Aa}}[t]}(t)?.[i]||r[e][i]}Ks("ConstantBinder",al),Ks("CrossFadedConstantBinder",ll),Ks("SourceExpressionBinder",hl),Ks("CrossFadedPatternBinder",fl),Ks("CrossFadedDasharrayBinder",pl),Ks("CompositeExpressionBinder",ul),Ks("ProgramConfiguration",dl,{omit:["_buffers"]}),Ks("ProgramConfigurationSet",ml);const yl=-16384;function vl(t){let e=tt/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=bt(t,yl,16383),i.y=bt(r,yl,16383),(t<i.x||t>i.x+1||r<i.y||r>i.y+1)&&$t("Geometry exceeds allowed extent, reduce your vector tile buffer size")}return i}function wl(t,e){return{type:t.type,id:t.id,properties:t.properties,geometry:e?vl(t):[]}}const bl=-32768;function xl(t,e,i,r,n){t.emplaceBack(bl+8*e+r,bl+8*i+n)}var Dl=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 wa,this.indexArray=new ka,this.segments=new Oa,this.programConfigurations=new ml(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 so(this.zoom),u=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:r,index:a,sourceLayerIndex:l}of t){let t=wl(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:vl(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,Ra),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++)xl(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 Ml(t,e){for(let i of t)if(Il(e,i))return!0;for(let i of e)if(Il(t,i))return!0;return Sl(t,e)}function El(t,e,i){return!!Il(t,e)||zl(e,t,i)}function Al(t,e){if(1===t.length)return Pl(e,t[0]);for(let i of e)for(let e of i)if(Il(t,e))return!0;for(let i of t)if(Pl(e,i))return!0;for(let i of e)if(Sl(t,i))return!0;return!1}function Fl(t,e,i){if(t.length>1){if(Sl(t,e))return!0;for(let r of e)if(zl(r,t,i))return!0}for(let r of t)if(zl(r,e,i))return!0;return!1}function Sl(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(Cl(r,n,e[t],e[t+1]))return!0}return!1}function Cl(t,e,i,r){return jt(t,i,r)!==jt(e,i,r)&&jt(t,e,i)!==jt(t,e,r)}function zl(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(Tl(t,e[i-1],e[i])<r)return!0;return!1}function Tl(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 Pl(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 Il(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 kl(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 l(e,i),new l(e,n),new l(r,n),new l(r,i)];if(t.length>2)for(let e of s)if(Il(t,e))return!0;for(let e=0;e<t.length-1;e++)if($l(t[e],t[e+1],s))return!0;return!1}function $l(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=jt(t,e,i[0]);return s!==jt(t,e,i[1])||s!==jt(t,e,i[2])||s!==jt(t,e,i[3])}function jl(t,e,i){let r=e.paint.get(t).value;return"constant"===r.kind?r.value:i.programConfigurations.get(e.id).getMaxValue(t)}function Rl(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function Ol(t,e,i,r,n){if(!e[0]&&!e[1])return t;let s=l.convert(e)._mult(n);"viewport"===i&&s._rotate(-r);let o=[];for(let e of t)o.push(e.sub(s));return o}function Bl(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 Ll({queryGeometry:t,size:e},i){return El(t,i,e)}function Ul({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return El(t,s,e*(i.projectTileCoordinates(s.x,s.y,r,n?.(s.x,s.y)).signedDistanceFromCamera/i.cameraToCenterDistance))}function Nl({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 El(t,Vl(s,i,r,n),a)}function Gl({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n},s){return El(t,Vl(s,i,r,n),e)}function ql({queryGeometry:t,size:e,transform:i,unwrappedTileID:r,getElevation:n,pitchAlignment:s="map",pitchScale:o="map"},a){let l="map"===s?"map"===o?Ll:Ul:"map"===o?Nl:Gl,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 Vl(t,e,i,r){let n=e.projectTileCoordinates(t.x,t.y,i,r?.(t.x,t.y)).point;return new l((.5*n.x+.5)*e.width,(.5*-n.y+.5)*e.height)}let Zl,Wl;Ks("CircleBucket",Dl,{omit:["layers"]});var Hl={get paint(){return Wl||=new xo({"circle-radius":new yo(ye.paint_circle["circle-radius"],"circle-radius"),"circle-color":new yo(ye.paint_circle["circle-color"],"circle-color"),"circle-blur":new yo(ye.paint_circle["circle-blur"],"circle-blur"),"circle-opacity":new yo(ye.paint_circle["circle-opacity"],"circle-opacity"),"circle-translate":new go(ye.paint_circle["circle-translate"],"circle-translate"),"circle-translate-anchor":new go(ye.paint_circle["circle-translate-anchor"],"circle-translate-anchor"),"circle-pitch-scale":new go(ye.paint_circle["circle-pitch-scale"],"circle-pitch-scale"),"circle-pitch-alignment":new go(ye.paint_circle["circle-pitch-alignment"],"circle-pitch-alignment"),"circle-stroke-width":new yo(ye.paint_circle["circle-stroke-width"],"circle-stroke-width"),"circle-stroke-color":new yo(ye.paint_circle["circle-stroke-color"],"circle-stroke-color"),"circle-stroke-opacity":new yo(ye.paint_circle["circle-stroke-opacity"],"circle-stroke-opacity")})},get layout(){return Zl||=new xo({"circle-sort-key":new yo(ye.layout_circle["circle-sort-key"],"circle-sort-key")})}},Yl=class extends Eo{constructor(t,e){super(t,Hl,e)}createBucket(t){return new Dl(t)}queryRadius(t){let e=t;return jl("circle-radius",this,e)+jl("circle-stroke-width",this,e)+Rl(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=Ol(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=>Vl(t,e,i,r)))}(u,n,o,a),h=c),ql({queryGeometry:l,size:h,transform:n,unwrappedTileID:o,getElevation:a,pitchAlignment:p,pitchScale:f},r)}},Xl=class extends Dl{};let Jl;Ks("HeatmapBucket",Xl,{omit:["layers"]});var Kl={get paint(){return Jl||=new xo({"heatmap-radius":new yo(ye.paint_heatmap["heatmap-radius"],"heatmap-radius"),"heatmap-weight":new yo(ye.paint_heatmap["heatmap-weight"],"heatmap-weight"),"heatmap-intensity":new go(ye.paint_heatmap["heatmap-intensity"],"heatmap-intensity"),"heatmap-color":new bo(ye.paint_heatmap["heatmap-color"],"heatmap-color"),"heatmap-opacity":new go(ye.paint_heatmap["heatmap-opacity"],"heatmap-opacity")})}};function Ql(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 th(t,{width:e,height:i},r){if(e===t.width&&i===t.height)return;let n=Ql({},{width:e,height:i},r);eh(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 eh(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 ih=class t{constructor(t,e){Ql(this,t,1,e)}resize(t){th(this,t,1)}clone(){return new t({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,i,r,n){eh(t,e,i,r,n,1)}},rh=class t{constructor(t,e){Ql(this,t,4,e)}resize(t){th(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){eh(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 nh(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 sh(t){let e={},i=t.resolution||256,r=t.clips?t.clips.length:1,n=t.image||new rh({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}Ks("AlphaImage",ih),Ks("RGBAImage",rh);const oh="big-fb";var ah=class extends Eo{createBucket(t){return new Xl(t)}constructor(t,e){super(t,Kl,e),this.heatmapFbos=new Map,this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(t){"heatmap-color"===t&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=sh({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(oh)}queryRadius(t){return jl("heatmap-radius",this,t)}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s,unwrappedTileID:o,getElevation:a}){return ql({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 lh;var hh={get paint(){return lh||=new xo({"hillshade-illumination-direction":new go(ye.paint_hillshade["hillshade-illumination-direction"],"hillshade-illumination-direction"),"hillshade-illumination-altitude":new go(ye.paint_hillshade["hillshade-illumination-altitude"],"hillshade-illumination-altitude"),"hillshade-illumination-anchor":new go(ye.paint_hillshade["hillshade-illumination-anchor"],"hillshade-illumination-anchor"),"hillshade-exaggeration":new go(ye.paint_hillshade["hillshade-exaggeration"],"hillshade-exaggeration"),"hillshade-shadow-color":new go(ye.paint_hillshade["hillshade-shadow-color"],"hillshade-shadow-color"),"hillshade-highlight-color":new go(ye.paint_hillshade["hillshade-highlight-color"],"hillshade-highlight-color"),"hillshade-accent-color":new go(ye.paint_hillshade["hillshade-accent-color"],"hillshade-accent-color"),"hillshade-method":new go(ye.paint_hillshade["hillshade-method"],"hillshade-method"),resampling:new go(ye.paint_hillshade.resampling,"resampling")})}},uh=class extends Eo{constructor(t,e){super(t,hh,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(Nt);return{directionRadians:t.map(Nt),altitudeRadians:s,shadowColor:r,highlightColor:i}}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&!this.isHidden()}};let ch;var fh={get paint(){return ch||=new xo({"color-relief-opacity":new go(ye["paint_color-relief"]["color-relief-opacity"],"color-relief-opacity"),"color-relief-color":new bo(ye["paint_color-relief"]["color-relief-color"],"color-relief-color"),resampling:new go(ye["paint_color-relief"].resampling,"resampling")})}};function ph(t){return"data"in t}var dh=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),ph(t)){o.pixelStoreUnpackPremultiplyAlpha.set(!1);let{data:e}=t;l&&e&&(e=nh(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 ph(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};ph(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&&!(ph(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=nh(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=nh(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}},mh=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 $t(`"${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 _h(t,this.getUnpackVector())}getPixels(){return new rh({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 _h(t,e){let i=e[0],r=e[1],n=e[2],s=e[3],o=Math.min(i,r,n),a=Math.round((t+s)/o);return{r:Math.floor(a*o/i)%256,g:Math.floor(a*o/r)%256,b:Math.floor(a*o/n)%256}}Ks("DEMData",mh);var gh=class extends Eo{constructor(t,e){super(t,fh,e)}_createColorRamp(t){let e={elevationStops:[],colorStops:[]},i=this._transitionablePaint._values["color-relief-color"].value.expression;if(i instanceof jn&&i._styleExpression.expression instanceof ki){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=[fi.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 $t(`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 rh({width:r.colorStops.length,height:1}),s=new rh({width:r.colorStops.length,height:1});for(let t=0;t<r.elevationStops.length;t++){let e=_h(r.elevationStops[t],i);s.setPixel(0,t,new fi(e.r/255,e.g/255,e.b/255,1)),n.setPixel(0,t,r.colorStops[t])}return this.colorRampTextures={elevationTexture:new dh(t,s,t.gl.RGBA),colorTexture:new dh(t,n,t.gl.RGBA)},this.colorRampTextures}hasOffscreenPass(){return!this.isHidden()&&!!this.colorRampTextures}};const yh=Io([{name:"a_pos",components:2,type:"Int16"}],4).members;function vh(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 wh(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 bh=new Set;let xh=!1;function Dh(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=ru(n/r|0,t[n],t[n+1],s);else for(let n=i-r;n>=e;n-=r)s=ru(n/r|0,t[n],t[n+1],s);return s&&Kh(s,s.next)&&(nu(s),s=s.next),s}function Mh(t,e=t){let i,r=e===t,n=t;do{i=!1,n===n.next||0!==bh.size&&bh.has(n)||!Kh(n,n.next)&&0!==Jh(n.prev,n,n.next)?(r||n!==e)&&(n=n.next,i=!r):((r||n===e)&&(e=n.prev),xh=!0,nu(n),n=n.prev,i=!0)}while(i||n!==e);return e}function Eh(t,e,i,r,n){n&&function(t,e,i,r){let n=t,s=0;do{n.z=Wh(n.x,n.y,e,i,r),Uh[s++]=n,n=n.next}while(n!==t);!function(t){if(t<=32)for(let e=1;e<t;e++){let t=Uh[e],i=t.z,r=e-1;for(;r>=0&&Uh[r].z>i;)Uh[r+1]=Uh[r],r--;Uh[r+1]=t}else{Gh.length<t&&(Gh=new Uint32Array(t),qh=new Uint32Array(t),Nh=Array(t));for(let e=0;e<t;e++)Gh[e]=Uh[e].z;Zh(t,Uh,Gh,Nh,qh,0),Zh(t,Nh,qh,Uh,Gh,8),Zh(t,Uh,Gh,Nh,qh,16),Zh(t,Nh,qh,Uh,Gh,24)}}(s);let o=null;for(let t=0;t<s;t++){let e=Uh[t];e.prevZ=o,o&&(o.nextZ=e),o=e}o.nextZ=null}(t,i,r,n);let s=t,o=!1;for(;t.prev!==t.next;){let a=t.prev,l=t.next;if(Jh(a,t,l)<0&&(n?Fh(t,i,r,n):Ah(t)))e.push(a.i,t.i,l.i),nu(t),t=l,s=l;else if((t=l)===s){if(xh=!1,t=Mh(t),xh){s=t;continue}if(!o){s=t=Sh(t,e),o=!0;continue}Ch(t,e,i,r,n);break}}}function Ah(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)&&Yh(r,o,n,a,s,l,p.x,p.y)&&Jh(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Fh(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),_=Wh(f,p,e,i,r),g=Wh(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)&&Yh(o,h,a,u,l,c,y.x,y.y)&&Jh(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)&&Yh(o,h,a,u,l,c,v.x,v.y)&&Jh(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Sh(t,e){let i=t,r=!1;do{let n=i.prev,s=i.next.next;Qh(n,i,i.next,s,!1)&&eu(n,s)&&eu(s,n)&&(e.push(n.i,i.i,s.i),nu(i),nu(i.next),i=t=s,r=!0),i=i.next}while(i!==t);return r?Mh(i):i}function Ch(t,e,i,r,n){let s=t;do{let t=s.next.next;for(;t!==s.prev;){if(s.i!==t.i&&Xh(s,t)){let o=iu(s,t);return s=Mh(s,s.next),o=Mh(o,o.next),Eh(s,e,i,r,n),void Eh(o,e,i,r,n)}t=t.next}s=s.next}while(s!==t)}let zh=!1;function Th(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 Ph(t,e){let i=function(t,e){let i,r=e,n=t.x,s=t.y,o=-1/0;if(Kh(t,r))return r;for(let e=0,a=0;e<kh;e++,a+=4){if(s<Ih[a+1]||s>Ih[a+3]||Ih[a]>n||Ih[a+2]<=o)continue;let l=Oh(e);r=Bh(e);do{if(r.prev.next===r){if(Kh(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<kh;e++,f+=4){if(Ih[f+2]<a||Ih[f]>n||Ih[f+3]<h||Ih[f+1]>u)continue;let p=Oh(e);r=Bh(e);do{if(r.prev.next===r&&n>=r.x&&r.x>=a&&n!==r.x&&Yh(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);(eu(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&&Lh(i,r)))&&(i=r,c=e)}r=r.next}while(r!==p)}return i}(t,e);if(!i)return e;let r=iu(i,t);return Rh(i,r.next.next),Mh(r,r.next),Mh(i,i.next)}let Ih=new Float64Array,kh=0;const $h=[],jh=[];function Rh(t,e){let i=t;do{let t=kh++;$h[t]=i;let r=1/0,n=1/0,s=-1/0,o=-1/0,a=0;do{let e=i.next;i.z=t,i.x<r&&(r=i.x),i.x>s&&(s=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y),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);jh[t]=i;let l=4*t;Ih[l]=r,Ih[l+1]=n,Ih[l+2]=s,Ih[l+3]=o}while(i!==e)}function Oh(t){let e=jh[t];for(;e.prev.next!==e;)e=e.next;return jh[t]=e,e}function Bh(t){let e=$h[t];for(;e.prev.next!==e;)e=e.next;return $h[t]=e,e}function Lh(t,e){return Jh(t.prev,t,e.prev)<0&&Jh(e.next,t,t.next)<0}const Uh=[];let Nh=[],Gh=new Uint32Array,qh=new Uint32Array;const Vh=new Uint32Array(256);function Zh(t,e,i,r,n,s){Vh.fill(0);for(let e=0;e<t;e++)Vh[i[e]>>>s&255]++;let o=0;for(let t=0;t<256;t++){let e=Vh[t];Vh[t]=o,o+=e}for(let o=0;o<t;o++){let t=i[o],a=Vh[t>>>s&255]++;r[a]=e[o],n[a]=t}}function Wh(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 Hh(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 Yh(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 Xh(t,e){let i=Kh(t,e)&&Jh(t.prev,t,t.next)>0&&Jh(e.prev,e,e.next)>0;return t.next.i!==e.i&&(i||eu(t,e)&&eu(e,t)&&(0!==Jh(t.prev,t,e.prev)||0!==Jh(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&&Qh(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 Jh(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function Kh(t,e){return t.x===e.x&&t.y===e.y}function Qh(t,e,i,r,n=!0){let s=Jh(t,e,i),o=Jh(t,e,r),a=Jh(i,r,t),l=Jh(i,r,e);return(s>0&&o<0||s<0&&o>0)&&(a>0&&l<0||a<0&&l>0)||!!n&&!!(0===s&&tu(t,i,e)||0===o&&tu(t,r,e)||0===a&&tu(i,t,r)||0===l&&tu(i,e,r))}function tu(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 eu(t,e){return Jh(t.prev,t,t.next)<0?Jh(t,e,t.next)>=0&&Jh(t,t.prev,e)>=0:Jh(t,e,t.prev)<0||Jh(t,t.next,e)<0}function iu(t,e){let i=su(t.i,t.x,t.y),r=su(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 ru(t,e,i,r){let n=su(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 nu(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),zh&&function(t,e){let i=4*t.z;e.x<Ih[i]&&(Ih[i]=e.x),e.y<Ih[i+1]&&(Ih[i+1]=e.y),e.x>Ih[i+2]&&(Ih[i+2]=e.x),e.y>Ih[i+3]&&(Ih[i+3]=e.y)}(t.prev,t.next)}function su(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null}}var ou=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)}},au=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 ou(0,0),line:new ou(0,0),tile:new ou(0,0),stencil:new ou(0,0),circle:1})}};Ks("SubdivisionGranularityExpression",ou),Ks("SubdivisionGranularitySetting",au);const lu=-32768,hu=32767;var uu=class{constructor(t,e){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=tt/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);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);let s=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,s),this._vertexBuffer.push(i,r),s}_subdivideTrianglesScanline(t){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,t);let e=[],i=t.length;for(let r=0;r<i;r+=3){let i=[t[r+0],t[r+1],t[r+2]],n=[this._vertexBuffer[2*t[r+0]+0],this._vertexBuffer[2*t[r+0]+1],this._vertexBuffer[2*t[r+1]+0],this._vertexBuffer[2*t[r+1]+1],this._vertexBuffer[2*t[r+2]+0],this._vertexBuffer[2*t[r+2]+1]],s=1/0,o=1/0,a=-1/0,l=-1/0;for(let t=0;t<3;t++){let e=n[2*t],i=n[2*t+1];s=Math.min(s,e),a=Math.max(a,e),o=Math.min(o,i),l=Math.max(l,i)}if(s===a||o===l)continue;let h=Math.floor(s/this._granularityCellSize),u=Math.ceil(a/this._granularityCellSize),c=Math.floor(o/this._granularityCellSize),f=Math.ceil(l/this._granularityCellSize);if(h!==u||c!==f)for(let t=c;t<f;t++){let r=this._scanlineGenerateVertexRingForCellRow(t,n,i);pu(this._vertexBuffer,r,e)}else e.push(...i)}return e}_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){let e=[];for(let i of t){let t=fu(i,this._granularity,!0),r=this._pointArrayToIndices(t),n=[];for(let t=1;t<r.length;t++)n.push(r[t-1]),n.push(r[t]);e.push(n)}return e}_handlePoles(t){let e=!1,i=!1;this._canonical&&(0===this._canonical.y&&(e=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(e||i)&&this._fillPoles(t,e,i)}_ensureNoPoleVertices(){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=tt,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,lu),0===f&&0===d&&this._generatePoleQuad(t,a,l,c,p,lu),0===d&&0===u&&this._generatePoleQuad(t,l,s,p,h,lu)),i&&(u===n&&f===n&&this._generatePoleQuad(t,s,a,h,c,hu),f===n&&d===n&&this._generatePoleQuad(t,a,l,c,p,hu),d===n&&u===n&&this._generatePoleQuad(t,l,s,p,h,hu))}}_initializeVertices(t){for(let e=0;e<t.length;e+=2)this._vertexToIndex(t[e],t[e+1])}subdividePolygonInternal(t,e){if(this._used)throw 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);this._initializeVertices(r);try{let t=function(t,e,i=2){let r=e&&e.length,n=r?e[0]*i:t.length;bh.size&&bh.clear();let s=Dh(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=Dh(t,e[i]*r,i<s-1?e[i+1]*r:t.length,r,!1);o===o.next&&bh.add(o),n.push(Hh(o))}n.sort(Th),function(t,e){let i=Math.ceil((t+2*e)/16)+e+2;Ih.length<4*i&&(Ih=new Float64Array(4*i)),kh=0}(t.length/r,e.length),Rh(i,i),zh=!0;for(let t=0;t<n.length;t++)i=Ph(n[t],i);return zh=!1,Mh(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 Eh(s,o,a,l,h),o}(r,n),e=this._convertIndices(r,t);i=this._subdivideTrianglesScanline(e)}catch(t){console.error(t)}let s=[];return e&&(s=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(i),this._granularity>=2&&0===this._canonical?.z&&(i=this._removeTrianglesOutsideTileX(i),s=s.map((t=>this._removeLinesOutsideTileX(t)))),{verticesFlattened:this._vertexBuffer,indicesTriangles:i,indicesLineList:s}}_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}_convertIndices(t,e){let i=[];for(let r of e)i.push(this._vertexToIndex(t[2*r],t[2*r+1]));return i}_pointArrayToIndices(t){let e=[];for(let i of t)e.push(this._vertexToIndex(i.x,i.y));return e}};function cu(t,e,i,r=!0){return new uu(i,e).subdividePolygonInternal(t,r)}function fu(t,e,i=!1){if(!t||t.length<1||t.length<2)return[];let r=t[0],n=t[t.length-1],s=i&&(r.x!==n.x||r.y!==n.y);if(e<2)return s?[...t,t[0]]:[...t];let o=Math.floor(tt/e),a=[];a.push(new l(t[0].x,t[0].y));let h=t.length,u=s?h:h-1;for(let e=0;e<u;e++){let i=t[e],r=e<h-1?t[e+1]:t[0],n=i.x,s=i.y,u=r.x,c=r.y,f=n!==u,p=s!==c;if(!f&&!p)continue;let d=u-n,m=c-s,_=Math.abs(d),g=Math.abs(m),y=n,v=s;for(;;){let t=d>0?(Math.floor(y/o)+1)*o:(Math.ceil(y/o)-1)*o,e=m>0?(Math.floor(v/o)+1)*o:(Math.ceil(v/o)-1)*o,i=Math.abs(y-t),r=Math.abs(v-e),n=Math.abs(y-u),s=Math.abs(v-c),h=f?i/_:1/0,w=p?r/g:1/0;if((n<=i||!f)&&(s<=r||!p))break;if(h<w&&f||!p){y=t,v+=m*h;let e=new l(y,Math.round(v));(a[a.length-1].x!==e.x||a[a.length-1].y!==e.y)&&a.push(e)}else{y+=d*w,v=e;let t=new l(Math.round(y),v);(a[a.length-1].x!==t.x||a[a.length-1].y!==t.y)&&a.push(t)}}let w=new l(u,c);(a[a.length-1].x!==w.x||a[a.length-1].y!==w.y)&&a.push(w)}return a}function pu(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 du(t,e,i,r,n,s,o,a,l){let h=n.length/2,u=o&&a&&l;if(h<Oa.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)>Oa.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,m=!0,_=!0,g=!0,u=0);let y=mu(o,r,s,a,f,m,h),v=mu(o,r,s,a,p,_,h),w=mu(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)>Oa.MAX_VERTEX_ARRAY_LENGTH&&(h=t.createNewSegment(e,i),l=a.count,d=!0,m=!0,u=0);let _=mu(o,r,s,a,f,d,h),g=mu(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 mu(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 _u=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 ba,this.indexArray=new ka,this.indexArray2=new $a,this.programConfigurations=new ml(t.layers,t.zoom),this.segments=new Oa,this.segments2=new Oa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=vh("fill",this.layers,e);let r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),s=[],o=new so(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:l,id:h,index:u,sourceLayerIndex:c}of t){let t=wl(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:vl(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=wh("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&&$t(`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,yh),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 Ui(e,500)){let e=cu(t,r,s.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;du(((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 gu,yu;Ks("FillBucket",_u,{omit:["layers","patternFeatures"]});var vu={get paint(){return yu||=new xo({"fill-antialias":new go(ye.paint_fill["fill-antialias"],"fill-antialias"),"fill-opacity":new yo(ye.paint_fill["fill-opacity"],"fill-opacity"),"fill-layer-opacity":new go(ye.paint_fill["fill-layer-opacity"],"fill-layer-opacity"),"fill-color":new yo(ye.paint_fill["fill-color"],"fill-color"),"fill-outline-color":new yo(ye.paint_fill["fill-outline-color"],"fill-outline-color"),"fill-translate":new go(ye.paint_fill["fill-translate"],"fill-translate"),"fill-translate-anchor":new go(ye.paint_fill["fill-translate-anchor"],"fill-translate-anchor"),"fill-pattern":new vo(ye.paint_fill["fill-pattern"],"fill-pattern")})},get layout(){return gu||=new xo({"fill-sort-key":new yo(ye.layout_fill["fill-sort-key"],"fill-sort-key")})}},wu=class extends Eo{constructor(t,e){super(t,vu,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 _u(t)}queryRadius(){return Rl(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:t,geometry:e,transform:i,pixelsToTileUnits:r}){return Al(Ol(t,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),e)}isTileClipped(){return!0}};const bu=Io([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),xu=Io([{name:"a_centroid",components:2,type:"Int16"}],4),Du=bu.members;var Mu=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 l(this.minX,this.minY))),i.extend(e(new l(this.maxX,this.minY))),i.extend(e(new l(this.minX,this.maxY))),i.extend(e(new l(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 Eu=Mu.fromPoints([new l(0,0),new l(tt,tt)]);function Au(t,e){return t.x===e.x&&(t.x<0||t.x>8192)||t.y===e.y&&(t.y<0||t.y>8192)}function Fu(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 Su=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 l(o,a)];else if(2===n)o+=t.readSVarint(),a+=t.readSVarint(),e&&e.push(new l(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=Cu(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 Cu(t){let e=t.length;if(e<=1)return[t];let i,r,n=[];for(let s=0;s<e;s++){let e=zu(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 zu(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}Su.types=["Unknown","Point","LineString","Polygon"];var Tu=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(Pu(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 Su(this._pbf,e,this.extent,this._keys,this._values)}};function Pu(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 Iu=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 Tu(t,t.readVarint()+t.pos);e.length&&(i[e.name]=e)}else t.skip(e)}this.layers=i}};const ku=6371008.8;var $u=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(xt(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 ku*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 ju=2*Math.PI*ku;function Ru(t){return ju*Math.cos(t*Math.PI/180)}function Ou(t){return(180+t)/360}function Bu(t){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t*Math.PI/360)))/360}function Lu(t,e){return t/Ru(e)}function Uu(t){return 360*t-180}function Nu(t){return 360/Math.PI*Math.atan(Math.exp((180-360*t)*Math.PI/180))-90}function Gu(t,e){return t*Ru(Nu(e))}var qu=class t{constructor(t,e,i=0){this.x=+t,this.y=+e,this.z=+i}static fromLngLat(e,i=0){let r=$u.convert(e);return new t(Ou(r.lng),Bu(r.lat),Lu(i,r.lat))}toLngLat(){return new $u(Uu(this.x),Nu(this.y))}toAltitude(){return Gu(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/ju*function(t){return 1/Math.cos(t*Math.PI/180)}(Nu(this.y))}};const Vu=89.25;function Zu(t,e,i){let r=1/(1<<i.z);return new qu(t/tt*r+i.x*r,e/tt*r+i.y*r)}function Wu(t,e){let i=bt(e.lat,-85.051129,Wt);return new l(Ou(e.lng)*t,Bu(i)*t)}function Hu(t,e){return new qu(e.x/t,e.y/t).toLngLat()}function Yu(t){return t.cameraToCenterDistance*Math.min(.85*Math.tan(Nt(90-t.pitch)),Math.tan(Nt(Vu-t.pitch)))}function Xu(t,e){let i=t.canonical,r=e/Ft(i.z),n=i.x+2**i.z*t.wrap,s=new Float64Array(16);return g(s),w(s,s,[n*r,i.y*r,0]),b(s,s,[r/tt,r/tt,1]),s}function Ju(t,e,i,r,n){let s=qu.fromLngLat(t,e),o=n*Lu(1,t.lat),{x:a,y:l,z:h}=Ku(i,r);return new qu(s.x+o*-a,s.y+o*-l,s.z+o*h)}function Ku(t,e){let i=Nt(t),r=Nt(e),n=Math.cos(-i),s=Math.sin(i);return{x:s*Math.sin(r),y:-s*Math.cos(r),z:n}}function Qu(t,e,i){if(e<=0||!t||0===t.length)return t;let r=function(t,e){let i=function(t,e,i){return Zu(4096,4096,i).toLngLat()}(0,0,e);return t*qu.fromLngLat(i).meterInMercatorCoordinateUnits()*((1<<e.z)*tt)}(e,i);return 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=[];for(let i=0;i<r;i++){let s=t[(i-1+r)%r],o=t[i],a=t[(i+1)%r];Au(s,o)||Au(o,a)?n.push(o.clone()):tc(n,s,o,a,e)}let s=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 s.length<3?t:(i&&s.push(s[0].clone()),s)}(t,r)))}function tc(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 ec=8192;function ic(t,e,i,r,n,s,o,a){t.emplaceBack(e,i,2*Math.floor(r*ec)+o,n*ec*2,s*ec*2,Math.round(a))}var rc=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 xa,this.centroidVertexArray=new ga,this.indexArray=new ka,this.programConfigurations=new ml(t.layers,t.zoom),this.segments=new Oa,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.features=[],this.hasDependencies=vh("fill-extrusion",this.layers,e);let r=new so(this.zoom),n=this.layers[0],s=n.layout.get("fill-extrusion-rounded-corner-distance"),o=n._featureFilter.needGeometry;for(let{feature:a,id:l,index:h,sourceLayerIndex:u}of t){let t=wl(a,o);if(!n._featureFilter.filter(r,t,i))continue;let c=o?t.geometry:vl(a),f={id:l,sourceLayerIndex:u,index:h,geometry:s>0?Qu(c,s,i):c,properties:a.properties,type:a.type,patterns:{}};this.hasDependencies?this.features.push(wh("fill-extrusion",this.layers,f,{zoom:this.zoom},e)):this.addFeature(f,f.geometry,h,i,{},e.subdivisionGranularity),e.featureIndex.insert(a,f.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,Du),this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,xu.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){let o=this.layers[0],a=o.layout?o.layout.get("fill-extrusion-rounded-corner-distance"):0,l=a>0?Qu(e,a,r):e;for(let e of Ui(l,500)){let i={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(i,r,t,e,s);let o=this.layoutVertexArray.length-n,a=Math.floor(i.x/i.sampleCount),l=Math.floor(i.y/i.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||Fu(r[0]))return;for(let e of r)0!==e.length&&nc(t,e);let s={segment:this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray)},o=n.fill.getGranularityForZoomLevel(e.z),a="Polygon"===Su.types[i.type];for(let t of r){if(0===t.length||Fu(t))continue;let e=fu(t,o,a);this._generateSideFaces(e,s)}if(!a)return;let l=cu(r,e,o,!1),h=this.layoutVertexArray;du(((t,e)=>{ic(h,t,e,0,0,1,1,0)}),this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(t,e){let i=0;for(let r=1;r<t.length;r++){let n=t[r],s=t[r-1];if(Au(n,s))continue;e.segment.vertexLength+4>Oa.MAX_VERTEX_ARRAY_LENGTH&&(e.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));let o=n.sub(s)._perp()._unit(),a=s.dist(n);i+a>32768&&(i=0),ic(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,0,i),ic(this.layoutVertexArray,n.x,n.y,o.x,o.y,0,1,i),i+=a,ic(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,0,i),ic(this.layoutVertexArray,s.x,s.y,o.x,o.y,0,1,i);let l=e.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),e.segment.vertexLength+=4,e.segment.primitiveLength+=2}}};function nc(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 sc,oc;Ks("FillExtrusionBucket",rc,{omit:["layers","features"]});var ac={get paint(){return oc||=new xo({"fill-extrusion-opacity":new go(ye["paint_fill-extrusion"]["fill-extrusion-opacity"],"fill-extrusion-opacity"),"fill-extrusion-color":new yo(ye["paint_fill-extrusion"]["fill-extrusion-color"],"fill-extrusion-color"),"fill-extrusion-translate":new go(ye["paint_fill-extrusion"]["fill-extrusion-translate"],"fill-extrusion-translate"),"fill-extrusion-translate-anchor":new go(ye["paint_fill-extrusion"]["fill-extrusion-translate-anchor"],"fill-extrusion-translate-anchor"),"fill-extrusion-pattern":new vo(ye["paint_fill-extrusion"]["fill-extrusion-pattern"],"fill-extrusion-pattern"),"fill-extrusion-height":new yo(ye["paint_fill-extrusion"]["fill-extrusion-height"],"fill-extrusion-height"),"fill-extrusion-base":new yo(ye["paint_fill-extrusion"]["fill-extrusion-base"],"fill-extrusion-base"),"fill-extrusion-vertical-gradient":new go(ye["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"],"fill-extrusion-vertical-gradient")})},get layout(){return sc||=new xo({"fill-extrusion-rounded-corner-distance":new go(ye["layout_fill-extrusion"]["fill-extrusion-rounded-corner-distance"],"fill-extrusion-rounded-corner-distance")})}},lc=class extends Eo{constructor(t,e){super(t,ac,e)}createBucket(t){return new rc(t)}queryRadius(){return Rl(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=Ol(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=fc(a,o,0),c=cc(r,h,l,o);return function(t,e,i){let r=1/0;Al(i,e)&&(r=uc(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];Ml(i,n)&&(r=Math.min(r,uc(i,n)))}}return r!==1/0&&r}(c[0],c[1],u)}};function hc(t,e){return t.x*e.x+t.y*e.y}function uc(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=hc(a,a),c=hc(a,l),f=hc(l,l),p=hc(h,a),d=hc(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 cc(t,e,i,r){let n=[],s=[],o=r[8]*e,a=r[9]*e,h=r[10]*e,u=r[11]*e,c=r[8]*i,f=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+h,w=y+u,b=m+c,x=_+f,D=g+p,M=y+d,E=new l((m+o)/w,(_+a)/w);E.z=v/w,t.push(E);let A=new l(b/M,x/M);A.z=D/M,i.push(A)}n.push(t),s.push(i)}return[n,s]}function fc(t,e,i){let r=[];for(let n of t){let t=[n.x,n.y,i,1];q(t,t,e),r.push(new l(t[0]/t[3],t[1]/t[3]))}return r}const pc=Io([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"}],4).members,dc=Io([{name:"a_uv_x",components:1,type:"Float32"},{name:"a_split_index",components:1,type:"Float32"}]).members,mc=Math.cos(Math.PI/180*37.5);var _c=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 Da,this.layoutVertexArray2=new Ma,this.indexArray=new ka,this.programConfigurations=new ml(t.layers,t.zoom),this.segments=new Oa,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id))}populate(t,e,i){this.hasDependencies=vh("line",this.layers,e)||this.hasLineDasharray(this.layers);let r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),s=[],o=new so(this.zoom),a=this.layers[0]._featureFilter.needGeometry;for(let{feature:e,id:l,index:h,sourceLayerIndex:u}of t){let t=wl(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:vl(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?(vh("line",this.layers,e)?wh("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,dc)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,pc),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=fu(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"===Su.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*tt/(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<mc&&f&&p,x=d.x*m.y-d.y*m.x>0;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 D=f&&p,M=D?i:l?"butt":r;if(D&&"round"===M&&(v<s?M="miter":v<=2&&(M="fakeround")),"miter"===M&&v>n&&(M="bevel"),"bevel"===M&&(v>2&&(M="flipbevel"),v<n&&(M="miter")),f&&this.updateDistance(f,c),"miter"===M)o._mult(v),this.addCurrentVertex(c,o,0,0,g);else if("flipbevel"===M){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),this.addCurrentVertex(c,o.mult(-1),0,0,g)}else if("bevel"===M||"fakeround"===M){let t=-Math.sqrt(v*v-1),e=x?t:0,i=x?0:t;if(f&&this.addCurrentVertex(c,d,e,i,g),"fakeround"===M){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,!1,x,0,g)}}p&&this.addCurrentVertex(c,m,-e,-i,g)}else if("butt"===M)this.addCurrentVertex(c,o,0,0,g);else if("square"===M){let t=f?1:-1;this.addCurrentVertex(c,o,t,t,g)}else"round"===M&&(f&&(this.addCurrentVertex(c,d,0,0,g),this.addCurrentVertex(c,d,1,1,g,!0)),p&&(this.addCurrentVertex(c,m,-1,-1,g,!0),this.addCurrentVertex(c,m,0,0,g)));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){let o=e.y*r-e.x,a=-e.y-e.x*r;this.addHalfVertex(t,e.x+e.y*i,e.y-e.x*i,s,!1,i,n),this.addHalfVertex(t,o,a,s,!0,-r,n),this.distance>16384&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,i,r,n,s))}addHalfVertex({x:t,y:e},i,r,n,s,o,a){let l=.5*(this.lineClips?32767*this.scaledDistance:this.scaledDistance);this.layoutVertexArray.emplaceBack(+!!n+(t<<1),+!!s+(e<<1),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===o?0:o<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);let h=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,h,this.e2),a.primitiveLength++),s?this.e2=h:this.e1=h}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 gc,yc;Ks("LineBucket",_c,{omit:["layers","patternFeatures"]});var vc={get paint(){return yc||=new xo({"line-opacity":new yo(ye.paint_line["line-opacity"],"line-opacity"),"line-layer-opacity":new go(ye.paint_line["line-layer-opacity"],"line-layer-opacity"),"line-color":new yo(ye.paint_line["line-color"],"line-color"),"line-translate":new go(ye.paint_line["line-translate"],"line-translate"),"line-translate-anchor":new go(ye.paint_line["line-translate-anchor"],"line-translate-anchor"),"line-width":new yo(ye.paint_line["line-width"],"line-width"),"line-gap-width":new yo(ye.paint_line["line-gap-width"],"line-gap-width"),"line-offset":new yo(ye.paint_line["line-offset"],"line-offset"),"line-blur":new yo(ye.paint_line["line-blur"],"line-blur"),"line-dasharray":new vo(ye.paint_line["line-dasharray"],"line-dasharray"),"line-pattern":new vo(ye.paint_line["line-pattern"],"line-pattern"),"line-gradient":new bo(ye.paint_line["line-gradient"],"line-gradient")})},get layout(){return gc||=new xo({"line-cap":new yo(ye.layout_line["line-cap"],"line-cap"),"line-join":new yo(ye.layout_line["line-join"],"line-join"),"line-miter-limit":new yo(ye.layout_line["line-miter-limit"],"line-miter-limit"),"line-round-limit":new yo(ye.layout_line["line-round-limit"],"line-round-limit"),"line-sort-key":new yo(ye.layout_line["line-sort-key"],"line-sort-key")})}},wc=class extends yo{possiblyEvaluate(t,e){return e=new so(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=Dt({},e,{zoom:Math.floor(e.zoom)}),super.evaluate(t,e,i,r)}};let bc;var xc=class extends Eo{constructor(t,e){super(t,vc,e),this.gradientVersion=0,bc||(bc=new wc(vc.paint.properties["line-width"].specification,"line-floorwidth"),bc.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 Ii,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"]=bc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,t)}createBucket(t){return new _c(t)}queryRadius(t){let e=t,i=Dc(jl("line-width",this,e),jl("line-gap-width",this,e)),r=jl("line-offset",this,e);return i/2+Math.abs(r)+Rl(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:t,feature:e,featureState:i,geometry:r,transform:n,pixelsToTileUnits:s}){let o=Ol(t,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-n.bearingInRadians,s),a=s/2*Dc(this.paint.get("line-width").evaluate(e,i),this.paint.get("line-gap-width").evaluate(e,i)),h=this.paint.get("line-offset").evaluate(e,i);return h&&(r=function(t,e){let i=[];for(let r of t){let t=Bl(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 l(0,0):r.sub(s)._unit()._perp(),h=i===t.length-1?new l(0,0):o.sub(r)._unit()._perp(),u=a._add(h)._unit(),c=u.x*h.x+u.y*h.y;0!==c&&u._mult(1/c),n.push(u._mult(e)._add(r))}i.push(n)}return i}(r,h*s)),function(t,e,i){for(let r of e){if(t.length>=3)for(let e of r)if(Il(t,e))return!0;if(Fl(t,r,i))return!0}return!1}(o,r,a)}isTileClipped(){return!0}};function Dc(t,e){return e>0?e+2*t:t}const Mc=Io([{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),Ec=Io([{name:"a_projected_pos",components:3,type:"Float32"}],4);Io([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Ac=Io([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);Io([{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 Fc=Io([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),Sc=Io([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Io([{name:"triangle",components:3,type:"Uint16"}]),Io([{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"}]),Io([{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"}]),Io([{type:"Float32",name:"offsetX"}]),Io([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Io([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const Cc=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(Cc.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 zc(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 Tc(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 Pc(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 Ic(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 kc={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"},$c={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]},jc={لآ:[65269,65270],لأ:[65271,65272],لإ:[65273,65274],لا:[65275,65276]},Rc=/[\u0600-\u06ff\u0750-\u077f\u0870-\u089f\u08a0-\u08ff\ufb50-\ufdff\ufe70-\ufeff]/;function Oc(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 Bc=new Map;for(let[t,e]of Object.entries(kc))Oc(e,t,Bc);function Lc(t){return Bc.get(t)??"U"}function Uc(t){return"D"===t||"L"===t||"C"===t}function Nc(t){return"D"===t||"R"===t||"C"===t}function Gc(t,e,i){return"D"===t?e&&i?3:e?1:i?2:0:"R"===t?+!!e:"L"===t?i?2:0:null}function qc(t){if(!Rc.test(t))return t;let e=function(t){return[...t].map((t=>{let e=t.codePointAt(0);return{codePoint:e,type:Lc(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&&Uc(e[t-1].type),n=t+1<e.length&&Nc(e[t+1].type);i.form=Gc(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&&jc[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=$c[t.codePoint];return e&&(e[t.form]||e[0])||t.codePoint}(t)))).join("")}function Vc(t,e,i){let r=e.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?t=t.toLocaleUpperCase():"lowercase"===r&&(t=t.toLocaleLowerCase()),(Cc.applyArabicShaping??qc)(t)}function Zc(t,e,i){for(let r of t.sections)r.text=Vc(r.text,e,i);return t}const Wc=typeof Intl<"u"&&"Segmenter"in Intl;let Hc,Yc;function Xc(t){if(!Wc||!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];Hc??=new Intl.Segmenter(void 0,{granularity:"grapheme"});let e=[];for(let{segment:i}of Hc.segment(t)){let t=e.length-1;t>=0&&Ic(e[t],i)?e[t]+=i:e.push(i)}return e}function Jc(t){let e=new Set;if(Wc){Yc??=new Intl.Segmenter(void 0,{granularity:"word"});for(let{index:i}of Yc.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 Kc(t){let e=t.codePointAt(0);return t.length>(e>65535?2:1)}function Qc(t){return/\s/u.test(String.fromCodePoint(t))}function tf(t){for(let e of t)if(Tc(e.codePointAt(0)))return!0;return!1}function ef(t){for(let e of t)if(!rf(e.codePointAt(0)))return!1;return!0}function rf(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 nf(t){return!(Tc(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 sf(t){return/\p{sc=Arab}/u.test(String.fromCodePoint(t))}function of(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 af(t){for(let e of t)if(of(e.codePointAt(0)))return!0;return!1}const lf={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},hf={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},uf={40:!0};function cf(t,e,i,r,n,s){if("fontStack"in e){let r=i[e.fontStack],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 ff(t,e,i,r){let n=(t-e)**2;return r?t<e?n/2:2*n:n+Math.abs(i)*i}function pf(t){return/^\s+$/u.test(t)}function df(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 mf(t,e,i,r,n,s){let o=null,a=ff(e,i,n,s);for(let t of r){let r=ff(e-t.x,i,n,s)+t.badness;r<=a&&(o=t,a=r)}return{index:t,x:e,priorBreak:o,badness:a}}function _f(t){return t?_f(t.priorBreak).concat(t.index):[]}var gf=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??=Xc(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&&nf(o.value.codePointAt(0))&&!lf[o.value]||!i.premature&&nf(i.value.codePointAt(0))&&!lf[i.value]||!lf[n.value]?e+=n.value:e+=lf[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&&pf(t[e]);)e++;let i=t.length;for(;i>e&&pf(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=Xc(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 $t("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)):$t("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=[],o=this.determineAverageLineWidth(t,e,i,r,n),a=this.hasZeroWidthSpaces(),l=this.graphemes(),h=null,u=0,c=0;for(let e=0;e<l.length;e++){let f=l[e];if(e>0){let t=l[e-1].codePointAt(0),i=f.codePointAt(0),r=zc(t),n=Pc(t)&&Pc(i);(hf[t]||r||"imageName"in this.getSection(e-1)||void 0!==l[e+1]&&uf[i]||n&&(h??=Jc(this.text)).has(c))&&s.push(mf(e,u,o,s,df(t,i,r&&a),!1))}Qc(f.codePointAt(0))||(u+=cf(f,this.getSection(e),i,r,t,n)),c+=f.length}return _f(mf(this.length(),u,o,s,0,!0))}determineAverageLineWidth(t,e,i,r,n){let s=0,o=0;for(let e of this.graphemes())s+=cf(e,this.getSection(o),i,r,t,n),o++;return s/Math.max(1,Math.ceil(s/e))}};const yf=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}({}),vf=/[\u061c\u200e\u200f\u202a-\u202e\u2066-\u2069]/,wf=new Set(["WS","FSI","LRI","RLI","PDI"]),bf=new Set(["S","B"]);function xf(t){return t.level%2==0?t.text:yf.getMirroredCharacter(t.text)??t.text}function Df(t,e){let{levels:i,paragraphs:r}=yf.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 Xc(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=yf.getBidiCharTypeName(t[r].text[0]);bf.has(n)?(t[r].level=e,i=!0):i&&wf.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(vf.test(t.text))continue;let e=xf(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 Mf=4294967296,Ef=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");var Af=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)*Mf;return this.pos+=8,t}readSFixed64(){let t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Mf;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&&Ef?Ef.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 Ff(t,e,i){1===t&&i.readMessage(Sf,e)}function Sf(t,e,i){if(3===t){let{id:t,bitmap:r,width:n,height:s,left:o,top:a,advance:l}=i.readMessage(Cf,{});e.push({id:t,bitmap:new ih({width:n+6,height:s+6},r),metrics:{width:n,height:s,left:o,top:a,advance:l}})}}function Cf(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 zf(t){return"function"==typeof t?.renderWithWebGL}function Tf(t){let{userImage:e}=t;return!(!e?.render||!e.render()||(zf(e.data)||t.data.replace(new Uint8Array(e.data.buffer)),0))}function Pf(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 If=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]}};Ks("ImagePosition",If),Ks("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}=Pf(n),a=new rh({width:s||1,height:o||1});for(let e in t){let r=t[e];if(r.isWebGLImage)continue;let n=i[e].paddedRect;rh.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;rh.copy(i.data,a,{x:0,y:0},{x:s,y:o},i.data),rh.copy(i.data,a,{x:0,y:h-1},{x:s,y:o-1},{width:l,height:1}),rh.copy(i.data,a,{x:0,y:0},{x:s,y:o+h},{width:l,height:1}),rh.copy(i.data,a,{x:l-1,y:0},{x:s-1,y:o},{width:1,height:h}),rh.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 If(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(!zf(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 kf=function(t){return t[t.none=0]="none",t[t.horizontal=1]="horizontal",t[t.vertical=2]="vertical",t[t.horizontalOnly=3]="horizontalOnly",t}(kf||{});const $f=/^\p{gc=M}$/u;function jf(t,e,i){let r=new gf(t.join(""),e,[]),n=0;for(let t of r.graphemes())r.sectionIndex.push(i[n]??0),n+=[...t].length;return r}function Rf(t){let e=[],i=0;for(let r of t)e.push(i),i+=r.length;return e}function Of(t,e,i){let r=[...t],n=Rf(r),s=function(t){let e=[],i=0;for(;i<t.length;){if(!$f.test(t[i])){e.push(i),i++;continue}let r=i;for(;r<t.length&&$f.test(t[r]);)r++;let n=t[r];if(void 0!==n&&of(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 jf(s.map((t=>r[t])),e,s.map((t=>i[n[t]]??0)))}function Bf(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d){let m=gf.fromFeature(t,n);2===c&&m.verticalizePunctuation();let _=m.determineLineBreaks(h,s,e,r,p),g=af(m.text)?function(t,e){let i=e.map((e=>t.toCodeUnitIndex(e))),r=Cc.isParsed()?Cc:null;if(1===t.sections.length)return r?r.processBidirectionalText(t.toString(),i).map((e=>Of(e,t.sections,[...e].map((()=>0))))):function(t,e){return Df(t,e).map((t=>t.text))}(t.toString(),i).map((e=>jf([...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])=>Of(e,t.sections,i))):function(t,e,i){return Df(t,i).map((t=>[t.text,t.sourceIndices.map((t=>e[t]??0))]))}(t.text,n,i).map((([e,i])=>{let r=[...e];return jf(r,t.sections,Rf(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=Uf(r,o,g),b=2!==l||u?null:Hf(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]:Gf(l,u,m),y="fontStack"in a&&Kc(d)&&!e[a.fontStack]?.[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=Yf(a,l,_,w,e,i),!u)continue;d.fontStack=a.fontStack}else{if(t.iconsInText=!0,a.scale*=g,u=Xf(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),Jf(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}=Lf(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 Lf(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 Uf(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 Nf(t){switch(t){case"top":return 0;case"center":return.5;default:return 1}}function Gf(t,e,i){return!(1===t||!e&&!Tc(i)||e&&(Qc(i)||sf(i)))}function qf(t){return/\p{Nd}/u.test(String.fromCodePoint(t))}function Vf(t){return/\p{Lu}/u.test(String.fromCodePoint(t))}function Zf(t){let e=t.some(qf)&&t.every((t=>qf(t)||function(t){return/[\p{P}\p{S}]/u.test(String.fromCodePoint(t))}(t))),i=t.length<=3&&t.every((t=>Vf(t)||qf(t)));return e||i}function Wf(t){return(qf(t)||Vf(t))&&!sf(t)}function Hf(t){let e=t.graphemes().slice(),i=e.map((t=>t.codePointAt(0))),r=i.map(Tc),n=e=>!r[e]&&!Qc(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(Zf(i.slice(t,e+1)))for(let n=t;n<=e;n++)r[n]=Wf(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=lf[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 Yf(t,e,i,r,n,s){let o,a=s[t.fontStack]?.[e],l=function(t,e,i,r){if(t?.rect)return t;let n=e[i.fontStack]?.[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=Nf(t.verticalAlign);o=(r.horizontalLineContentHeight-24*t.scale)*e}return{rect:l.rect,metrics:l.metrics,baselineOffset:o}}function Xf(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=Nf(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 Jf(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 Kf(t,e,i){let{horizontalAlign:r,verticalAlign:n}=Lf(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 Qf(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 tp(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 ep(t,e){let{expression:i}=e;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new so(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 so(e===-1/0?t.zoomStops[1]-1:e))))}(i),r=i.evaluate(new so(t+1));return{kind:"camera",zoomStops:i.zoomStops,sizes:e,layoutSize:r,interpolationType:i.interpolationType}}}function ip(t,{uSize:e,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===t.kind?r/128:"composite"===t.kind?ji.number(r/128,n/128,i):e}function rp(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?bt(ki.interpolationFactor(r,n,t[s],t[o]),0,1):0;return Math.min(ji.number(e[s],e[o],a),i)}(t,e):"composite"===t.kind&&(i=function({interpolationType:t,minZoom:e,maxZoom:i},r){return t?bt(ki.interpolationFactor(t,r,e,i),0,1):0}(t,e)),{uSizeT:i,uSize:r}}var np=class t extends l{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 sp(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 op(t){let e=0;for(let i=0;i<t.length-1;i++)e+=t[i].dist(t[i+1]);return e}function ap(t,e,i){return t?.6*e*i:0}function lp(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}function hp(t,e,i,r,n,s){let o=ap(i,n,s),a=lp(i,r)*s,l=0,h=op(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 np(ji.number(r.x,n.x,u),ji.number(r.y,n.y,u),n.angleTo(r),i);return c._round(),!o||sp(t,c,a,o,e)?c:void 0}l+=s}}function up(t,e,i,r,n,s,o,a,l){let h=ap(r,s,o),u=lp(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),cp(t,f?e/2*a%e:(u/2+2*s)*o*a%e,e,h,i,c,f,!1,l)}function cp(t,e,i,r,n,s,o,a,l){let h=s/2,u=op(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=ji.number(o.x,a.x,_),y=ji.number(o.y,a.y,_);if(g>=0&&g<l&&y>=0&&y<l&&f-h>=0&&f+h<=u){let i=new np(g,y,m,e);i._round(),(!r||sp(t,i,s,r,n))&&p.push(i)}}c+=d}return!a&&!p.length&&!o&&(p=cp(t,c/2,i,r,n,s,o,!0,l)),p}function fp(t,e,i,r,n){let s=[];for(let o of t){let t;for(let a=0;a<o.length-1;a++){let h=o[a],u=o[a+1];h.x<e&&u.x<e||(h.x<e?h=new l(e,h.y+(e-h.x)/(u.x-h.x)*(u.y-h.y))._round():u.x<e&&(u=new l(e,h.y+(e-h.x)/(u.x-h.x)*(u.y-h.y))._round()),!(h.y<i&&u.y<i)&&(h.y<i?h=new l(h.x+(i-h.y)/(u.y-h.y)*(u.x-h.x),i)._round():u.y<i&&(u=new l(h.x+(i-h.y)/(u.y-h.y)*(u.x-h.x),i)._round()),!(h.x>=r&&u.x>=r)&&(h.x>=r?h=new l(r,h.y+(r-h.x)/(u.x-h.x)*(u.y-h.y))._round():u.x>=r&&(u=new l(r,h.y+(r-h.x)/(u.x-h.x)*(u.y-h.y))._round()),!(h.y>=n&&u.y>=n)&&(h.y>=n?h=new l(h.x+(n-h.y)/(u.y-h.y)*(u.x-h.x),n)._round():u.y>=n&&(u=new l(h.x+(n-h.y)/(u.y-h.y)*(u.x-h.x),n)._round()),(!t||!h.equals(t[t.length-1]))&&(t=[h],s.push(t)),t.push(u)))))}}return s}function pp(t,e,i,r){let n=[],s=t.image,o=s.pixelRatio,a=s.paddedRect.w-2,h=s.paddedRect.h-2,u={x1:t.left,y1:t.top,x2:t.right,y2:t.bottom},c=s.stretchX||[[0,a]],f=s.stretchY||[[0,h]],p=(t,e)=>t+e[1]-e[0],d=c.reduce(p,0),m=f.reduce(p,0),_=a-d,g=h-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)&&(u=Qf(t)),y=dp(c,0,e[0]),w=dp(f,0,e[1]),v=dp(c,e[0],e[2]),b=dp(f,e[1],e[3]),x=e[0]-y,M=e[1]-w,D=i-v,E=r-b}let A=u.x1,F=u.y1,S=u.x2-A,C=u.y2-F,z=(t,r,n,a)=>{let h=_p(t.stretch-y,v,S,A),u=gp(t.fixed-x,D,t.stretch,d),c=_p(r.stretch-w,b,C,F),f=gp(r.fixed-M,E,r.stretch,m),p=_p(n.stretch-y,v,S,A),_=gp(n.fixed-x,D,n.stretch,d),g=_p(a.stretch-w,b,C,F),z=gp(a.fixed-M,E,a.stretch,m),T=new l(h,c),P=new l(p,c),I=new l(p,g),k=new l(h,g),$=new l(u/o,f/o),j=new l(_/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=mp(c,_,d),e=mp(f,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:h+1}));return n}function dp(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 mp(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 _p(t,e,i,r){return t/e*i+r}function gp(t,e,i,r){return t-e*i/r}function yp(t,e,i,r,n,s,o,a){let h=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(let t of e.positionedLines)for(let r of t.positionedGlyphs){if(!r.rect)continue;let s=r.rect||{},c=4,f=!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];f=t.sdf,p=t.pixelRatio,c=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-c)*r.scale-_+y[0],x=(-r.metrics.top-c)*r.scale+y[1],D=b+s.w/w*r.scale/p,M=x+s.h/w*r.scale/p,E=new l(b,x),A=new l(D,x),F=new l(b,M),S=new l(D,M);if(m){let t=new l(-_,_- -17),e=-Math.PI/2,i=12-_,n=new l(22-i,-(r.imageName?i:0)),s=new l(...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(h){let t=Math.sin(h),e=Math.cos(h),i=[e,-t,t,e];E._matMult(i),A._matMult(i),F._matMult(i),S._matMult(i)}let C=new l(0,0),z=new l(0,0);u.push({tl:E,tr:A,bl:F,br:S,tex:s,writingMode:e.writingMode,glyphOffset:g,sectionIndex:r.sectionIndex,isSDF:f,pixelOffsetTL:C,pixelOffsetBR:z,minFontScaleX:0,minFontScaleY:0})}return u}Ks("Anchor",np);var vp=class{constructor(t,e,i,r,n,s,o,a,h,u){if(this.boxStartIndex=t.length,h){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 h=s.image?.content&&(s.image.textFitWidth||s.image.textFitHeight)?Qf(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};h.y1=h.y1*o-a[0],h.y2=h.y2*o+a[2],h.x1=h.x1*o-a[3],h.x2=h.x2*o+a[1];let c=s.collisionPadding;if(c&&(h.x1-=c[0]*o,h.y1-=c[1]*o,h.x2+=c[2]*o,h.y2+=c[3]*o),u){let t=new l(h.x1,h.y1),e=new l(h.x2,h.y1),i=new l(h.x1,h.y2),r=new l(h.x2,h.y2),n=u*Math.PI/180;t._rotate(n),e._rotate(n),i._rotate(n),r._rotate(n),h.x1=Math.min(t.x,e.x,i.x,r.x),h.x2=Math.max(t.x,e.x,i.x,r.x),h.y1=Math.min(t.y,e.y,i.y,r.y),h.y2=Math.max(t.y,e.y,i.y,r.y)}t.emplaceBack(e.x,e.y,h.x1,h.y1,h.x2,h.y2,i,r,n)}this.boxEndIndex=t.length}},wp=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 bp(t,e=1){let i=Mu.fromPoints(t[0]),r=Math.min(i.width(),i.height()),n=r/2,s=new wp([],xp),{minX:o,minY:a,maxX:h,maxY:u}=i;if(0===r)return new l(o,a);for(let e=o;e<h;e+=r)for(let i=a;i<u;i+=r)s.push(new Dp(e+n,i+n,n,t));let c=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 Dp(i/e,r/e,0,t)}(t),f=c;for(;s.length;){let i=s.pop();(i.d>f.d||!f.d)&&(f=i),!(i.max-f.d<=e)&&(n=i.h/2,s.push(new Dp(i.p.x-n,i.p.y-n,n,t)),s.push(new Dp(i.p.x+n,i.p.y-n,n,t)),s.push(new Dp(i.p.x-n,i.p.y+n,n,t)),s.push(new Dp(i.p.x+n,i.p.y+n,n,t)))}return c.d>0&&f.d-c.d<=e?c.p:f.p}function xp(t,e){return e.max-t.max}var Dp=class{constructor(t,e,i,r){this.p=new l(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,Tl(t,s,a))}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}};let Mp=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 Ep=1/0;function Ap(t,e){return e[1]===Ep?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 Fp(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 bi(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),Ep];let o=[];for(let t of s)o.push(t,Ap(t,n));return new bi(o)}return null}function Sp(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 Cp(t,e,i,r,n,s,o,a,l,h,u,c){let f=s.textMaxSize.evaluate(e,{});void 0===f&&(f=o);let p,d=t.layers[0].layout,m=d.get("icon-offset").evaluate(e,{},u),_=Tp(i.horizontal),g=o/24,y=t.tilePixelRatio*g,v=t.tilePixelRatio*f/24,w=t.tilePixelRatio*a,b=t.tilePixelRatio*d.get("symbol-spacing"),x=d.get("text-padding")*t.tilePixelRatio,D=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]}(d,e,u,t.tilePixelRatio),M=d.get("text-max-angle")/180*Math.PI,E="viewport"!==d.get("text-rotation-alignment")&&"point"!==d.get("symbol-placement"),A="map"===d.get("icon-rotation-alignment").constantOr("viewport")&&"point"!==d.get("symbol-placement"),F=d.get("symbol-placement"),S=b/2,C=d.get("icon-text-fit");r&&"none"!==C&&(t.allowVerticalPlacement&&i.vertical&&(p=tp(r,i.vertical,C,d.get("icon-text-fit-padding"),m,g)),_&&(r=tp(r,_,C,d.get("icon-text-fit-padding"),m,g)));let z=u?c.line.getGranularityForZoomLevel(u.z):1,T=(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){let E=t.addToLineVertexArray(e,i),A=a.layout.get("symbol-height-offset").evaluate(w,{},D);A>t.maxHeightOffset&&(t.maxHeightOffset=A);let F,S,C,z,T=0,P=0,I=0,k=0,$=-1,j=-1,R={},O=(0,qa.default)("");if(t.allowVerticalPlacement&&r.vertical){let t=a.layout.get("text-rotate").evaluate(w,{},D)+90;C=new vp(l,e,h,u,c,r.vertical,f,p,d,t),o&&(z=new vp(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=pp(n,i,x,r),f=o?pp(o,i,x,r):void 0;S=new vp(l,e,h,u,c,n,_,g,!1,i),T=4*s.length;let p=t.iconSizeData,d=null;"source"===p.kind?(d=[128*a.layout.get("icon-size").evaluate(w,{})],d[0]>32640&&$t(`${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)&&$t(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,d,v,y,w,0,e,E.lineStartIndex,E.lineLength,-1,D,A),$=t.icon.placedSymbolArray.length-1,f&&(P=4*f.length,t.addSymbols(t.icon,f,d,v,y,w,2,e,E.lineStartIndex,E.lineLength,-1,D,A),j=t.icon.placedSymbolArray.length-1)}let B=Object.keys(r.horizontal);for(let i of B){let n=r.horizontal[i];F||=(O=(0,qa.default)(n.text),new vp(l,e,h,u,c,n,f,p,d,a.layout.get("text-rotate").evaluate(w,{},D)));let o=1===n.positionedLines.length;if(I+=zp(t,e,n,s,a,d,w,m,A,E,r.vertical?1:3,o?B:[i],R,$,b,D),o)break}r.vertical&&(k+=zp(t,e,r.vertical,s,a,d,w,m,A,E,2,["vertical"],R,j,b,D));let L=F?F.boxStartIndex:t.collisionBoxArray.length,U=F?F.boxEndIndex:t.collisionBoxArray.length,N=C?C.boxStartIndex:t.collisionBoxArray.length,G=C?C.boxEndIndex:t.collisionBoxArray.length,q=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,Z=z?z.boxStartIndex:t.collisionBoxArray.length,W=z?z.boxEndIndex:t.collisionBoxArray.length,H=-1,Y=(t,e)=>t?.circleDiameter?Math.max(t.circleDiameter,e):e;H=Y(F,H),H=Y(C,H),H=Y(S,H),H=Y(z,H);let X=+(H>-1);X&&(H*=M/24),t.glyphOffsetArray.length>=t.maxGlyphs&&$t("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 J=Fp(a,w,D),[K,Q]=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(Mp[r[e]],i[0],i[1])}return[i,t.length]}(t.textAnchorOffsets,J);t.symbolInstances.emplaceBack(e.x,e.y,R.right>=0?R.right:-1,R.center>=0?R.center:-1,R.left>=0?R.left:-1,R.vertical||-1,$,j,O,L,U,N,G,q,V,Z,W,h,I,k,T,P,X,0,f,H,K,Q,A)}(t,c,a,i,r,n,p,t.layers[0],t.collisionBoxArray,e.index,e.sourceLayerIndex,t.index,y,[x,x,x,x],E,l,w,D,A,m,e,s,h,u,o)};if("line"===F)for(let n of fp(e.geometry,0,0,tt,tt)){let e=fu(n,z),s=up(e,b,M,i.vertical||_,r,24,v,t.overscaling,tt);for(let i of s)(!_||!Pp(t,_.text,S,i))&&T(e,i)}else if("line-center"===F){for(let t of e.geometry)if(t.length>1){let e=fu(t,z),n=hp(e,M,i.vertical||_,r,24,v);n&&T(e,n)}}else if("Polygon"===e.type)for(let t of Ui(e.geometry,0)){let e=bp(t,16);T(fu(t[0],z,!0),new np(e.x,e.y,0))}else if("LineString"===e.type)for(let t of e.geometry){let e=fu(t,z);T(e,new np(e[0].x,e[0].y,0))}else if("Point"===e.type)for(let t of e.geometry)for(let e of t)T([e],new np(e.x,e.y,0))}function zp(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m){let _=yp(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&&$t(`${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)&&$t(`${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 Tp(t){for(let e in t)return t[e];return null}function Pp(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 Ip(t,e,i){let r="never",n=t.get(e);return n?r=n:t.get(i)&&(r="always"),r}const kp=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function $p(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 jp(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 Rp(t){for(let e of t.sections)if(af(e.text))return!0;return!1}var Op=class{constructor(t){this.layoutVertexArray=new Fa,this.indexArray=new ka,this.programConfigurations=t,this.segments=new Oa,this.dynamicLayoutVertexArray=new Sa,this.opacityVertexArray=new Ca,this.hasVisibleVertices=!1,this.placedSymbolArray=new la}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,Mc.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,e),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,Ec.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,kp,!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())}};Ks("SymbolBuffers",Op);var Bp=class{constructor(t,e,i){this.layoutVertexArray=new t,this.layoutAttributes=e,this.indexArray=new i,this.segments=new Oa,this.collisionVertexArray=new Pa}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,Ac.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy())}};Ks("CollisionBuffers",Bp);var Lp=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=ep(this.zoom,e["text-size"]),this.iconSizeData=ep(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"!==Ip(i,"text-overlap","text-allow-overlap")||"never"!==Ip(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=>kf[t]))),this.stateDependentLayerIds=this.layers.filter((t=>t.isStateDependent())).map((t=>t.id)),this.sourceID=t.sourceID}createArrays(){this.text=new Op(new ml(this.layers,this.zoom,(t=>t.startsWith("text")))),this.icon=new Op(new ml(this.layers,this.zoom,(t=>t.startsWith("icon")))),this.glyphOffsetArray=new ca,this.lineVertexArray=new fa,this.symbolInstances=new ua,this.textAnchorOffsets=new da}calculateGlyphDependencies(t,e,i,r,n){let s=(r||this.allowVerticalPlacement)&&n,o=gf.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]||={},n=a[t];Kc(n)&&(r[n]=!0);for(let t of n){if(r[t]=!0,!s)continue;let e=lf[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 mi&&!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 so(this.zoom);for(let{feature:e,id:o,index:a,sourceLayerIndex:m}of t){let t,_,g=r._featureFilter.needGeometry,y=wl(e,g);if(!r._featureFilter.filter(d,y,i))continue;if(g||(y.geometry=vl(e)),l){let e=r.getValueAndResolveTokens("text-field",y,i,p),n=mi.factory(e);this.hasRTLText||=Rp(n),t=Zc(n,r,y)}if(h){let t=r.getValueAndResolveTokens("icon-image",y,i,p);_=t instanceof xi?t:xi.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:Su.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=tf(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=[],n=0;function s(e){r.push(t[e]),n++}function o(t,e,n){let s=i[t];return delete i[t],i[e]=s,r[s].geometry[0].pop(),r[s].geometry[0]=r[s].geometry[0].concat(n[0]),s}function a(t,i,n){let s=e[i];return delete e[i],e[t]=s,r[s].geometry[0].shift(),r[s].geometry[0]=n[0].concat(r[s].geometry[0]),s}function l(t,e,i){let r=i?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let h=0;h<t.length;h++){let u=t[h],c=u.geometry,f=u.text?u.text.toString():null;if(!f){s(h);continue}let p=l(f,c),d=l(f,c,!0);if(p in i&&d in e&&i[p]!==e[d]){let t=a(p,d,c),n=o(p,d,r[t].geometry);delete e[p],delete i[d],i[l(f,r[n].geometry,!0)]=n,r[t].geometry=null}else p in i?o(p,d,c):d in e?a(p,d,c):(s(h),e[p]=n-1,i[d]=n-1)}return r.filter((t=>t.geometry))}(this.features)),this.sortFeaturesByKey&&this.features.sort(((t,e)=>t.sortKey-e.sortKey))}update(t,e,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(t,e,this.layers,{imagePositions:i}))}addFeatures({options:t,canonical:e,glyphMap:i,glyphPositions:r,iconMap:n,iconPositions:s,showCollisionBoxes:o}){!function(t){t.bucket.createArrays(),t.bucket.tilePixelRatio=tt/(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 so(t.bucket.zoom+1),t.canonical),layoutTextSize:r["text-size"].possiblyEvaluate(new so(t.bucket.zoom+1),t.canonical),textMaxSize:r["text-size"].possiblyEvaluate(new so(18))};if("composite"===t.bucket.textSizeData.kind){let{minZoom:e,maxZoom:i}=t.bucket.textSizeData;n.compositeTextSizes=[r["text-size"].possiblyEvaluate(new so(e),t.canonical),r["text-size"].possiblyEvaluate(new so(i),t.canonical)]}if("composite"===t.bucket.iconSizeData.kind){let{minZoom:e,maxZoom:i}=t.bucket.iconSizeData;n.compositeIconSizes=[r["icon-size"].possiblyEvaluate(new so(e),t.canonical),r["icon-size"].possiblyEvaluate(new so(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=ef(n)?l:0,_=i.get("text-anchor").evaluate(r,{},t.canonical),g=Fp(e,r,t.canonical);if(!g){let e=i.get("text-radial-offset").evaluate(r,{},t.canonical);m=e?Ap(_,[24*e,Ep]):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&&tf(n)&&(p.vertical=Bf(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(Sp(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=Bf(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=Sp(_));let e=Bf(d,t.glyphMap,t.glyphPositions,t.imagePositions,h,v,s,_,y,f,m,1,!1,c,u);e&&(p.horizontal[y]=e),w(),tf(n)&&o&&a&&(p.vertical=Bf(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&&(_=Kf(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&&$t("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=Tp(p.horizontal)||p.vertical;t.bucket.iconsInText||=!!y&&y.iconsInText,(y||_)&&Cp(t.bucket,r,p,_,t.imageMap,n,c,f,m,g,t.canonical,t.subdivisionGranularity)}t.showCollisionBoxes&&t.bucket.generateCollisionDebugBuffers()}({bucket:this,glyphMap:i,glyphPositions:r,imageMap:n,imagePositions:s,showCollisionBoxes:o,canonical:e,subdivisionGranularity:t.subdivisionGranularity})}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];$p(d,a.x,a.y,n.x,A+n.y,u.x,u.y,i,D,_.x,_.y,w,b,f),$p(d,a.x,a.y,o.x,A+o.y,u.x+u.w,u.y,i,D,g.x,_.y,w,b,f),$p(d,a.x,a.y,l.x,A+l.y,u.x,u.y+u.h,i,D,_.x,g.y,w,b,f),$p(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),jp(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),h=a.vertexLength,u=n.layoutVertexArray,c=n.collisionVertexArray,f=o.anchorX,p=o.anchorY;this._addCollisionDebugVertex(u,c,s,f,p,new l(t,e)),this._addCollisionDebugVertex(u,c,s,f,p,new l(i,e)),this._addCollisionDebugVertex(u,c,s,f,p,new l(i,r)),this._addCollisionDebugVertex(u,c,s,f,p,new l(t,r)),a.vertexLength+=4;let d=n.indexArray;d.emplaceBack(h,h+1),d.emplaceBack(h+1,h+2),d.emplaceBack(h+2,h+3),d.emplaceBack(h+3,h),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 Bp(za,Fc.members,$a),this.iconCollisionBox=new Bp(za,Fc.members,$a);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 Up,Np;Ks("SymbolBucket",Lp,{omit:["layers","collisionBoxArray","features","compareText"]});var Gp={get paint(){return Np||=new xo({"icon-opacity":new yo(ye.paint_symbol["icon-opacity"],"icon-opacity"),"icon-color":new yo(ye.paint_symbol["icon-color"],"icon-color"),"icon-halo-color":new yo(ye.paint_symbol["icon-halo-color"],"icon-halo-color"),"icon-halo-width":new yo(ye.paint_symbol["icon-halo-width"],"icon-halo-width"),"icon-halo-blur":new yo(ye.paint_symbol["icon-halo-blur"],"icon-halo-blur"),"icon-translate":new go(ye.paint_symbol["icon-translate"],"icon-translate"),"icon-translate-anchor":new go(ye.paint_symbol["icon-translate-anchor"],"icon-translate-anchor"),"text-opacity":new yo(ye.paint_symbol["text-opacity"],"text-opacity"),"text-color":new yo(ye.paint_symbol["text-color"],"text-color",{runtimeType:Ee,getOverride:t=>t.textColor,hasOverride:t=>!!t.textColor}),"text-halo-color":new yo(ye.paint_symbol["text-halo-color"],"text-halo-color"),"text-halo-width":new yo(ye.paint_symbol["text-halo-width"],"text-halo-width"),"text-halo-blur":new yo(ye.paint_symbol["text-halo-blur"],"text-halo-blur"),"text-translate":new go(ye.paint_symbol["text-translate"],"text-translate"),"text-translate-anchor":new go(ye.paint_symbol["text-translate-anchor"],"text-translate-anchor")})},get layout(){return Up||=new xo({"symbol-placement":new go(ye.layout_symbol["symbol-placement"],"symbol-placement"),"symbol-spacing":new go(ye.layout_symbol["symbol-spacing"],"symbol-spacing"),"symbol-avoid-edges":new go(ye.layout_symbol["symbol-avoid-edges"],"symbol-avoid-edges"),"symbol-sort-key":new yo(ye.layout_symbol["symbol-sort-key"],"symbol-sort-key"),"symbol-z-order":new go(ye.layout_symbol["symbol-z-order"],"symbol-z-order"),"icon-allow-overlap":new go(ye.layout_symbol["icon-allow-overlap"],"icon-allow-overlap"),"icon-overlap":new go(ye.layout_symbol["icon-overlap"],"icon-overlap"),"icon-ignore-placement":new go(ye.layout_symbol["icon-ignore-placement"],"icon-ignore-placement"),"icon-optional":new go(ye.layout_symbol["icon-optional"],"icon-optional"),"icon-rotation-alignment":new yo(ye.layout_symbol["icon-rotation-alignment"],"icon-rotation-alignment"),"icon-size":new yo(ye.layout_symbol["icon-size"],"icon-size"),"icon-text-fit":new go(ye.layout_symbol["icon-text-fit"],"icon-text-fit"),"icon-text-fit-padding":new go(ye.layout_symbol["icon-text-fit-padding"],"icon-text-fit-padding"),"icon-image":new yo(ye.layout_symbol["icon-image"],"icon-image"),"icon-rotate":new yo(ye.layout_symbol["icon-rotate"],"icon-rotate"),"icon-padding":new yo(ye.layout_symbol["icon-padding"],"icon-padding"),"icon-keep-upright":new go(ye.layout_symbol["icon-keep-upright"],"icon-keep-upright"),"icon-offset":new yo(ye.layout_symbol["icon-offset"],"icon-offset"),"icon-anchor":new yo(ye.layout_symbol["icon-anchor"],"icon-anchor"),"icon-pitch-alignment":new go(ye.layout_symbol["icon-pitch-alignment"],"icon-pitch-alignment"),"text-pitch-alignment":new go(ye.layout_symbol["text-pitch-alignment"],"text-pitch-alignment"),"text-rotation-alignment":new go(ye.layout_symbol["text-rotation-alignment"],"text-rotation-alignment"),"text-field":new yo(ye.layout_symbol["text-field"],"text-field"),"text-font":new yo(ye.layout_symbol["text-font"],"text-font"),"text-size":new yo(ye.layout_symbol["text-size"],"text-size"),"text-max-width":new yo(ye.layout_symbol["text-max-width"],"text-max-width"),"text-line-height":new go(ye.layout_symbol["text-line-height"],"text-line-height"),"text-letter-spacing":new yo(ye.layout_symbol["text-letter-spacing"],"text-letter-spacing"),"text-justify":new yo(ye.layout_symbol["text-justify"],"text-justify"),"text-radial-offset":new yo(ye.layout_symbol["text-radial-offset"],"text-radial-offset"),"text-variable-anchor":new go(ye.layout_symbol["text-variable-anchor"],"text-variable-anchor"),"text-variable-anchor-offset":new yo(ye.layout_symbol["text-variable-anchor-offset"],"text-variable-anchor-offset"),"text-anchor":new yo(ye.layout_symbol["text-anchor"],"text-anchor"),"text-max-angle":new go(ye.layout_symbol["text-max-angle"],"text-max-angle"),"text-writing-mode":new go(ye.layout_symbol["text-writing-mode"],"text-writing-mode"),"text-rotate":new yo(ye.layout_symbol["text-rotate"],"text-rotate"),"text-padding":new go(ye.layout_symbol["text-padding"],"text-padding"),"text-keep-upright":new go(ye.layout_symbol["text-keep-upright"],"text-keep-upright"),"text-transform":new yo(ye.layout_symbol["text-transform"],"text-transform"),"text-offset":new yo(ye.layout_symbol["text-offset"],"text-offset"),"text-allow-overlap":new go(ye.layout_symbol["text-allow-overlap"],"text-allow-overlap"),"text-overlap":new go(ye.layout_symbol["text-overlap"],"text-overlap"),"text-ignore-placement":new go(ye.layout_symbol["text-ignore-placement"],"text-ignore-placement"),"text-optional":new go(ye.layout_symbol["text-optional"],"text-optional"),"symbol-height-offset":new yo(ye.layout_symbol["symbol-height-offset"],"symbol-height-offset"),"symbol-height-anchor":new go(ye.layout_symbol["symbol-height-anchor"],"symbol-height-anchor")})}},qp=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:be,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}};Ks("FormatSectionOverride",qp,{omit:["defaultValue"]});const Vp=t=>"symbol"===t.type;var Zp=class t extends Eo{constructor(t,e){super(t,Gp,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 fo(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()||kn(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 Lp(t)}queryRadius(){return 0}queryIntersectsFeature(){throw Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(let e of Gp.paint.overridableProperties){if(!t.hasPaintOverride(this.layout,e))continue;let i=this.paint.get(e),r=new Tn(new qp(i),`layers[${this.id}].paint.${i.property.name}`,i.property.specification),n=null;n="constant"===i.value.kind||"source"===i.value.kind?new jn("source",r):new Rn("composite",r,i.value.zoomStops),this.paint._values[e]=new fo(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=Gp.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 mi)s(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){let t=e=>{n||(e instanceof Ci&&Fi(e.value)===ze?s(e.value.sections):e instanceof Ri?s(e.sections):e.eachChild(t))},e=i.value;e._styleExpression&&t(e._styleExpression.expression)}return n}};let Wp;var Hp={get paint(){return Wp||=new xo({"background-color":new go(ye.paint_background["background-color"],"background-color"),"background-pattern":new wo(ye.paint_background["background-pattern"],"background-pattern"),"background-opacity":new go(ye.paint_background["background-opacity"],"background-opacity")})}},Yp=class extends Eo{constructor(t,e){super(t,Hp,e)}},Xp=class extends Eo{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 Jp(t,e){if("custom"===t.type)return new Xp(t,e);switch(t.type){case"background":return new Yp(t,e);case"circle":return new Yl(t,e);case"color-relief":return new gh(t,e);case"fill":return new wu(t,e);case"fill-extrusion":return new lc(t,e);case"heatmap":return new ah(t,e);case"hillshade":return new uh(t,e);case"line":return new xc(t,e);case"raster":return new Co(t,e);case"symbol":return new Zp(t,e)}}var Kp=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 Qp={once:!0};var td=class{constructor(t,e){this.target=t,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Kp((()=>this.process())),this.subscription=Ut(this.target,"message",(t=>this.receive(t)),!1),this.globalScope=Ot(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?Ut(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 te(e.signal.reason))}),Qp):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:io(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(Ot(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(it(ro(e.error))):i.resolve(ro(e.data)))}if(!this.messageHandlers[e.type])return void this.completeTask(t,null,null);let i=ro(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,it(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?io(e):null,data:io(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}};function ed(t,e){let{x:i,y:r}=qu.fromLngLat(e);return!(t<0||t>25||r<0||r>=1||i<0||i>=1)}var id=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=sd(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=ad(256*t,256*(e=2**i-e-1),i),n=ad(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 l((t.x*e-this.x)*tt,(t.y*e-this.y)*tt)}toString(){return`${this.z}/${this.x}/${this.y}`}},rd=class{constructor(t,e){this.wrap=t,this.canonical=e,this.key=sd(t,e.z,e.z,e.x,e.y)}},nd=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 id(i,+r,+n),this.key=sd(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?sd(this.wrap*+e,t,this.canonical.z,this.canonical.x,this.canonical.y):sd(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 rd(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}getTilePoint(t){return this.canonical.getTilePoint(new qu(t.x-this.wrap,t.y))}normalizeCoordinates(e,i,r=tt){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 sd(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 od=6378137*Math.PI;function ad(t,e,i){let r=2*od/256/2**i;return[t*r-od,e*r-od]}function ld(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}Ks("CanonicalTileID",id),Ks("OverscaledTileID",nd,{omit:["terrainRttPosMatrix32f"]});const hd="_geojsonTileLayer";var ud=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]}},cd=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=Cu(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}},fd=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}},pd=class extends fd{},dd=class extends pd{getValueFromBuffer(t){return this.dataBuffer[t]}},md=class extends pd{getValueFromBuffer(t){return this.dataBuffer[t]}},_d=class extends fd{constructor(t,e,i,r){super(t,e,r),this.delta=i}},gd=class extends _d{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}},yd=class extends fd{constructor(t,e,i,r){super(t,r?Int32Array.of(e):Uint32Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},vd=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 dd||t instanceof yd||t instanceof gd||t instanceof md}};var wd,bd,xd=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"}(wd||={}),function(t){t.NONE="NONE",t.FAST_PFOR="FAST_PFOR",t.VARINT="VARINT"}(bd||={});const Dd=new Uint32Array(33);Dd[0]=0;for(let t=1;t<=32;t++)Dd[t]=32===t?4294967295:4294967295>>>32-t;const Md=Dd;function Ed(t,e){return t-t%e}function Ad(t){return Ed(t+31,32)}function Fd(t){let e=t>>>0;return((255&e)<<24|(65280&e)<<8|e>>>8&65280|e>>>24&255)>>>0}const Sd=function(t){if(!Number.isFinite(t))return 65536;let e=Ed(Math.floor(t),256);return 0===e?256:e}(65536),Cd=3*Sd/256+Sd|0;function zd(){let t=new Uint8Array(Cd);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 Td(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=Md[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 Pd(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 Id(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 kd(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=Ad(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)$d(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=Pd(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=Td(t,u,n,f,r)}o>0&&(c=Id(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 $d(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=Md[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&Md[n-h]>>>0)<<h)&s,a=n-h}}function jd(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 Rd(t,e,i){let r=new BigUint64Array(i);for(let i=0;i<r.length;i++)r[i]=Od(t,e);return r}function Od(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 Bd(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 Ld(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|Fd(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??zd();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+Ed(n,256),a=r,l=i;for(;a!==o;){let i=Math.min(Sd,o-a);l=kd(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:zd()}}(i>>>2))}function Ud(t){return t>>>1^-(1&t)}function Nd(t){return t>>1n^-(1n&t)}function Gd(t){return t%2==1?(t+1)/-2:t/2}function qd(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 Vd(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 Zd(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 Wd(t){let e=new Int32Array(t.length);e[0]=Ud(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]=Ud(t[r])+e[r-1],e[r+1]=Ud(i)+e[r],e[r+2]=Ud(n)+e[r+1],e[r+3]=Ud(s)+e[r+2]}for(;r!==t.length;++r)e[r]=Ud(t[r])+e[r-1];return e}function Hd(t){let e=new BigInt64Array(t.length);e[0]=Nd(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]=Nd(t[r])+e[r-1],e[r+1]=Nd(i)+e[r],e[r+2]=Nd(n)+e[r+1],e[r+3]=Nd(s)+e[r+2]}for(;r!==e.length;++r)e[r]=Nd(t[r])+e[r-1];return e}function Yd(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 Xd(t){let e=new Uint32Array(t.length);e[0]=Ud(t[0])>>>0;for(let i=1;i<t.length;i++)e[i]=e[i-1]+Ud(t[i])>>>0;return e}function Jd(t){let e=new BigUint64Array(t.length);e[0]=BigInt.asUintN(64,Nd(t[0]));for(let i=1;i<t.length;i++)e[i]=BigInt.asUintN(64,e[i-1]+Nd(t[i]));return e}var Kd,Qd,tm,em;!function(t){t.PRESENT="PRESENT",t.DATA="DATA",t.OFFSET="OFFSET",t.LENGTH="LENGTH"}(Kd||={}),function(t){t.NONE="NONE",t.SINGLE="SINGLE",t.SHARED="SHARED",t.VERTEX="VERTEX",t.MORTON="MORTON",t.FSST="FSST"}(Qd||={}),function(t){t.VERTEX="VERTEX",t.INDEX="INDEX",t.STRING="STRING",t.KEY="KEY"}(tm||={}),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"}(em||={});const im=[Kd.PRESENT,Kd.DATA,Kd.OFFSET,Kd.LENGTH],rm=[wd.NONE,wd.DELTA,wd.COMPONENTWISE_DELTA,wd.RLE,wd.MORTON],nm=[bd.NONE,bd.FAST_PFOR,bd.VARINT],sm=[Qd.NONE,Qd.SINGLE,Qd.SHARED,Qd.VERTEX,Qd.MORTON,Qd.FSST],om=[tm.VERTEX,tm.INDEX,tm.STRING,tm.KEY],am=[em.VAR_BINARY,em.GEOMETRIES,em.PARTS,em.RINGS,em.TRIANGLES,em.SYMBOL,em.DICTIONARY];function lm(t,e){let i=function(t,e){let i=t[e.get()],r=im[i>>4],n={};switch(r){case Kd.DATA:n={dictionaryType:sm[15&i]};break;case Kd.OFFSET:n={offsetType:om[15&i]};break;case Kd.LENGTH:n={lengthType:am[15&i]}}e.increment();let s=t[e.get()],o=rm[s>>5],a=rm[s>>2&7],l=nm[3&s];e.increment();let h=jd(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===wd.MORTON?function(t,e,i){let r=jd(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):wd.RLE!==i.logicalLevelTechnique1&&wd.RLE!==i.logicalLevelTechnique2||bd.NONE===i.physicalLevelTechnique?i:function(t,e,i){let r=jd(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 hm;!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"}(hm||={});var um=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 cm(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 fm(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 um(t,e),s=new um(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 pm(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?cm(a,r,0):a}function dm(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?cm(a,r,0):a}const mm=new TextDecoder;function _m(t,e,i){return i-e>=12?mm.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 gm(t,e,i,r,n){return function(t,e,i,r){let n;switch(e.logicalLevelTechnique1){case wd.DELTA:if(e.logicalLevelTechnique2===wd.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=Ud(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,i.runs,i.numRleValues);n=Wd(t=qd(t,i.runs,i.numRleValues))}else n=Wd(t);break;case wd.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=Ud(o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues);break;case wd.MORTON:Yd(t),n=new Int32Array(t);break;case wd.COMPONENTWISE_DELTA:n=function(t){if(t.length<2)return new Int32Array(t);let e=new Int32Array(t.length);e[0]=Ud(t[0]),e[1]=Ud(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]=Ud(t[r])+e[r-2],e[r+1]=Ud(i)+e[r-1],e[r+2]=Ud(n)+e[r],e[r+3]=Ud(s)+e[r+1]}for(;r!==t.length;r+=2)e[r]=Ud(t[r])+e[r-2],e[r+1]=Ud(t[r+1])+e[r-1];return e}(t);break;case wd.NONE:n=function(t){let e=new Int32Array(t.length);for(let i=0;i<t.length;i++)e[i]=Ud(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?cm(n,r,0):n}(wm(t,e,i),i,0,n)}function ym(t,e,i,r,n){return function(t,e,i,r){let n;switch(e.logicalLevelTechnique1){case wd.DELTA:n=Xd(e.logicalLevelTechnique2===wd.RLE?qd(t,e.runs,e.numRleValues):t);break;case wd.RLE:n=qd(t,e.runs,e.numRleValues);break;case wd.MORTON:Yd(t),n=t;break;case wd.COMPONENTWISE_DELTA:n=function(t){if(t.length<2)return new Uint32Array(t);let e=new Uint32Array(t.length);e[0]=Ud(t[0])>>>0,e[1]=Ud(t[1])>>>0;for(let i=2;i<t.length;i+=2)e[i]=e[i-2]+Ud(t[i])>>>0,e[i+1]=e[i-1]+Ud(t[i+1])>>>0;return e}(t);break;case wd.NONE:n=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return r?cm(n,r,0):n}(wm(t,e,i),i,0,n)}function vm(t,e,i){return function(t,e){if(e.logicalLevelTechnique1===wd.DELTA&&e.logicalLevelTechnique2===wd.NONE)return function(t){let e=new Int32Array(t.length+1);e[0]=0,e[1]=Ud(t[0]);let i=e[1];for(let r=2;r!==e.length;++r)i+=Ud(t[r-1]),e[r]=e[r-1]+i;return new Uint32Array(e)}(t);if(e.logicalLevelTechnique1===wd.RLE&&e.logicalLevelTechnique2===wd.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===wd.NONE&&e.logicalLevelTechnique2===wd.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===wd.DELTA&&e.logicalLevelTechnique2===wd.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=Ud(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 Yd(i),new Uint32Array(i)}throw Error("Only delta encoding is supported for transforming length to offset streams yet.")}(wm(t,e,i),i)}function wm(t,e,i){let r=i.physicalLevelTechnique;switch(r){case bd.FAST_PFOR:return Ld(t,i.numValues,i.byteLength,e);case bd.VARINT:return jd(t,e,i.numValues);case bd.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 bm(t,e,i){let r=i.physicalLevelTechnique;switch(r){case bd.VARINT:return Rd(t,e,i.numValues);case bd.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 xm(t,e,i){let r=wm(t,e,i);return 1===r.length?i.logicalLevelTechnique1===wd.DELTA?Ud(r[0]):r[0]:function(t){return t[1]}(r)}function Dm(t,e,i){return function(t){if(2===t.length){let e=Ud(t[1]);return[e,e]}return[Ud(t[2]),Ud(t[3])]}(wm(t,e,i))}function Mm(t,e,i){return function(t){if(2===t.length){let e=Nd(t[1]);return[e,e]}return[Nd(t[2]),Nd(t[3])]}(Rd(t,e,i.numValues))}function Em(t,e,i,r){return function(t,e,i){let r;switch(e.logicalLevelTechnique1){case wd.DELTA:if(e.logicalLevelTechnique2===wd.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=Nd(t[i+e]);for(let t=0;t<o;t++)s+=a,r[n++]=s}return r}(t,n.runs,n.numRleValues);r=Hd(t=Vd(t,n.runs,n.numRleValues))}else r=Hd(t);break;case wd.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=Nd(o),r.fill(o,n,n+s),n+=s}return r}(t,e.runs,e.numRleValues);break;case wd.NONE:r=function(t){let e=new BigInt64Array(t.length);for(let i=0;i<t.length;i++)e[i]=Nd(t[i]);return e}(t);break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?cm(r,i,0n):r}(bm(t,e,i),i,r)}function Am(t,e,i,r){return Sm(bm(t,e,i),i,r)}function Fm(t,e,i){let r=bm(t,e,i);return 1===r.length?i.logicalLevelTechnique1===wd.DELTA?Nd(r[0]):r[0]:function(t){return t[1]}(r)}function Sm(t,e,i){let r;switch(e.logicalLevelTechnique1){case wd.DELTA:r=Jd(e.logicalLevelTechnique2===wd.RLE?Vd(t,e.runs,e.numRleValues):t);break;case wd.RLE:r=Vd(t,e.runs,e.numRleValues);break;case wd.NONE:r=t;break;default:throw Error(`The specified Logical level technique is not supported: ${e.logicalLevelTechnique1}`)}return i?cm(r,i,0n):r}function Cm(t,e,i,r,n="int32"){let s=t.logicalLevelTechnique1;if(s===wd.RLE)return 1===t.runs?hm.CONST:hm.FLAT;if(s!==wd.DELTA||t.logicalLevelTechnique2!==wd.RLE)return 1===t.numValues?hm.CONST:hm.FLAT;let o=e instanceof um?e.size():e;if(t.numRleValues!==o)return hm.FLAT;if(1===t.runs)return hm.SEQUENCE;if(2!==t.runs)return 1===t.numValues?hm.CONST:hm.FLAT;let a=r.get();if(t.physicalLevelTechnique===bd.VARINT)return function(t,e,i){let r=new xd(e.get());if("int64"===i){let e=Rd(t,r,4);return 2n===e[2]&&2n===e[3]}let n=jd(t,r,4);return 2===n[2]&&2===n[3]}(i,r,n)?hm.SEQUENCE:1===t.numValues?hm.CONST:hm.FLAT;let l=r.get(),h=new Int32Array(i.buffer,i.byteOffset+l,4);return r.set(a),2===h[2]&&2===h[3]?hm.SEQUENCE:1===t.numValues?hm.CONST:hm.FLAT}var zm,Tm,Pm,Im=class extends pd{getValueFromBuffer(t){return this.dataBuffer[t]}},km=class extends _d{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 $m(t,e,i){return{x:jm(t,e)-i,y:jm(t>>1,e)-i}}function jm(t,e){let i=0;for(let r=0;r<e;r++)i|=(t&1<<2*r)>>r;return i}function Rm(t,e,i,r,n,s,o){return t===Pm.MORTON?function(t,e,i,r,n,s){let o=Array(n?r+1:r);for(let n=0;n<r;n++){let r=$m(t[e[i+n]],s.numBits,s.coordinateShift);o[n]=new l(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 l(t[r],t[r+1])}return n&&(s[s.length-1]=s[0]),s}(e,i,r,n,s)}function Om(t,e,i,r){let n=Array(r?i+1:i);for(let r=0;r<2*i;r+=2)n[r/2]=new l(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"}(zm||={}),function(t){t[t.POINT=0]="POINT",t[t.LINESTRING=1]="LINESTRING",t[t.POLYGON=2]="POLYGON"}(Tm||={}),function(t){t[t.MORTON=0]="MORTON",t[t.VEC_2=1]="VEC_2",t[t.VEC_3=2]="VEC_3"}(Pm||={});var Bm=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=$m(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,h=t.mortonSettings,u=t.topologyVector,c=u.geometryOffsets,f=u.partOffsets,p=u.ringOffsets,d=t.vertexOffsets,m=!d||0===d.length,_=t.containsPolygonGeometry(),g=t.vertexBuffer;for(let u=0;u<t.numGeometries;u++){let y=t.geometryType(u);switch(y){case zm.POINT:{let u,_;if(m)u=g[o++],_=g[o++];else if(t.vertexBufferType===Pm.MORTON){let t=$m(g[d[a++]],h.numBits,h.coordinateShift);u=t.x,_=t.y}else{let t=2*d[a++];u=g[t],_=g[t+1]}e[s++]=[[new l(u,_)]],c&&n++,f&&i++,p&&r++}break;case zm.MULTIPOINT:{let u,f=c[n]-c[n-1];if(n++,m){u=Array(f);for(let t=0;t<f;t++){let e=g[o++],i=g[o++];u[t]=new l(e,i)}}else u=Rm(t.vertexBufferType,g,d,a,f,!1,h),a+=f;e[s++]=u.map((t=>[t])),i+=f,r+=f}break;case zm.LINESTRING:{let l,u;_?(l=p[r]-p[r-1],r++):l=f[i]-f[i-1],i++,m?(u=Om(g,o,l,!1),o+=2*l):(u=Rm(t.vertexBufferType,g,d,a,l,!1,h),a+=l),e[s++]=[u],c&&n++}break;case zm.POLYGON:{let l=f[i]-f[i-1];i++;let u,_=Array(l-1),y=p[r]-p[r-1];if(r++,m){u=Om(g,o,y,!0),o+=2*y;for(let t=0;t<_.length;t++)y=p[r]-p[r-1],r++,_[t]=Om(g,o,y,!0),o+=2*y}else{u=Rm(t.vertexBufferType,g,d,a,y,!0,h),a+=y;for(let e=0;e<_.length;e++)y=p[r]-p[r-1],r++,_[e]=Rm(t.vertexBufferType,g,d,a,y,!0,h),a+=y}e[s++]=[u].concat(_),c&&n++}break;case zm.MULTILINESTRING:{let l=c[n]-c[n-1];n++;let u=Array(l);for(let e=0;e<l;e++){let n;if(_?(n=p[r]-p[r-1],r++):n=f[i]-f[i-1],i++,m)u[e]=Om(g,o,n,!1),o+=2*n;else{let i=Rm(t.vertexBufferType,g,d,a,n,!1,h);u[e]=i,a+=n}}e[s++]=u}break;case zm.MULTIPOLYGON:{let l=c[n]-c[n-1];n++;let u=Array(l);for(let e=0;e<l;e++){let n=f[i]-f[i-1];i++;let s,l=Array(n-1),c=p[r]-p[r-1];r++,m?(s=Om(g,o,c,!0),o+=2*c):(s=Rm(t.vertexBufferType,g,d,a,c,!0,h),a+=c);for(let e=0;e<l.length;e++){let i=p[r]-p[r-1];r++,m?(l[e]=Om(g,o,i,!0),o+=2*i):(l[e]=Rm(t.vertexBufferType,g,d,a,i,!0,h),a+=i)}u[e]=[s].concat(l)}e[s++]=u.flat()}break;default:throw Error(`The specified geometry type (${y}) is currently not supported.`)}}return e}(this)}get mortonSettings(){return this._mortonSettings}},Lm=class extends Bm{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===zm.POLYGON||this._geometryType===zm.MULTIPOLYGON}containsSingleGeometryType(){return!0}};function Um(t,e,i,r){return new Nm(Pm.VEC_2,t,e,i,r)}var Nm=class extends Bm{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)===zm.POLYGON||this.geometryType(t)===zm.MULTIPOLYGON)return!0;return!1}containsSingleGeometryType(){return!1}},Gm=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 Um(t,this._topologyVector,void 0,this._vertexBuffer).getGeometries()}[Symbol.iterator](){return null}};function qm(t,e,i,r,n,s){return new Vm(t,e,i,r,n,s)}var Vm=class extends Gm{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 Zm(t,e,i,r,n){return new Wm(t,e,i,r,n)}var Wm=class extends Gm{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 Hm(t,e,i,r){let n,s,o,a,l=lm(t,i);if(Cm(l,r,t,i)===hm.CONST){let h,u,c,f,p=xm(t,i,l);for(let r=0;r<e-1;r++){let e=lm(t,i);switch(e.physicalStreamType){case Kd.LENGTH:switch(e.logicalStreamType.lengthType){case em.GEOMETRIES:h=vm(t,i,e);break;case em.PARTS:u=vm(t,i,e);break;case em.RINGS:c=vm(t,i,e);break;case em.TRIANGLES:f=vm(t,i,e)}break;case Kd.OFFSET:switch(e.logicalStreamType.offsetType){case tm.VERTEX:n=ym(t,i,e);break;case tm.INDEX:a=ym(t,i,e)}break;case Kd.DATA:Qd.VERTEX===e.logicalStreamType.dictionaryType?s=gm(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},s=ym(t,i,e))}}return a?void 0!==h||void 0!==u?qm(r,p,f,a,s,{geometryOffsets:h,partOffsets:u,ringOffsets:c}):qm(r,p,f,a,s):void 0===o?function(t,e,i,r,n){return new Lm(t,e,Pm.VEC_2,i,r,n)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},n,s):function(t,e,i,r,n,s){return new Lm(t,e,Pm.MORTON,i,r,n,s)}(r,p,{geometryOffsets:h,partOffsets:u,ringOffsets:c},n,s,o)}let h,u,c,f,p,d,m,_=ym(t,i,l);for(let r=0;r<e-1;r++){let e=lm(t,i);switch(e.physicalStreamType){case Kd.LENGTH:switch(e.logicalStreamType.lengthType){case em.GEOMETRIES:h=ym(t,i,e);break;case em.PARTS:u=ym(t,i,e);break;case em.RINGS:c=ym(t,i,e);break;case em.TRIANGLES:f=vm(t,i,e)}break;case Kd.OFFSET:switch(e.logicalStreamType.offsetType){case tm.VERTEX:n=ym(t,i,e);break;case tm.INDEX:a=ym(t,i,e)}break;case Kd.DATA:Qd.VERTEX===e.logicalStreamType.dictionaryType?s=gm(t,i,e):(o={numBits:e.numBits,coordinateShift:e.coordinateShift},s=ym(t,i,e))}}return h?(p=Ym(_,h,2),u&&c?(d=Xm(_,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=Ym(_,u,1),m=Xm(_,d,c,!0)):u&&(d=Ym(_,u,0)),a&&!d?Zm(_,f,a,s):a?Zm(_,f,a,s,{geometryOffsets:p,partOffsets:d,ringOffsets:m}):void 0===o?Um(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},n,s):function(t,e,i,r,n){return new Nm(Pm.MORTON,t,e,i,r,n)}(_,{geometryOffsets:p,partOffsets:d,ringOffsets:m},n,s,o)}function Ym(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 Xm(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 Jm=class extends fd{constructor(t,e,i){super(t,e.getBuffer(),i),this.dataVector=e}getValueFromBuffer(t){return this.dataVector.get(t)}},Km=class extends pd{getValueFromBuffer(t){return this.dataBuffer[t]}},Qm=class extends fd{constructor(t,e,i,r){super(t,r?BigInt64Array.of(e):BigUint64Array.of(e),i)}getValueFromBuffer(t){return this.dataBuffer[0]}},t_=class extends fd{constructor(t,e,i,r){super(t,i,r),this.offsetBuffer=e}},e_=class extends t_{constructor(t,e,i,r){super(t,e,i,r??e.length-1)}getValueFromBuffer(t){return _m(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}},i_=class extends t_{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 _m(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}},r_=class extends t_{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 _m(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 n_(t,e,i,r,n){let s,o,a,l,h,u,c,f=n;for(let t=0;t<r;t++){let t=lm(e,i);switch(t.physicalStreamType){case Kd.PRESENT:{let r=new um(fm(e,t.numValues,t.byteLength,i),t.numValues);f=n??r;break}case Kd.OFFSET:o=ym(e,i,t,0,f);break;case Kd.LENGTH:{let r=vm(e,i,t);em.DICTIONARY===t.logicalStreamType.lengthType?s=r:em.SYMBOL===t.logicalStreamType.lengthType?l=r:u=r;break}case Kd.DATA:{let r=e.subarray(i.get(),i.get()+t.byteLength);i.add(t.byteLength);let n=t.logicalStreamType.dictionaryType;Qd.FSST===n?h=r:Qd.SINGLE===n||Qd.SHARED===n?a=r:Qd.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 r_(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 i_(t,i,r,e,n):new i_(t,i,r,e)}}(t,a,o,s,f)??function(t,e,i,r,n){if(e&&i){if(r)return n?new i_(t,r,e,i,n):new i_(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 i_(t,r,e,i,n)}return n?new e_(t,e,i,n):new e_(t,e,i)}}(t,u,c,o,f)}var s_,o_,a_=class extends fd{constructor(t,e,i){super(t,new Uint8Array,i??e.length),this.values=e}getValueFromBuffer(t){return this.values[t]}};function l_(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 um(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=h_(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 h_(t,e,i,r){return i-e==1||t[e]===o_.START_LIST?c_(t,e,i,r):u_(t,e,i,r)}function u_(t,e,i,r){let n=Object.create(null),s=e;for(;s<i;){let e=p_(t[s++],r);if("string"!=typeof e)throw Error(`Map key dictionary index does not resolve to a string: ${e}`);let o=c_(t,s,i,r);n[e]=o.value,s=o.nextIndex}return{value:n,nextIndex:s}}function c_(t,e,i,r){if(e>=i)throw Error("Unexpected end of map value stream");let n=t[e];if(n===o_.FALSE)return{value:!1,nextIndex:e+1};if(n===o_.TRUE)return{value:!0,nextIndex:e+1};if(n===o_.START_MAP){let n=f_(t,e,i);return{value:u_(t,e+2,n,r).value,nextIndex:n}}if(n===o_.START_LIST){let n=f_(t,e,i),s=[],o=e+2;for(;o<n;){let e=c_(t,o,n,r);s.push(e.value),o=e.nextIndex}return{value:s,nextIndex:n}}return{value:p_(n,r),nextIndex:e+1}}function f_(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 p_(t,e){let i=t-o_.COUNT;if(i<0||i>=e.length)throw Error(`Scalar dictionary index out of range: ${t}`);return e[i]}function d_(t,e){for(let i of e)t.push(i)}function m_(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=lm(e,i),r=t.numValues,n=i.get(),s=fm(e,r,t.byteLength,i);i.set(n+t.byteLength),o=new um(s,t.numValues)}let a=o??r;switch(n.physicalType){case 4:case 3:return function(t,e,i,r,n){let s=lm(t,e),o=Cm(s,n,t,e),a=3===r.physicalType;if(o===hm.FLAT){let r=__(n)?n:void 0,o=a?gm(t,e,s,0,r):ym(t,e,s,0,r);return new dd(i.name,o,n)}if(o===hm.SEQUENCE){let r=Dm(t,e,s);return new gd(i.name,r[0],r[1],s.numRleValues,a)}let l=a?function(t,e,i){let r=wm(t,e,i);return 1===r.length?Ud(r[0]):function(t){return Ud(t[1])}(r)}(t,e,s):xm(t,e,s);return new yd(i.name,l,n,a)}(e,i,s,n,a);case 9:return n_(s.name,e,i,s.nullable?t-1:t,o)??null;case 0:return function(t,e,i,r,n){let s=lm(t,e),o=s.numValues,a=e.get(),l=__(n)?n:void 0,h=fm(t,o,s.byteLength,e,l);e.set(a+s.byteLength);let u=new um(h,o);return new Jm(i.name,u,n)}(e,i,s,0,a);case 6:case 5:return function(t,e,i,r,n){let s=lm(t,e),o=Cm(s,r,t,e,"int64"),a=5===n.physicalType;if(o===hm.FLAT){let n=__(r)?r:void 0,o=a?Em(t,e,s,n):Am(t,e,s,n);return new Im(i.name,o,r)}if(o===hm.SEQUENCE){let r=Mm(t,e,s);return new km(i.name,r[0],r[1],s.numRleValues,a)}let l=a?function(t,e,i){let r=bm(t,e,i);return 1===r.length?Nd(r[0]):function(t){return Nd(t[1])}(r)}(t,e,s):Fm(t,e,s);return new Qm(i.name,l,r,a)}(e,i,s,a,n);case 7:return function(t,e,i,r){let n=lm(t,e),s=__(r)?r:void 0,o=pm(t,e,n.numValues,s);return new Km(i.name,o,r)}(e,i,s,a);case 8:return function(t,e,i,r){let n=lm(t,e),s=__(r)?r:void 0,o=dm(t,e,n.numValues,s);return new md(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 a_(t,[])));let s=function(t,e,i){let r=t[e.get()];e.add(1);let n=ym(t,e,lm(t,e)),s=i-1,o=[];r&s_.STRING&&(s-=function(t,e,i){let r=t[e.get()];e.add(1);let n=n_("",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&s_.INT32?(d_(r,gm(t,e,lm(t,e))),n++):i&s_.INT64&&(d_(r,Em(t,e,lm(t,e))),n++),i&s_.UINT32?(d_(r,ym(t,e,lm(t,e))),n++):i&s_.UINT64&&(d_(r,Am(t,e,lm(t,e))),n++),n}(t,e,r,o),s-=function(t,e,i,r){let n=0;return i&s_.FLOAT&&(d_(r,pm(t,e,lm(t,e).numValues)),n++),i&s_.DOUBLE&&(d_(r,dm(t,e,lm(t,e).numValues)),n++),n}(t,e,r,o);let a,l=0;if(r&s_.PRESENCE){let i=function(t,e){let i=lm(t,e);if(i.physicalStreamType!==Kd.PRESENT)throw Error(`Expected PRESENT stream for map column but found: ${i.physicalStreamType}`);let r=i.numValues,n=e.get(),s=new um(fm(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=ym(t,e,lm(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=l_(s,t,o,l,h);a.push(new a_(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=lm(t,e);switch(i.physicalStreamType){case Kd.LENGTH:em.DICTIONARY===i.logicalStreamType.lengthType?r=vm(t,e,i):s=vm(t,e,i);break;case Kd.DATA:Qd.SINGLE===i.logicalStreamType.dictionaryType||Qd.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=jd(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=lm(t,e);f=new um(fm(t,i.numValues,i.byteLength,e),i.numValues)}let d=ym(t,e,lm(t,e),0,f);if(o){if(!s)throw Error(`Incomplete shared FSST dictionary for column "${p}"`);h[c++]=new r_(p,d,r,n,s,o,f,u)}else h[c++]=new i_(p,d,r,n,f)}return h}(t,e,i)}function __(t){return t instanceof um}!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"}(s_||={}),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"}(o_||={});function g_(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 y_(t){return 30===t||31===t}function v_(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 w_(t){return"scalarType"===t.type&&"logicalType"===t.scalarType?.type&&0===t.scalarType.logicalType}function b_(t){return"complexType"===t.type&&"physicalType"===t.complexType?.type&&0===t.complexType.physicalType}const x_=new TextDecoder,D_="0-3(ID), 4(GEOMETRY), 10-29(scalars), 30(STRUCT), 31(MAP)";function M_(t,e){let i=jd(t,e,1)[0];if(0===i)return"";let r=e.get(),n=t.subarray(r,r+i);return e.add(i),x_.decode(n)}function E_(t,e){let i=jd(t,e,1)[0]>>>0,r=i>=10?g_(i):null;if(!r)throw Error(`Unsupported field type code ${i}. Supported: 10-29(scalars), 30(STRUCT), 31(MAP)`);let n={...r,name:M_(t,e)};if("complexType"===n.type&&y_(i)){let i=n.complexType,r=jd(t,e,1)[0]>>>0;i.children=Array(r);for(let n=0;n<r;n++)i.children[n]=E_(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 A_(t,e){let i,r=jd(t,e,1)[0]>>>0,n=g_(r);if(!n)throw Error(`Unsupported column type code ${r}. Supported: ${D_}`);if(function(t){return t>=10}(r))i=M_(t,e);else if(r<4)i="id";else{if(4!==r)throw Error(`Unsupported column type code ${r}. Supported: ${D_}`);i="geometry"}let s={...n,name:i};if("complexType"===s.type&&y_(r)){let i=jd(t,e,1)[0]>>>0,r=s.complexType;r.children=Array(i);for(let n=0;n<i;n++)r.children[n]=E_(t,e)}return s}function F_(t,e){let i={featureTables:[]},r={};if(r.name=M_(t,e),0===r.name.length)throw Error("Missing layer name");let n=jd(t,e,1)[0]>>>0,s=jd(t,e,1)[0]>>>0;r.columns=Array(s);for(let i=0;i<s;i++)r.columns[i]=A_(t,e);return i.featureTables.push(r),[i,n]}function S_(t,e,i,r,n,s,o=!1){let a=e.scalarType?.longID?6:4,l="number"==typeof s?void 0:s,h=Cm(n,s,t,i,6===a?"int64":"int32");if(4===a)switch(h){case hm.FLAT:return new dd(r,ym(t,i,n,0,l),s);case hm.SEQUENCE:{let e=Dm(t,i,n);return new gd(r,e[0],e[1],n.numRleValues,!1)}case hm.CONST:return new yd(r,xm(t,i,n),s,!1)}switch(h){case hm.FLAT:return o?new md(r,function(t,e,i,r){let n=function(t,e,i){if(i.physicalLevelTechnique===bd.VARINT)return function(t,e){switch(e.logicalLevelTechnique1){case wd.DELTA:return e.logicalLevelTechnique2===wd.RLE&&(t=Zd(t,e.runs,e.numRleValues)),function(t){t[0]=Gd(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]=Gd(t[i])+t[i-1],t[i+1]=Gd(e)+t[i],t[i+2]=Gd(r)+t[i+1],t[i+3]=Gd(n)+t[i+2]}for(;i!==t.length;++i)t[i]=Gd(t[i])+t[i-1]}(t),t;case wd.RLE:return function(t,e){return Zd(t,e.runs,e.numRleValues)}(t,e);case wd.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]=Bd(t,e);return r}(t,e,i.numValues),i);let r=Sm(bm(t,e,i),i);return Float64Array.from(r,Number)}(t,e,i);return r?cm(n,r,0):n}(t,i,n,l),s):new Im(r,Am(t,i,n,l),s);case hm.SEQUENCE:{let e=Mm(t,i,n);return new km(r,e[0],e[1],n.numRleValues,!1)}case hm.CONST:return new Qm(r,Fm(t,i,n),s,!1)}throw Error("Vector type not supported for id column.")}var C_=class{constructor(t,e){switch(this._featureData=t,this.properties=this._featureData.properties||{},this._featureData.geometry?.type){case zm.POINT:case zm.MULTIPOINT:this.type=1;break;case zm.LINESTRING:case zm.MULTILINESTRING:this.type=2;break;case zm.POLYGON:case zm.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 l(t.x,t.y));t.push(i)}return t}},z_=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 C_(this.features[t],this.extent)}},T_=class{constructor(t){this.layers={};let e=function(t,e,i=!0){let r=new xd(0),n=[];for(;r.get()<t.length;){let e=jd(t,r,1)[0]>>>0,s=r.get()+e;if(s>t.length)throw Error(`Block overruns tile: ${s} > ${t.length}`);let o=jd(t,r,1)[0]>>>0;if(1!==o&&2!==o){r.set(s);continue}let[a,l]=F_(t,r),h=a.featureTables[0],u=null,c=null,f=[],p=0;for(let e of h.columns){let n=e.name;if(w_(e)){let s=null;if(e.nullable){let e=lm(t,r),i=r.get(),n=fm(t,e.numValues,e.byteLength,r);r.set(i+e.byteLength),s=new um(n,e.numValues)}let o=lm(t,r);p=s?s.size():o.decompressedCount,u=S_(t,e,r,n,o,s??p,i)}else if(b_(e)){let e=jd(t,r,1)[0];if(0===p){let e=r.get();p=lm(t,r).decompressedCount,r.set(e)}c=Hm(t,e,r,p)}else{let i=v_(e)?jd(t,r,1)[0]:1;if(0===i)continue;let n=m_(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 vd(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 z_(e)})),{})}};function P_(t,e,i,r,n){return zt(t,((t,s)=>{let o=e instanceof po?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 I_(t,e){return e-t}Ks("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 Xs(tt,16,0),this.grid3D=new Xs(tt,16,0),this.featureIndexArray=new _a,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 T_(this.rawTileData).layers:new Iu(new Af(this.rawTileData)).layers,this.sourceLayerCoder=new ud(this.vtLayers?Object.keys(this.vtLayers).sort():[hd])),this.vtLayers}query(t,e,i,r){this.loadVTLayers();let n=t.params,s=tt/t.tileSize/t.scale,o=Jn(n.filter,"queryRenderedFeatures filter",n.globalState),a=t.queryGeometry,l=t.queryPadding*s,h=Mu.fromPoints(a),u=this.grid.query(h.minX-l,h.minY-l,h.maxX+l,h.maxY+l),c=Mu.fromPoints(t.cameraQueryGeometry).expandBy(l),f=this.grid3D.query(c.minX,c.minY,c.maxX,c.maxY,((e,i,r,n)=>kl(t.cameraQueryGeometry,e-l,i-l,r+l,n+l)));for(let t of f)u.push(t);u.sort(I_);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||=vl(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=wl(p,!0);if(!n.filter(new so(this.tileID.overscaledZ),t,this.tileID.canonical))return}else if(!n.filter(new so(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=Dt({},l[e]);c.paint=P_(c.paint,i.paint,p,n,o),c.layout=P_(c.layout,i.layout,p,n,o);let f=!u||u(p,i,n);if(!f)continue;let m=new cd(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=Jn(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"]});var k_=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)}};
|
|
6
|
+
/**
|
|
7
|
+
* MapLibre GL JS
|
|
8
|
+
* @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v6.9.0/LICENSE.txt
|
|
9
|
+
*/function $_(){var t=new p(4);return p!=Float32Array&&(t[1]=0,t[2]=0),t[0]=1,t[3]=1,t}let j_,R_,O_;const B_={frame(t,e,i,r){let n=r||window,s=n.requestAnimationFrame((t=>{o(),e(t)})),{unsubscribe:o}=Ut(t.signal,"abort",(()=>{o(),n.cancelAnimationFrame(s),i(new te(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(c()&&!f())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=>(j_||=document.createElement("a"),j_.href=t,j_.href),get hardwareConcurrency(){return typeof navigator<"u"&&navigator.hardwareConcurrency||4},get prefersReducedMotion(){return void 0===O_?!!matchMedia&&(R_??=matchMedia("(prefers-reduced-motion: reduce)"),R_.matches):O_},set prefersReducedMotion(t){O_=t}},L_=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 U_(){return L_.getCurrentTime()}var N_=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 l((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||document.createElement("body"),r=i.querySelectorAll("script, iframe");for(let t of r)t.remove();return t.clean(i),i.innerHTML}static isPossiblyDangerous(t,e){let i=e.replace(/\s+/g,"").toLowerCase();if(["src","href","xlink:href"].includes(t)&&(i.includes("javascript:")||i.includes("data:"))||"srcdoc"===t||t.startsWith("on"))return!0}static clean(e){let i=e.children;for(let e of i)t.removeAttributes(e),t.clean(e)}static removeAttributes(e){for(let{name:i,value:r}of Array.from(e.attributes))t.isPossiblyDangerous(i,r)&&e.removeAttribute(i)}};let G_;(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 ie(r.signal),G_.getImage(o,r,n,s)},t.getImage=(t,i,r=!0,n)=>new Promise(((s,o)=>{t.headers||={},t.headers.accept="image/webp,*/*",Dt(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 ${it(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&&!Ot(self)&&!ne(e.url)&&(!e.headers||Object.keys(e.headers).reduce(((t,e)=>t&&"accept"===e),!0));i++;let f=c?l(e,u):le(e,u);try{let e=await f;delete t.abortController,t.state="completed",e.data instanceof HTMLImageElement||Lt(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(it(e))}finally{i--,a()}},a=()=>{let t=(()=>{for(let t of Object.keys(n))if(n[t]())return!0;return!1})()?re.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:re.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||!ce(s))&&(n.crossOrigin="anonymous"),e.signal.addEventListener("abort",(()=>{n.src="",r(new te(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}))})(G_||={}),G_.resetRequestQueue();var q_=class{constructor(t){this._transformRequestFn=t??null}transformRequest(t,e){return this._transformRequestFn&&this._transformRequestFn(t,e)||{url:t}}setTransformRequest(t){this._transformRequestFn=t}},V_=class extends de{},Z_=class extends V_{},W_=class extends V_{constructor(t={}){super("style.load",t)}},H_=class extends V_{constructor(t,e={}){super(t,e),this.dataType="style"}},Y_=class extends V_{constructor(t,e={}){super(t,e),this.dataType="source"}},X_=class extends V_{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=N_.mousePos(e.getCanvas(),i);super(t,Dt({point:n,lngLat:e.unproject(n),originalEvent:i},r)),this._defaultPrevented=!1,this.target=e}},J_=class extends V_{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e,i){let r="touchend"===t?i.changedTouches:i.touches,n=N_.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 l(0,0));super(t,{points:n,point:o,lngLats:s,lngLat:e.unproject(o),originalEvent:i}),this._defaultPrevented=!1}},K_=class extends V_{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,e){super("wheel",{originalEvent:e}),this._defaultPrevented=!1}},Q_=class extends V_{},tg=class extends V_{constructor(t={}){super("terrain",t)}},eg=class extends V_{constructor(t={}){super("projectiontransition",t)}},ig=class extends V_{},rg=class extends V_{constructor(t={}){super("styleimagemissing",t)}};function ng(t,e){let i={};for(let e in t)"ref"!==e&&(i[e]=t[e]);return ve.forEach((t=>{t in e&&(i[t]=e[t])})),i}function sg(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]=ng(t[i],e[t[i].ref]));return t}function og(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(!og(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(!og(t[i],e[i]))return!1;return!0}return t===e}function ag(t,e){t.push(e)}function lg(t,e,i){ag(i,{command:"addSource",args:[t,e[t]]})}function hg(t,e,i){ag(e,{command:"removeSource",args:[t]}),i[t]=!0}function ug(t,e,i,r){hg(t,i,r),lg(t,e,i)}function cg(t,e,i){let r;for(r in t[i])if(Object.prototype.hasOwnProperty.call(t[i],r)&&"data"!==r&&!og(t[i][r],e[i][r]))return!1;for(r in e[i])if(Object.prototype.hasOwnProperty.call(e[i],r)&&"data"!==r&&!og(t[i][r],e[i][r]))return!1;return!0}function fg(t,e,i,r,n,s){t||={},e||={};for(let o in t)Object.prototype.hasOwnProperty.call(t,o)&&(og(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}));for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&!Object.prototype.hasOwnProperty.call(t,o)&&(og(t[o],e[o])||i.push({command:s,args:[r,o,e[o],n]}))}function pg(t){return t.id}function dg(t,e){return t[e.id]=e,t}function mg(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 _g(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 gg=class extends _e{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 rh({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 me(Error(`Image "${t}" has invalid "stretchX" value`))),i=!1),this._validateStretch(e.stretchY,r?.height)||(this.fire(new me(Error(`Image "${t}" has invalid "stretchY" value`))),i=!1),this._validateContent(e.content,e)||(this.fire(new me(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 rg({id:t})),$t(`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||$t(`Image with ID: "${e}" was not found`),Tf(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}},yg=class{constructor(t){this._imageManager=t,this._entries={},this._image=new rh({width:1,height:1}),this._dirty=!0}destroy(){this._texture&&=(this._texture.destroy(),null),this._entries={},this._image=new rh({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 If(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}bind(t){let e=t.gl;this._texture?this._dirty&&=(this._texture.update(this._image),!1):(this._texture=new dh(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}=Pf(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;rh.copy(s,r,{x:0,y:0},{x:i,y:n},{width:o,height:a}),rh.copy(s,r,{x:0,y:a-1},{x:i,y:n-1},{width:o,height:1}),rh.copy(s,r,{x:0,y:0},{x:i,y:n+a},{width:o,height:1}),rh.copy(s,r,{x:o-1,y:0},{x:i-1,y:n},{width:1,height:a}),rh.copy(s,r,{x:0,y:0},{x:i+o,y:n},{width:1,height:a})}this._dirty=!0}};const vg=1114111,wg={start:0,end:vg};let bg=0;function xg(t){let e=/^u\+([0-9a-f]*)(\?+)$/i.exec(t);if(e){let[,t,i]=e;return t.length+i.length>6?null:Dg(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 Dg(r,void 0===i[2]?r:parseInt(i[2],16))}function Dg(t,e){return t>e||t>vg?null:{start:t,end:Math.min(e,vg)}}function Mg(t,e){return t.ranges.some((({start:t,end:i})=>e>=t&&e<=i))}var Eg=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(Mg(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 $t(`Ignoring the font face declared for "${t}": it has no URL.`),null;let r="maplibre-gl-font-face-"+bg++,n=i["unicode-range"];if(!n?.length)return{url:i.url,ranges:[wg],family:r};let s=[];for(let t of n){let e=xg(t);e?s.push(e):$t(`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 $t(`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),$t(`Ignoring the font face at ${t.url}: ${it(i).message}`),!1}}async _downloadFontFile(t){let e=await this.requestManager.transformRequest(t,"Glyphs"),i=await ue(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 Ag=1e20,Fg=new Float64Array(256);for(let t=0;t<256;t++){let e=.5-(t/255)**(1/2.2);Fg[t]=e*Math.abs(e)}Fg[255]=-1e20;var Sg=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(Ag,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=Fg[t];y[e]=Math.max(0,i),g[e]=Math.max(0,-i)}}Cg(y,0,0,u,c,u,this.f,this.v,this.z);let b=Math.min(_,1);Cg(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 Cg(t,e,i,r,n,s,o,a,l){for(let h=e;h<e+r;h++)zg(t,i*s+h,s,n,o,a,l);for(let h=i;h<i+n;h++)zg(t,h*s+e,1,r,o,a,l)}function zg(t,e,i,r,n,s,o){s[0]=0,o[0]=-1e20,o[1]=Ag,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]=Ag}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 Tg=ye.layout_symbol["text-font"].default.join(","),Pg=(t,e)=>{let i=new Sg(t);return i.buffer=e,i};var Ig=class{constructor(t,e,i,r=Pg){this.requestManager=t,this.localIdeographFontFamily=e,this.entries={},this.lang=i,this.fontFaceManager=new Eg(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 of t[i])e.push(this._getAndCacheGlyphsPromise(i,r));let i=await Promise.all(e),r={};for(let{stack:t,id:e,glyph:n}of i)r[t]||={},r[t][e]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics};return r}async _getAndCacheGlyphsPromise(t,e){this.entries[t]??={glyphs:{},requests:{},ranges:{}};let i=this.entries[t],r=i.glyphs[e];if(void 0!==r)return{stack:t,id:e,glyph:r};let n=e.codePointAt(0),s=this.fontFaceManager.hasFontFaces()?await this.fontFaceManager.getFontFamily(t,n):null;return s?(r=i.glyphs[e]=await this._drawGlyph(i,t,e,s),{stack:t,id:e,glyph:r}):!this.url||Kc(e)||this._charUsesLocalIdeographFontFamily(n)?(r=i.glyphs[e]=await this._drawGlyph(i,t,e),{stack:t,id:e,glyph:r}):await this._downloadAndCacheRangePromise(t,e)}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[String.fromCodePoint(+t)]=s[+t];return r.ranges[n]=!0,{stack:t,id:e,glyph:s[i]||null}}catch(s){let o=r.glyphs[e]=await this._drawGlyph(r,t,e);return this._warnOnMissingGlyphRange(o,n,i,it(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 ue(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 Af(t).readFields(Ff,[])}(s.data))o[t.id]=t;return o}_warnOnMissingGlyphRange(t,e,i,r){let n=256*e;$t(`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 ih({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=Kc(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===Tg&&""!==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){$t(`Failed to load font "${n}": ${it(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={},e.requests={},e.ranges={}}this.entries={},this.fontFaceManager.destroy()}};let kg;var $g=class extends _e{constructor(t,e){super(),this._transitionable=new lo(kg||=new xo({anchor:new go(ye.light.anchor,"anchor"),position:new go(ye.light.position,"position"),color:new go(ye.light.color,"color"),intensity:new go(ye.light.intensity,"intensity")}),"light",e),this.setLight(t),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}getCartesianPosition(){return function([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)]}(this.properties.get("position"))}setLight(t,e={}){if(!this._validate(Vs.light,t,e))for(let e in t){let i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i){return Ys(this,t,{value:e},i)}};let jg;var Rg=class extends _e{constructor(t,e){super(),this._transitionable=new lo(jg||=new xo({"sky-color":new go(ye.sky["sky-color"],"sky-color"),"horizon-color":new go(ye.sky["horizon-color"],"horizon-color"),"fog-color":new go(ye.sky["fog-color"],"fog-color"),"fog-ground-blend":new go(ye.sky["fog-ground-blend"],"fog-ground-blend"),"horizon-fog-blend":new go(ye.sky["horizon-fog-blend"],"horizon-fog-blend"),"sky-horizon-blend":new go(ye.sky["sky-horizon-blend"],"sky-horizon-blend"),"atmosphere-blend":new go(ye.sky["atmosphere-blend"],"atmosphere-blend")}),"sky",e),this.setSky(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new so(0))}setSky(t,e={}){if(!this._validate(Vs.sky,t,e)){t||={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0};for(let e in t){let i=t[e];e.endsWith("-transition")?this._transitionable.setTransition(e.slice(0,-11),i):this._transitionable.setValue(e,i)}}}getSky(){return this._transitionable.serialize()}updateTransitions(t){this._transitioning=this._transitionable.transitioned(t,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(t){this.properties=this._transitioning.possiblyEvaluate(t)}_validate(t,e,i={}){return Ys(this,t,{value:e},i)}calculateFogBlendOpacity(t){return t<60?0:t<70?(t-60)/10:1}},Og=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 $t("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))}};function Bg(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 Lg(){let t=re.WORKER_URL||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";return new URL(`./${e}`,t).href}(),e=!t?.endsWith(".cjs");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 Bg(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 Bg(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 Bg(i,e)}finally{URL.revokeObjectURL(i)}}var Ug=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(Lg());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 Ng=Math.floor(B_.hardwareConcurrency/2);let Gg;function qg(){return Gg||=new Ug,Gg}Ug.workerCount=function(t){if(null==Bt){let e=t.navigator?t.navigator.userAgent:null;Bt=!!t.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return Bt}(globalThis)?Math.max(Math.min(Ng,3),1):1;var Vg=class{constructor(t,e){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=e,this.removed=!1,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)=>{let r=new td(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();this.actors=[],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 Zg;function Wg(){return Zg||(Zg=new Vg(qg(),se),Zg.registerMessageHandler("GR",((t,e,i)=>le(e,i)))),Zg}function Hg(t,e){let i=m();return w(i,i,[1,1,0]),b(i,i,[.5*t.width,.5*t.height,1]),t.calculatePosMatrix?v(i,i,t.calculatePosMatrix(e.toUnwrapped())):i}function Yg(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(Xg);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,Hg(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])Jg(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 Xg(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 Jg(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 Kg(t,e,i,r){let n=t;if(t.url?n=(await he(await e.transformRequest(t.url,"Source"),i)).data:await B_.frameAsync(i,r),!n)return null;let s=Mt(Dt(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 Qg=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 $u?new $u(t.lng,t.lat):$u.convert(t),this}setSouthWest(t){return this._sw=t instanceof $u?new $u(t.lng,t.lat):$u.convert(t),this}extend(e){let i,r,n=this._sw,s=this._ne;if(e instanceof $u)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($u.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend($u.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 $u(i.lng,i.lat),this._ne=new $u(r.lng,r.lat)),this}getCenter(){return new $u((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 $u(this.getWest(),this.getNorth())}getSouthEast(){return new $u(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}=$u.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=xt(this.getWest(),-180,180),s=xt(this.getEast(),-180,180),o=xt(e.getWest(),-180,180),a=xt(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 $u(e.lng-n,e.lat-r),new $u(e.lng+n,e.lat+r))}adjustAntiMeridian(){let e=new $u(this._sw.lng,this._sw.lat),i=new $u(this._ne.lng,this._ne.lat);return new t(e,e.lng>i.lng?new $u(i.lng+360,i.lat):i)}},ty=class{constructor(t,e,i){this.bounds=Qg.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(Ou(this.bounds.getWest())*e),r=Math.floor(Bu(this.bounds.getNorth())*e),n=Math.ceil(Ou(this.bounds.getEast())*e),s=Math.ceil(Bu(this.bounds.getSouth())*e);return t.x>=i&&t.x<n&&t.y>=r&&t.y<s}},ey=class extends _e{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,Dt(this,Mt(e,["url","scheme","tileSize","promoteId","encoding"])),this._options=Dt({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 Y_("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Kg(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(Dt(this,e),e.bounds&&(this.tileBounds=new ty(e.bounds,this.minzoom,this.maxzoom)),this.fire(new Y_("data",{sourceDataType:"metadata"})),this.fire(new Y_("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,ee(t)||this.fire(new me(it(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 Dt({},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};i.request.collectResourceTiming=this._collectResourceTiming,await this.dispatcher.waitForInitComplete();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||ee(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.painter),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}},iy=class extends _e{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=Dt({type:"raster"},e),Dt(this,Mt(e,["url","scheme","tileSize"]))}async load(t=!1){this._loaded=!1,this.fire(new Y_("dataloading")),this._tileJSONRequest=new AbortController;try{let e=await Kg(this._options,this.map._requestManager,this._tileJSONRequest,this.map._ownerWindow);this._tileJSONRequest=null,this._loaded=!0,e&&(Dt(this,e),e.bounds&&(this.tileBounds=new ty(e.bounds,this.minzoom,this.maxzoom)),this.fire(new Y_("data",{sourceDataType:"metadata"})),this.fire(new Y_("data",{sourceDataType:"content",sourceDataChanged:t})))}catch(t){this._tileJSONRequest=null,this._loaded=!0,ee(t)||this.fire(new me(it(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 Dt({},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 G_.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 rh({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 dh(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}},ry=class extends iy{constructor(t,e,i,r){super(t,e,i,r),this.type="raster-dem",this.maxzoom=22,this._options=Dt({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 G_.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=Lt(e)&&c()?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"&&f()){let e=t.width+4,i=t.height+4;try{return new rh({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 B_.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 nd(t.overscaledZ,n,e.z,r,e.y).key]={backfilled:!1},a[new nd(t.overscaledZ,o,e.z,s,e.y).key]={backfilled:!1},e.y>0&&(a[new nd(t.overscaledZ,n,e.z,r,e.y-1).key]={backfilled:!1},a[new nd(t.overscaledZ,t.wrap,e.z,e.x,e.y-1).key]={backfilled:!1},a[new nd(t.overscaledZ,o,e.z,s,e.y-1).key]={backfilled:!1}),e.y+1<i&&(a[new nd(t.overscaledZ,n,e.z,r,e.y+1).key]={backfilled:!1},a[new nd(t.overscaledZ,t.wrap,e.z,e.x,e.y+1).key]={backfilled:!1},a[new nd(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 ny(t,e){return e?t.properties[e]:t.id}function sy(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 oy(t){if(!t)return{};let e={};return e.removeAll=t.removeAll,e.remove=new Set(t.remove||[]),e.add=new Map(t.add?.map((t=>[t.id,t]))),e.update=new Map(t.update?.map((t=>[t.id,t]))),e}function ay(t){return t&&0!==t.length?"number"==typeof t[0]?[t]:t.flatMap((t=>ay(t))):[]}function ly(t){return"GeometryCollection"===t.type?t.geometries.flatMap((t=>ly(t))):ay(t.coordinates)}function hy(t){let e,i=new Qg;switch(t.type){case"FeatureCollection":e=t.features.flatMap((t=>ly(t.geometry)));break;case"Feature":e=ly(t.geometry);break;default:e=ly(t)}if(0===e.length)return i;for(let t of e){let[e,r]=t;i.extend([e,r])}return i}var uy=class extends _e{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._isUpdatingWorker=!1,this._pendingWorkerUpdate={data:e.data},this.actorPromise=i.getActor(),this.setEventedParent(r),this._data="string"==typeof e.data?{url:e.data}:{geojson:e.data},this._options=Dt({},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&&$t(`The maxzoom value "${this.maxzoom}" is expected to be greater than the clusterMaxZoom value "${e.clusterMaxZoom}".`),this.workerOptions=Dt({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:tt,maxZoom:this.maxzoom,lineMetrics:e.lineMetrics||!1,generateId:e.generateId||!1,promoteId:"string"==typeof e.promoteId?e.promoteId:void 0,cluster:e.cluster||!1,clusterOptions:{maxZoom:this._getClusterMaxZoom(e.clusterMaxZoom),minPoints:Math.max(2,e.clusterMinPoints||2),extent:tt,radius:this._pixelsToTileUnits(e.clusterRadius||50),log:!1,generateId:e.generateId||!1}},clusterProperties:e.clusterProperties,filter:e.filter},e.workerOptions)}_hasPendingWorkerUpdate(){return void 0!==this._pendingWorkerUpdate.data||void 0!==this._pendingWorkerUpdate.diff||this._pendingWorkerUpdate.updateCluster}_pixelsToTileUnits(t){return t*(tt/this.tileSize)}_tileUnitsToPixels(t){return t/(tt/this.tileSize)}_getClusterMaxZoom(t){let e=t?Math.round(t):this.maxzoom-1;return Number.isInteger(t)||void 0===t||$t(`Integer expected for option 'clusterMaxZoom': provided value "${t}" rounded to "${e}"`),e}async load(){await this._updateWorkerData()}onAdd(t){this.map=t,this.load()}setData(t){return this._data="string"==typeof t?{url:t}:{geojson:t},this._pendingWorkerUpdate={data:t},this._updateWorkerData()}updateData(t){return this._pendingWorkerUpdate.diff=function(t,e){if(!t)return e||{};if(!e)return t||{};let i=oy(t),r=oy(e);!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,sy(n,r)),t.update.delete(i))}}(i,r);let n={};if((i.removeAll||r.removeAll)&&(n.removeAll=!0),n.remove=new Set([...i.remove,...r.remove]),n.add=new Map([...i.add,...r.add]),n.update=new Map([...i.update,...r.update]),n.remove.size&&n.add.size)for(let t of n.add.keys())n.remove.delete(t);let s=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}(n);return s}(this._pendingWorkerUpdate.diff,t),this._updateWorkerData()}async getData(){return this._data.url&&await this.once("data"),this._data.geojson?this._data.geojson:{type:"FeatureCollection",features:Array.from(this._data.updateable.values())}}async getBounds(){return hy(await this.getData())}setClusterOptions(t){return this.workerOptions.geojsonVtOptions.cluster=t.cluster,void 0!==t.clusterRadius&&(this.workerOptions.geojsonVtOptions.clusterOptions.radius=this._pixelsToTileUnits(t.clusterRadius)),void 0!==t.clusterMaxZoom&&(this.workerOptions.geojsonVtOptions.clusterOptions.maxZoom=this._getClusterMaxZoom(t.clusterMaxZoom)),this._pendingWorkerUpdate.updateCluster=!0,this._updateWorkerData()}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 _updateWorkerData(){if(this._isUpdatingWorker)return this._updatePromise;if(!this._hasPendingWorkerUpdate())return void $t(`No pending worker updates for GeoJSONSource ${this.id}.`);let{data:t,diff:e,updateCluster:i}=this._pendingWorkerUpdate,r=this._getLoadGeoJSONParameters(t,e,i);void 0===t?e?this._pendingWorkerUpdate.diff=void 0:i&&(this._pendingWorkerUpdate.updateCluster=void 0):this._pendingWorkerUpdate.data=void 0,this._updatePromise=this._dispatchWorkerUpdate(r),await this._updatePromise}async _getLoadGeoJSONParameters(t,e,i){let r=Dt({type:this.type,source:this.id},this.workerOptions);return"string"==typeof t?(r.request=await this.map._requestManager.transformRequest(B_.resolveURL(t),"Source"),r.request.collectResourceTiming=this._collectResourceTiming,r):void 0!==t?(r.data=t,r):e?(r.dataDiff=e,r):i?(r.updateCluster=!0,r):void 0}async _dispatchWorkerUpdate(t){this._isUpdatingWorker=!0,this.fire(new Y_("dataloading"));try{let e=await t,i=await(await this.actorPromise).sendAsync({type:"LD",data:e});if(this._isUpdatingWorker=!1,this._removed||i.abandoned)return void this.fire(new Y_("dataabort"));i.data&&(this._data={geojson:i.data});let r=this._applyDiffToSource(e.dataDiff),n=this._getShouldReloadTileOptions(r),s={};this._applyResourceTiming(s,i),this.fire(new Y_("data",{...s,sourceDataType:"metadata"})),this.fire(new Y_("data",{...s,sourceDataType:"content",shouldReloadTileOptions:n}))}catch(t){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new Y_("dataabort"));this.fire(new me(it(t)))}finally{this._hasPendingWorkerUpdate()&&await this._updateWorkerData()}}_applyResourceTiming(t,e){if(!this._collectResourceTiming)return;let i=e.resourceTiming?.[this.id];if(!i)return;let r=i.slice(0);r?.length&&Dt(t,{resourceTiming:r})}_applyDiffToSource(t){if(!t)return;let e="string"==typeof this.promoteId?this.promoteId:void 0;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=ny(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=ny(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=ny(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._options.cluster?void 0:i}_getShouldReloadTileOptions(t){if(t)return{affectedBounds:t.filter(Boolean).map((t=>hy(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=Uu((t-r)/2**i),s=Nu((e+1+r)/2**i),o=Uu((t+1+r)/2**i),a=Nu((e-r)/2**i);return new Qg([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._isUpdatingWorker&&!this._hasPendingWorkerUpdate()}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.painter,"RT"===e)}catch(e){if(delete t.abortController,t.aborted||ee(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.actorPromise.then((t=>t.sendAsync({type:"RS",data:{type:this.type,source:this.id}})))}serialize(){return Dt({},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 cy=[0,0,1],fy=(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:my(r.paint.get("raster-saturation")),u_contrast_factor:dy(r.paint.get("raster-contrast")),u_spin_weights:py(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 py(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 dy(t){return t>0?1/(1-t):1+t}function my(t){return t>0?1-1/(1.001-t):-t}var _y=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 gy=Io([{name:"a_pos",type:"Int16",components:2}]);function yy(t,e){let i=vy(e,"16bit"),r=ga.deserialize({arrayBuffer:i.vertices,length:i.vertices.byteLength/2/2}),n=ka.deserialize({arrayBuffer:i.indices,length:i.indices.byteLength/2/3});return new _y(t.createVertexBuffer(r,gy.members),t.createIndexBuffer(n),Oa.simpleSegment(0,0,r.length,n.length))}function vy(t,e){let i=void 0===t.granularity?1:Math.max(t.granularity,1),r=i+(t.generateBorders?2:0),n=i+(t.extendToNorthPole||t.generateBorders?1:0)+(t.extendToSouthPole||t.generateBorders?1:0),s=r+1,o=n+1,a=t.generateBorders?-1:0,l=t.generateBorders||t.extendToNorthPole?-1:0,h=i+ +!!t.generateBorders,u=i+(t.generateBorders||t.extendToSouthPole?1:0),c=s*o,f=r*n*6,p=s*o>65536;if(p&&"16bit"===e)throw Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");let d=p||"32bit"===e,m=new Int16Array(2*c),_=0;for(let e=l;e<=u;e++)for(let r=a;r<=h;r++){let n=r/i*tt;-1===r&&(n=-64),r===i+1&&(n=8256);let s=e/i*tt;-1===e&&(s=t.extendToNorthPole?lu:-64),e===i+1&&(s=t.extendToSouthPole?hu:8256),m[_++]=n,m[_++]=s}let g=d?new Uint32Array(f):new Uint16Array(f),y=0;for(let t=0;t<n;t++)for(let e=0;e<r;e++){let i=e+1+t*s,r=e+(t+1)*s,n=e+1+(t+1)*s;g[y++]=e+t*s,g[y++]=r,g[y++]=i,g[y++]=i,g[y++]=r,g[y++]=n}return{vertices:m.buffer.slice(0),indices:g.buffer.slice(0),uses32bitIndices:d}}var wy=class extends _e{constructor(t,e,i,r){super(),this.imageWarp=cy,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 Y_("dataloading")),this.url=this.options.url,this._abortController=new AbortController;try{let e=await G_.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 me(Error(`Could not load image ${this.url}: the response is empty`)))}catch(t){if(ee(t))return;this._abortController=null,this._loaded=!0,this.fire(new me(it(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??=yy(t,{granularity:16}),this._subdividedMesh)}_disposeTexture(){this.texture?.destroy(),this.texture=null}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Y_("data",{sourceDataType:"metadata"})))}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(qu.fromLngLat);return this.tileID=function(t){let e=Mu.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 id(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||by(t))return cy;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?cy:[d,m,y]}(this.tileCoords,this._warp),this._subdividedQuad=this.imageWarp[2]>0&&!by(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 Y_("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 dh(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 Y_("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}=Mu.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 by(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 xy=class extends wy{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");ce(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 me(it(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 me(new we(`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 dh(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 Y_("data",{sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},Dy=class extends wy{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 me(new we(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new me(new we(`sources.${t}`,null,'missing required property "coordinates"'))),e.animate&&"boolean"!=typeof e.animate&&this.fire(new me(new we(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),e.canvas?"string"!=typeof e.canvas&&!(e.canvas instanceof HTMLCanvasElement)&&this.fire(new me(new we(`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 me(new we(`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 me(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 dh(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 Y_("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 My={},Ey="RTLPluginLoaded";var Ay=class extends _e{constructor(...t){super(...t),this.status="unavailable",this.url=null,this.dispatcher=Wg()}_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=B_.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 de(Ey))}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}};let Fy=null;function Sy(){return Fy||=new Ay,Fy}var Cy=class{constructor(t,e){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=t,this.uid=At(),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||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=U_(),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?.style),this.hasSymbolBuckets=!1;for(let t in this.buckets){let e=this.buckets[t];if(e instanceof Lp){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 Lp&&e.hasRTLText){this.hasRTLText=!0,Sy().lazyLoad();break}}this.queryPadding=0;for(let t in this.buckets){let i=this.buckets[t];this.queryPadding=Math.max(this.queryPadding,e.style.getLayer(t).queryRadius(i))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),this.dashPositions=t.dashPositions}else this.collisionBoxArray=new oa;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 dh(t,this.imageAtlas.image,e.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&=(this.glyphAtlasTexture=new dh(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=Jn(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=wl(r,!0);if(!o.filter(new so(this.tileID.overscaledZ),t,this.tileID.canonical))continue}else if(!o.filter(new so(this.tileID.overscaledZ),r))continue;let c=i.getId(r,n),f=new cd(r,a,l,h,c);f.tile=u,t.push(f)}}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.style.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?.style?.getLayer(i);l&&(this.queryPadding=Math.max(this.queryPadding,l.queryRadius(n)))}}holdingForSymbolFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<U_()}clearSymbolFadeHold(){this.symbolFadeHoldUntil=void 0}setSymbolHoldDuration(t){this.symbolFadeHoldUntil=U_()+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}};function zy(t){let e=[];for(let i in t)e.push({id:i,state:t[i]});return e}var Ty=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]||={},Dt(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=Dt({},(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]=zy(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]||={},Dt(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]=zy(i[t]);t.setFeatureState(r,e,this.revision)}},Py=class t{constructor(t,e){this.min=t,this.max=e,this.center=I([],T([],this.min,this.max),.5)}quadrant(e){let i=[e%2==0,e<2],r=S(this.min),n=S(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}},Iy=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=q([],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=N([],t[e+s],t[e+n]),r=C(i);I(i,i,1/r),a.push(r),l.push(i)}for(let e=0;e<4;e++){let r=ct(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 $(i,R([],N([],t[e[0]],t[e[1]]),N([],t[e[2]],t[e[1]]))),i[3]=-j(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/G(t)),r=N([],e,I([],i,j(e,i))),n=G(r);if(n>0){let t=Math.sqrt(1-i[3]*i[3]);return ht(e,T([],I([],i,-i[3]),I([],r,t/n)))}return null}(i,h);if(null!==u){let t=u/j(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=$([],R([],N([],l[t[0]],l[t[1]]),N([],l[t[2]],l[t[1]]))),i=-j(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 Py(u,c))}};function ky(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 $y(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 jy(t,e){return function(i,r,n,s,o){let a=2*((t-1)/St(Math.cos(Nt(Vu-o))/Math.cos(Nt(Vu)))-1),l=Math.acos(n/s),h=2*$y(a-1,0,Nt(o/2)),u=Math.min(Nt(Vu),l+Nt(o/2)),c=$y(a-1,Math.min(u,l-Nt(o/2)),u),f=Math.atan(r/n),p=i;return p+=St(s/Math.hypot(r,n)/Math.max(.5,Math.cos(Nt(o/2)))),p+=a*St(Math.cos(f))/2,p-=St(Math.max(1,c/h/e))/2,p}}const Ry=jy(9.314,3);function Oy(t,e){let i=(e.roundZoom?Math.round:Math.floor)(t.zoom+St(t.tileSize/e.tileSize));return Math.max(0,i)}function By(t,e){let i=t.getCameraFrustum(),r=t.getClippingPlane();if(r&&e.maxContentElevation>0){let n=Math.hypot(r[0],r[1],r[2]);if(n>0){let s=1+e.maxContentElevation/ku,o=bt(-r[3]/n,-1,1),a=Math.cos(Math.acos(o)+Math.acos(1/s));r=[r[0],r[1],r[2],-a*n],i=function(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 Iy(n,s,new Py(o,a))}(i,Math.sqrt(s*s-1),t.cameraPosition)}}let n=function(t){let e=Lu(1,t.center.lat)*t.worldSize;return Ju(t.center,t.elevation,t.pitch,t.bearing,t.cameraToCenterDistance/e)}(t),s=qu.fromLngLat(t.center,t.elevation),o=function(t,e){let i=bt((15-(Vu-t.pitch-t.fov/2))/15,0,1),r=Math.max(500,e??0);return t.elevation+i*r}(t,e.maxContentElevation),a=t.getCoveringTilesDetailsProvider(),l=a.allowVariableZoom(t,e),h=Oy(t,e),u=e.minzoom||0,c=void 0===e.maxzoom?t.maxZoom:e.maxzoom,f=Math.min(Math.max(0,h),c),p=2**f,d=[p*n.x,p*n.y,0],m=[p*s.x,p*s.y,0],_=Math.hypot(s.x-n.x,s.y-n.y),g=Math.abs(s.z-n.z),y=Math.hypot(_,g),v=t=>({zoom:0,x:0,y:0,wrap:t,fullyVisible:!1}),w=[],b=[];if(t.renderWorldCopies&&a.allowWorldCopies())for(let t=1;t<=3;t++)w.push(v(-t)),w.push(v(t));for(w.push(v(0));w.length>0;){let p=w.pop(),_=p.x,v=p.y,x=p.fullyVisible,D={x:_,y:v,z:p.zoom},M=a.getTileBoundingVolume(D,p.wrap,o,e);if(!x){let t=ky(i,M,r);if(0===t)continue;x=2===t}let E=a.distanceToTile2d(n.x,n.y,D,M),A=h;l&&(A=(e.calculateTileZoom||Ry)(t.zoom+St(t.tileSize/e.tileSize),E,g,y,t.fov)),A=(e.roundZoom?Math.round:Math.floor)(A),A=Math.max(0,A);let F=Math.min(A,c);if(p.wrap=a.getWrap(s,D,p.wrap),p.zoom>=F){if(p.zoom<u)continue;let t=f-p.zoom,i=d[0]-.5-(_<<t),r=d[1]-.5-(v<<t),n=e.reparseOverscaled?Math.max(p.zoom,A):p.zoom;b.push({tileID:new nd(p.zoom===c?n:p.zoom,p.wrap,p.zoom,_,v),distanceSq:Q([m[0]-.5-_,m[1]-.5-v]),tileDistanceToCamera:Math.sqrt(i*i+r*r)})}else for(let t=0;t<4;t++)w.push({zoom:p.zoom+1,x:(_<<1)+t%2,y:(v<<1)+(t>>1),wrap:p.wrap,fullyVisible:x})}return b.sort(((t,e)=>t.distanceSq-e.distanceSq)).map((t=>t.tileID))}function Ly(t){return"raster"===t||"image"===t||"video"===t}function Uy(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 Ny(t,e,i,r,n,s){if(!e.hasData())return!1;let o=e.tileID.children(n),a=Gy(t,e,o,i,r,n,s);if(a)return!0;for(let l of o)Gy(t,e,l.children(n),i,r,n,s)&&(a=!0);return a}function Gy(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 qy(t,e,i,r){let n=t.tileID;return!!t.selfFading||!t.hasData()&&(!!e.has(n)&&(t.setSelfFadeLogic(i+r),!0))}function Vy(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 Zy=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(ld).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 l(r.canonical.x,r.canonical.y)._rotate(-t),o=new l(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(ld).map((t=>t.key))}},Wy=class t extends _e{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 uy;case"image":return wy;case"raster":return iy;case"raster-dem":return ry;case"vector":return ey;case"video":return xy;case"canvas":return Dy}return My[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 Zy,this._outOfViewCache=new k_(0,(t=>this._unloadTile(t))),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new Ty,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 Zy}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 me(it(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 Y_("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.map?this.map.painter:null);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=U_(),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||Vy(t,i),!i.neighboringTiles?.[t.tileID.key]?.backfilled&&Vy(i,t)}}(t,this._inViewTiles),t.featureStateRevision=-1,this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new Y_("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?re.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)&&n.layout){t=Math.max(t,n.layout.get("symbol-height-offset").constantOr(0));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 nd(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y))):(i=By(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 Y_("data",{sourceDataType:"idle",sourceId:this.id}));let n=Oy(t,this._source),s=this._updateRetainedTiles(i,n),o=Ly(this._source.type);o&&this._rasterFadeDuration>0&&!e&&function(t,e,i,r,n,s,o){let a=U_(),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(),!Uy(t,e,i,a,r,n,o)&&(Ny(t,e,i,a,s,o)||qy(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.map?this.map.painter:null));let i=e;return e||(e=new Cy(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 Y_("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=Mu.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*tt/i.tileSize/a;for(let t of o){let e=c.map((e=>t.getTilePoint(new qu(e.x,e.y))));if(e.expandBy(u),e.intersects(Eu)){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=Mu.fromPoints(t);i.shrinkBy(.001*Math.min(i.width(),i.height()));let n=i.map(e);Mu.fromPoints(r).covers(n)||(r=r.map((t=>t.x>.5?new qu(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()||Ly(this._source.type)&&function(t,e){if(e<=0)return!1;let i=U_();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||=hd,this._state.updateState(t,e,i)}removeFeatureState(t,e,i){t||=hd,this._state.removeFeatureState(t,e,i)}getFeatureState(t,e){return t||=hd,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}},Hy=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=bt(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 Yy(t,e,i,r,n){return n?t?t(e,i)+r:0===r?void 0:r:r}function Xy(t,e){let i=!0;return"always"===t||("never"===t||"never"===e)&&(i=!1),i}var Jy=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||!Xy(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||!Xy(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))&&!Xy(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))&&!Xy(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 Ky(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 Qy=m();function tv(t,e,i){let r=m();if(!t){let{vecSouth:t,vecEast:i}=iv(e),n=$_();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 b(r,r,[1/i,1/i,1]),r}function ev(t,e,i,r){if(t){let t=m();if(!e){let{vecSouth:e,vecEast:r}=iv(i);t[0]=r[0],t[1]=r[1],t[4]=e[0],t[5]=e[1]}return b(t,t,[r,r,1]),t}return i.pixelsToClipSpaceMatrix}function iv(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=H();o[0]=-n*r*i-s*e,o[1]=-s*r*i+n*e;let a=J(o);a<1e-9?K(o):X(o,o,1/a);let l=H();l[0]=n*r*e-s*i,l[1]=s*r*e+n*i;let h=J(l);return h<1e-9?K(l):X(l,l,1/h),{vecEast:l,vecSouth:o}}function rv(t,e,i){return Yy(t.getElevation,e,i,t.heightOffset??0,t.heightAnchorGround??!0)}function nv(t,e,i,r){let n;null==r?(n=[t,e,0,1],bv(n,n,i)):(n=[t,e,r,1],q(n,n,i));let s=n[3];return{point:new l(n[0]/s,n[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function sv(t,e){return.5+t/e*.5}function ov(t,e){return t.x>=-e[0]&&t.x<=e[0]&&t.y>=-e[1]&&t.y<=e[1]}function av(t,e,i,r,n,s,o,a,h,u,c,f,p){let d=i?t.textSizeData:t.iconSizeData,m=rp(d,e.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.transform.width/e.transform.height,b=!1;for(let i=0;i<v.length;i++){let x=v.get(i);if(x.hidden||2===x.writingMode&&!b){wv(x.numGlyphs,g);continue}b=!1;let D=new l(x.anchorX,x.anchorY),M={getElevation:p,pitchedLabelPlaneMatrix:r,lineVertexArray:y,pitchWithMap:s,projectionCache:{projections:{},offsets:{},cachedAnchorPoint:void 0,anyProjectionOccluded:!1},transform:e.transform,tileAnchorPoint:D,unwrappedTileID:h,width:u,height:c,translation:f},E=mv(x.anchorX,x.anchorY,M);if(!ov(E.point,_)){wv(x.numGlyphs,g);continue}let A=sv(e.transform.cameraToCenterDistance,E.signedDistanceFromCamera),F=ip(d,m,x),S=s?F*e.transform.getPitchedTextCorrection(x.anchorX,x.anchorY,h)/A:F*A,C=uv({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&&uv({projectionContext:M,pitchedLabelPlaneMatrixInverse:n,symbol:x,fontSize:S,flip:!0,keepUpright:o,glyphOffsetArray:t.glyphOffsetArray,dynamicLayoutVertexArray:g,aspectRatio:w,rotateToLine:a}).notEnoughRoom)&&wv(x.numGlyphs,g)}i?t.text.dynamicLayoutVertexBuffer.updateData(g):t.icon.dynamicLayoutVertexBuffer.updateData(g)}function lv(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=yv(t*c,i,r,n,s.segment,h,u,a,o);if(!p)return null;let d=yv(t*f,i,r,n,s.segment,h,u,a,o);return!d||a.projectionCache.anyProjectionOccluded?null:{first:p,last:d}}function hv(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 uv(t){let e,{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:s,flip:o,keepUpright:a,glyphOffsetArray:h,dynamicLayoutVertexArray:u,aspectRatio:c,rotateToLine:f}=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,l=n.lineStartIndex+n.lineLength,u=lv(p,h,d,m,o,n,f,i);if(!u)return{notEnoughRoom:!0};let _=dv(u.first.point.x,u.first.point.y,i,r),g=dv(u.last.point.x,u.last.point.y,i,r);if(a&&!o){let t=hv(n.writingMode,_,g,c);if(t)return t}e=[u.first];for(let r=n.glyphStartIndex+1;r<t-1;r++){let t=yv(p*h.getoffsetX(r),d,m,o,n.segment,s,l,i,f);if(!t)return{notEnoughRoom:!0};e.push(t)}e.push(u.last)}else{if(a&&!o){let t=pv(i.tileAnchorPoint.x,i.tileAnchorPoint.y,i).point,e=n.lineStartIndex+n.segment+1,s=new l(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),o=pv(s.x,s.y,i),a=o.signedDistanceFromCamera>0?o.point:cv(i.tileAnchorPoint,s,t,1,i),h=dv(t.x,t.y,i,r),u=dv(a.x,a.y,i,r),f=hv(n.writingMode,h,u,c);if(f)return f}let t=yv(p*h.getoffsetX(n.glyphStartIndex),d,m,o,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,f);if(!t||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};e=[t]}for(let t of e)jp(u,t.point,t.angle);return{}}function cv(t,e,i,r,n){let s=t.add(t.sub(e)._unit()),o=pv(s.x,s.y,n).point,a=i.sub(o);return i.add(a._mult(r/a.mag()))}function fv(t,e,i){let r=e.projectionCache;if(r.projections[t])return r.projections[t];let n=new l(e.lineVertexArray.getx(t),e.lineVertexArray.gety(t)),s=pv(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 cv(0===i.distanceFromAnchor?e.tileAnchorPoint:new l(e.lineVertexArray.getx(o),e.lineVertexArray.gety(o)),n,i.previousVertex,i.absOffsetX-i.distanceFromAnchor+1,e)}function pv(t,e,i){let r,n=t+i.translation[0],s=e+i.translation[1];return i.pitchWithMap?(r=nv(n,s,i.pitchedLabelPlaneMatrix,rv(i,n,s)),r.isOccluded=!1):(r=i.transform.projectTileCoordinates(n,s,i.unwrappedTileID,rv(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 dv(t,e,i,r){if(i.pitchWithMap){let n=[t,e,0,1];q(n,n,r);let s=n[0]/n[3],o=n[1]/n[3];return i.transform.projectTileCoordinates(s,o,i.unwrappedTileID,rv(i,s,o)).point}return{x:t/i.width*2-1,y:1-e/i.height*2}}function mv(t,e,i){return i.transform.projectTileCoordinates(t,e,i.unwrappedTileID,rv(i,t,e))}function _v(t,e,i){return t._unit()._perp()._mult(e*i)}function gv(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=fv(t+l.direction,a,l),c=_v(u.sub(i),o,l.direction),f=i.add(c),p=u.add(c);return a.projectionCache.offsets[t]=Rt(s,h,f,p)||h,a.projectionCache.offsets[t]}function yv(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=pv(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=fv(p,a,t),0===i)x.push(y),_=g.sub(y);else{let e,r=g.sub(y);e=0===r.mag()?_v(fv(p+u,a,t).sub(g),i,u):_v(r,i,u),m||=y.add(e),d=gv(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 vv=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function wv(t,e){for(let i=0;i<t;i++){let t=e.length;e.resize(t+4),e.float32.set(vv,3*t)}}function bv(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 xv=class{constructor(t,e=new Jy(t.width+200,t.height+200,25),i=new Jy(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,Yy(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,h,u,c,f,p,d){let m=[],_=new l(e.anchorX,e.anchorY),g=this.getPerspectiveRatio(_.x,_.y,s,d?.(_.x,_.y)),y=(h?n*this.transform.getPitchedTextCorrection(e.anchorX,e.anchorY,s)/g:n*g)/24,v={getElevation:d,pitchedLabelPlaneMatrix:o,lineVertexArray:i,pitchWithMap:h,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=lv(y,r,e.lineOffsetX*y,e.lineOffsetY*y,!1,e,!1,v),b=!1,x=!1,D=!0;if(w){let e=.5*c*g+f,i=new l(-100,-100),r=new l(this.screenRightBoundary,this.screenBottomBoundary),n=new Hy,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(h){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?[]:fp([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,h=o.y+100;m.push(l,h,e,0);let c=l-e,f=h-e,p=l+e,d=h+e;if(D&&=this.isOffscreen(c,f,p,d),x||=this.isInsideGrid(c,f,p,d),"always"!==t&&this.grid.hitTestCircle(l,h,e,t,u)&&(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=Qy;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=nv(t.x,t.y,i,rv(e,t.x,t.y)),n=e.transform.projectTileCoordinates(r.point.x,r.point.y,e.unwrappedTileID,rv(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 Mu;for(let r of t){let t=new l(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)),h={},u={};for(let t of a){let i=t.key;void 0===h[i.bucketInstanceId]&&(h[i.bucketInstanceId]={}),h[i.bucketInstanceId][i.featureIndex]||Ml(e,[new l(t.x1,t.y1),new l(t.x2,t.y1),new l(t.x2,t.y2),new l(t.x1,t.y2)])&&(h[i.bucketInstanceId][i.featureIndex]=!0,void 0===u[i.bucketInstanceId]&&(u[i.bucketInstanceId]=[]),u[i.bucketInstanceId].push(i.featureIndex))}return u}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],bv(i,i,n)):(i=[t,e,r,1],q(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=g([]);return w(t,t,[-100,-100,0]),t}_projectCollisionBox(t,e,i,r,n,s,o,a,h,u,c,f=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,Yy(h,y+1,v,f,p),c),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=iv(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),!u)&&(x*=bt(.5+a.signedDistanceFromCamera/this.transform.cameraToCenterDistance*.5,0,4)),u&&(w+=d*u.x*x+_*u.y*x,b+=m*u.x*x+g*u.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 l(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,Yy(h,t.x,t.y,f,p),c)));T=t.some((t=>!t.isOccluded)),z=t.map((t=>new l(t.x,t.y)))}else T=!0;return{box:yt(z),allPointsOccluded:!T}}},Dv=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}},Mv=class{constructor(t,e,i,r,n){this.text=new Dv(t?t.text:null,e,i,n),this.icon=new Dv(t?t.icon:null,e,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}},Ev=class{constructor(t,e,i){this.text=t,this.icon=e,this.skipFade=i}},Av=class{constructor(t,e,i,r,n){this.bucketInstanceId=t,this.featureIndex=e,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}},Fv=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 Sv(t,e,i,r,n){let{horizontalAlign:s,verticalAlign:o}=Lf(t);return new l(-(s-.5)*e+r[0]*n,-(o-.5)*i+r[1]*n)}var Cv=class{constructor(t,e,i,r,n){this.transform=t.clone(),this.terrain=e,this.collisionIndex=new xv(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new Fv(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,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/tt,c=i.tileID.toUnwrapped(),f="map"===a.get("text-rotation-alignment"),p=et(i,1,this.transform.zoom),d=lt(this.collisionIndex.transform,i,l.get("text-translate"),l.get("text-translate-anchor")),m=lt(this.collisionIndex.transform,i,l.get("icon-translate"),l.get("icon-translate-anchor")),_=tv(f,this.transform,p);this.retainedQueryData[n.bucketInstanceId]=new Av(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:rp(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=Mp[t.textAnchor],D=[t.textOffset0,t.textOffset1],M=Sv(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"),_=Ip(n,"text-overlap","text-allow-overlap"),g="always"===_,y=Ip(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 Ev(!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=Mp[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=ip(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&&$t("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 Ev((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}[Sp(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 Mv(s,r,e.text,e.icon),i||=e.text!==s.text.placed,i||=e.icon!==s.icon.placed):(this.opacities[t]=new Mv(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 Mv(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);e&&r.latestFeatureIndex&&t.id===e.layerIds[0]&&this.updateBucketOpacities(e,r.tileID,i,r.collisionBoxArray)}}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 Mv(null,0,!1,!1,!0),a=s.get("text-allow-overlap"),h=s.get("icon-allow-overlap"),u=n._unevaluatedLayout.hasValue("text-variable-anchor")||n._unevaluatedLayout.hasValue("text-variable-anchor-offset"),c="map"===s.get("text-rotation-alignment"),f="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),d=new Mv(null,0,a&&(h||!t.hasIconData()||s.get("icon-optional")),h&&(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||=i!==jv},_=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,h=this.opacities[a];i[a]?h=o:h||(h=d,this.opacities[a]=h),i[a]=!0;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=$v(h.text);m(t.text,n,v?jv:e),m(t.text,s,w?jv:e);let i=h.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 l=this.placedOrientations[r.crossTileID];l&&(this.markUsedJustification(t,"left",r,l),this.markUsedOrientation(t,l,r))}if(g){let e=$v(h.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&v);r.placedIconSymbolIndex>=0&&(m(t.icon,r.numIconVertices,i?e:jv),t.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=h.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(t.icon,r.numVerticalIconVertices,i?jv:e),t.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=h.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 l(0,0);if(i.textBox||i.verticalTextBox){let r=!0;if(u){let t=this.variableOffsets[a];t?(e=Sv(t.anchor,t.width,t.height,t.textOffset,t.textBoxScale),c&&e._rotate(f?-this.transform.bearingInRadians:this.transform.bearingInRadians)):r=!1}if(i.textBox||i.verticalTextBox){let n;i.textBox&&(n=v),i.verticalTextBox&&(n=w),zv(t.textCollisionBox.collisionVertexArray,h.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),zv(t.iconCollisionBox.collisionVertexArray,h.icon.placed,r,b.icon,p?e.x:0,p?e.y:0)}}}}if(t.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw 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 zv(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 Tv=2**25,Pv=2**24,Iv=2**17,kv=65536;function $v(t){if(0===t.opacity&&!t.placed)return 0;if(1===t.opacity&&t.placed)return 4294967295;let e=+!!t.placed,i=Math.floor(127*t.opacity);return i*Tv+e*Pv+i*Iv+e*kv+512*i+256*e+2*i+e}const jv=0;var Rv=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}},Ov=class{constructor(t,e,i,r,n,s,o,a){this.placement=new Cv(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=U_(),n=()=>!this._forceFullPlacement&&U_()-r>2;for(;this._currentPlacementIndex>=0;){let r=e[t[this._currentPlacementIndex]],s=this.placement.collisionIndex.transform.zoom;if(Vp(r)&&r.layout&&(!r.minzoom||r.minzoom<=s)&&(!r.maxzoom||r.maxzoom>s)){if(this._inProgressLayer||=new Rv(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 Bv=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Lv=new Uint32Array(96);var Uv=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=Bv[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=Bv.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 Nv(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;Lv[0]=0,Lv[1]=n.length-1,Lv[2]=0;let a=3,l=[];for(;a>0;){let h=Lv[--a],u=Lv[--a],c=Lv[--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)&&(Lv[a++]=c,Lv[a++]=f-1,Lv[a++]=1-h),(0===h?i>=p:r>=d)&&(Lv[a++]=f+1,Lv[a++]=u,Lv[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;Lv[0]=0,Lv[1]=n.length-1,Lv[2]=0;let a=3,l=0,h=i*i;for(;a>0;){let u=Lv[--a],c=Lv[--a],f=Lv[--a];if(c-f<=o){for(let i=f;i<=c;i++)Zv(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];Zv(d,m,t,e)<=h&&(r[l++]=n[p]),(0===u?t-i<=d:e-i<=m)&&(Lv[a++]=f,Lv[a++]=p-1,Lv[a++]=1-u),(0===u?t+i>=d:e+i>=m)&&(Lv[a++]=p+1,Lv[a++]=c,Lv[a++]=1-u)}return l}};function Nv(t,e,i,r,n,s){if(n-r<=i)return;let o=r+n>>1;Gv(t,e,o,r,n,s),Nv(t,e,i,r,o-1,1-s),Nv(t,e,i,o+1,n,1-s)}function Gv(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);Gv(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(qv(t,e,r,i),e[2*n+s]>o&&qv(t,e,r,n);a<l;){for(qv(t,e,a,l),a++,l--;e[2*a+s]<o;)a++;for(;e[2*l+s]>o;)l--}e[2*r+s]===o?qv(t,e,r,l):(l++,qv(t,e,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function qv(t,e,i,r){Vv(t,i,r),Vv(e,2*i,2*r),Vv(e,2*i+1,2*r+1)}function Vv(t,e,i){let r=t[e];t[e]=t[i],t[i]=r}function Zv(t,e,i,r){let n=t-i,s=e-r;return n*n+s*s}const Wv=.03125;var Hv=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*Wv),y:Math.floor(t.anchorY*Wv)}))),crossTileIDs:e.map((t=>t.crossTileID))};if(i.positions.length>128){let t=new Uv(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=Wv/2**(a-n),h=(o*tt+t.anchorY)*l,u=r*tt*Wv;return{x:Math.floor((s*tt+t.anchorX)*l-i*tt*Wv),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))}},Yv=class{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}},Xv=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 Hv(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}},Jv=class{constructor(){this.layerIndexes={},this.crossTileIDs=new Yv,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(t,e,i){let r=this.layerIndexes[t.id];void 0===r&&(r=this.layerIndexes[t.id]=new Xv);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]}},Kv="void main() {fragColor=vec4(1.0);}";const Qv={prelude:tw("#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+2.0;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:tw("\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:tw("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:tw("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);}"),backgroundPattern:tw("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);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:tw("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:tw(Kv,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:tw("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:tw("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:tw("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:tw("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:tw("#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:tw("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:tw(Kv,"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:tw("#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:tw("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:tw("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:tw("#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:tw("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);\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.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:tw("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;\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.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:tw("#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+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;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:tw("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec2 size=vec2(textureSize(u_image,0));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*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;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:tw("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;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);float a_direction=float(int(a_data.z & 3u)-1);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 float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:tw("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 float a_uv_x;layout(location=3) 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);float a_direction=float(int(a_data.z & 3u)-1);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 float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:tw("#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;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_direction=float(int(a_data.z & 3u)-1);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 float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:tw("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;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_direction=float(int(a_data.z & 3u)-1);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 float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:tw("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 float a_uv_x;layout(location=3) 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_direction=float(int(a_data.z & 3u)-1);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 float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),layerOpacity:tw("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:tw("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:tw("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:tw("#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:tw("#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:tw("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:tw("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;}"),atmosphere:tw("#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:tw("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;in vec3 v_view_direction;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (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*u_device_pixel_ratio,u_sky_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(fragColor,vec4(vec3(0.0),0.0),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 tw(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",iw="mercator";var rw=class{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return iw}get shaderDefine(){return ew}get shaderPreludeCode(){return Qv.projectionMercator}get vertexShaderPreludeCode(){return Qv.projectionMercator.vertexSource}get subdivisionGranularity(){return au.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 ga;s.emplaceBack(0,0),s.emplaceBack(tt,0),s.emplaceBack(0,tt),s.emplaceBack(tt,tt);let o=t.createVertexBuffer(s,gy.members),a=Oa.simpleSegment(0,0,4,2),l=new ka;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let h=t.createIndexBuffer(l);return this._cachedMesh=new _y(o,h,a),this._cachedMesh}recalculate(){}hasTransition(){return!1}},nw=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=ji.number(t.top,e.top,i)),null!=e.bottom&&null!=t.bottom&&(this.bottom=ji.number(t.bottom,e.bottom,i)),null!=e.left&&null!=t.left&&(this.left=ji.number(t.left,e.left,i)),null!=e.right&&null!=t.right&&(this.right=ji.number(t.right,e.right,i)),this}getCenter(t,e){return new l(bt((this.left+t-this.right)/2,0,t),bt((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 sw(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 ow(t){return Math.max(0,Math.floor(t))}var aw=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 $u(0,0),this._elevation=0,this._zoom=0,this._tileZoom=ow(this._zoom),this._scale=Ft(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new nw,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(t,e,i){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=ow(this._zoom),this._scale=Ft(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 nw(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=!i&&t.autoCalculateNearFarZ,e&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(t){this._minElevationForCurrentTile=t}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(t){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 l(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(t){let e=xt(t,-180,180)*Math.PI/180;this._bearingInRadians!==e&&(this._unmodified=!1,this._bearingInRadians=e,this._calcMatrices(),this._rotationMatrix=$_(),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=bt(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 Gt(this._fovInRadians)}setFov(t){t=bt(t,.1,150),this.fov!==t&&(this._unmodified=!1,this._fovInRadians=Nt(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=Ft(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._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 Qg([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=[-Wt,Wt])}getCameraQueryGeometry(t,e){if(1===e.length)return[e[0],t];{let{minX:i,minY:r,maxX:n,maxY:s}=Mu.fromPoints(e).extend(t);return[new l(i,r),new l(n,r),new l(n,s),new l(i,s),new l(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=Lu(1,this.center.lat)*this.worldSize,!this._width||!this._height)return;this._pixelsToGLUnits=[2/this._width,-2/this._height];let t=g(new Float64Array(16));b(t,t,[this._width/2,-this._height/2,1]),w(t,t,[1,-1,0]),this._clipSpaceToPixelsMatrix=t,t=g(new Float64Array(16)),b(t,t,[1,-1,1]),w(t,t,[-1,-1,0]),b(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,s,o=void 0===i?this.bearing:i,a=r=void 0===r?this.pitch:r,{distanceToCenter:l,clampedElevation:h}=this._distanceToCenterFromAltElevationPitch(e,this.elevation,a),{x:u,y:c}=Ku(a,o),f=qu.fromLngLat(t,e),p=Gu(1,f.y),d=0;do{if(d+=1,d>10)break;s=l/p,n=new qu(f.x+u*s,f.y+c*s),p=1/n.meterInMercatorCoordinateUnits()}while(Math.abs(l-s*p)>1e-12);return{center:n.toLngLat(),elevation:h,zoom:St(this.height/2/Math.tan(this.fovInRadians/2)/s/this.tileSize)}}recalculateZoomAndCenter(t){if(this.elevation-t==0)return;let e=1/this.worldSize,i=Lu(1,this.center.lat)*this.worldSize,r=qu.fromLngLat(this.center,this.elevation),n=r.x/e,s=r.y/e,o=r.z/e,a=this.pitch,l=this.bearing,{x:h,y:u,z:c}=Ku(a,l),f=this.cameraToCenterDistance,p=n+f*-h,d=s+f*-u,m=o+f*c,{distanceToCenter:_,clampedElevation:g}=this._distanceToCenterFromAltElevationPitch(m/i,t,a),y=_*i,v=new qu((p+h*y)*e,(d+u*y)*e,0).toLngLat(),w=Lu(1,v.lat),b=St(this.height/2/Math.tan(this.fovInRadians/2)/_/w/this.tileSize);this._elevation=g,this._center=v,this.setZoom(b)}_distanceToCenterFromAltElevationPitch(t,e,i){let r,n=-Math.cos(Nt(i)),s=t-e,o=e;return n*s>=0||Math.abs(n)<.1?(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 l(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/tt,1/e/tt]}},lw=class{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 nd(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 Py([e+t.x/o,t.y/o,n],[e+(t.x+1)/o,(t.y+1)/o,s])}allowVariableZoom(t,e){let i=bt(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 hw=Io([{name:"a_pos3d",type:"Int16",components:3}]);var uw=class extends _e{constructor(t){super(),this._lastTilesetChange=U_(),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 By(t,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:e,calculateTileZoom:this.tileManager._source.calculateTileZoom}))i[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float32Array(16),A(n.terrainRttPosMatrix32f,0,tt,tt,0,0,1),this._tiles[n.key]=new Cy(n,this.tileSize),this._lastTilesetChange=U_(),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=st();if(r.canonical.equals(t.canonical))A(s,0,tt,tt,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=tt>>e;A(s,0,o,o,0,0,1),w(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=tt>>e;A(s,0,tt,tt,0,0,1),w(s,s,[i*o,n*o,0]),b(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=st();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;A(o,0,tt,tt,0,0,1),w(o,o,[e*tt,i*tt,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=tt>>e;A(o,0,l,l,0,0,1),w(o,o,[-i*l+s*tt,-r*l+a*tt,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=tt<<e;A(o,0,l,l,0,0,1),w(o,o,[i*tt+s*l,r*tt+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=U_()){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)}};const cw=tt*(1-1e-12);var fw=class{constructor(t,e,i,r="auto"){this._meshCache={},this.painter=t,this.tileManager=new uw(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._elevationSamplerCache=new Map}destroy(){this._fbo&&=(this._fbo.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=tt){let n=t.normalizeCoordinates(e,i,r);if(!n)return 0;let s=this.getElevationSampler(n.tileID);return s?s(n.x,n.y,r):0}getElevationForLngLatZoom(t,e){if(!ed(e,t.wrap()))return 0;let{tileID:i,mercatorX:r,mercatorY:n}=this._getOverscaledTileIDFromLngLatZoom(t,e);return this.getElevation(i,r%tt,n%tt,tt)}getElevationForLngLat(t,e){let i=this.getCoverageIndex();if(i){let e=qu.fromLngLat(t),r=dw(i,this.exaggeration,e.x,e.y);if(r.demLoaded)return r.elevation}let r=By(e,{maxzoom:this.tileManager.maxzoom,minzoom:this.tileManager.minzoom,tileSize:512,terrain:this}),n=0;for(let t of r)t.canonical.z>n&&(n=Math.min(t.canonical.z,this.tileManager.maxzoom));return this.getElevationForLngLatZoom(t,n)}getElevation(t,e,i,r=tt){return this.getDEMElevation(t,e,i,r)*this.exaggeration}resetElevationCache(){this._elevationSamplerCache.clear(),this._coverageIndex=void 0}getCoverageIndex(){return void 0===this._coverageIndex&&(this._coverageIndex=this._buildCoverageIndex()),this._coverageIndex}_buildCoverageIndex(){let t=[],e=new Map,i=0,r=0;for(let n of this.tileManager.getRenderableTiles()){if(!n)continue;let{canonical:s,wrap:o}=n.tileID;t.includes(s.z)||t.push(s.z);let a=this.getElevationSampler(n.tileID);e.set(`${o}/${s.z}/${s.x}/${s.y}`,a);let{minElevation:l,maxElevation:h}=this.getMinMaxElevation(n.tileID);i=Math.min(i,l??0),r=Math.max(r,h??0)}return 0===e.size?null:(t.sort(((t,e)=>e-t)),{zooms:t,samplerPerTile:e,minElevation:i-10,maxElevation:r+10})}getElevationSampler(t){let e=t.key,i=this._elevationSamplerCache.get(e);if(i)return i;let r=this.tileManager.getSourceTile(t,!0),n=r?.dem;if(!r||!n)return null;let s=this._getDEMTileMatrix(t,r),o=s[0]*n.dim,a=s[5]*n.dim,l=s[12]*n.dim,h=s[13]*n.dim,u=(t,e,i)=>{let r=8192===i?1:tt/i;return n.sampleBilinear(t*r*o+l,e*r*a+h)};return this._elevationSamplerCache.set(e,u),u}_getDEMTileMatrix(t,e){let i=`${e.tileID.key}/${t.key}`,r=this._demMatrixCache.get(i);if(r)return r;let n=this.tileManager.getSource().maxzoom,s=t.canonical.z-e.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=n?s=t.canonical.z-n:$t("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let o=t.canonical.x-(t.canonical.x>>s<<s),a=t.canonical.y-(t.canonical.y>>s<<s),l=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/(tt<<s),1/(tt<<s),0]);return w(l,l,[o*tt,a*tt,0]),this._demMatrixCache.set(i,l),l}getTerrainData(t){if(!this._emptyDemTexture){let t=this.painter.context,e=new rh({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new dh(t,e,t.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new dh(t,new rh({width:1,height:1}),t.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=g([])}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 dh(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 dh(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}depthAtPoint(t){let e=new Uint8Array(4),i=this.painter.context,r=i.gl;return i.bindFramebuffer.set(this.getFramebuffer().framebuffer),r.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,r.RGBA,r.UNSIGNED_BYTE,e),i.bindFramebuffer.set(null),(e[0]/16777216+e[1]/65536+e[2]/256+e[3])/256}getTerrainMesh(t){let e=this.painter.style.projection?.transitionState>0,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 ya,a=new ka,l=this.meshSize,h=tt/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 _y(s.createVertexBuffer(o,hw.members),s.createIndexBuffer(a),Oa.simpleSegment(0,0,o.length,a.length));return this._meshCache[n]=c,c}getSkirtLength(t){return 2*Math.PI*ku/2**Math.max(t,0)/5}getMinTileElevationForLngLatZoom(t,e){if(!ed(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=qu.fromLngLat(t.wrap()),r=(1<<e)*tt,n=i.x*r,s=i.y*r,o=Math.floor(n/tt),a=Math.floor(s/tt);return{tileID:new nd(e,0,e,o,a),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?lu:0,u=+!n,c=s?hu:tt,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*tt,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 pw={covered:!1,demLoaded:!1,elevation:0};function dw(t,e,i,r){if(r<0||r>=1)return pw;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)*tt,cw),Math.min((l-u)*tt,cw),tt)*e}:{covered:!0,demLoaded:!1,elevation:0}}return pw}function mw(t,e){return t.covered&&e<=t.elevation+1e-6}function _w(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 gw=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){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(t,e)=>{e=bt(+e,this.minZoom,this.maxZoom);let i={center:new $u(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*Ft(i.zoom),s=0,o=n,a=0,h=n,u=0,c=0,{x:f,y:p}=this.size;if(this._helper._latRange){let t=this._helper._latRange;s=Bu(t[1])*n,o=Bu(t[0])*n,o-s<p&&(u=p/(o-s))}r&&(a=xt(Ou(r[0])*n,0,n),h=xt(Ou(r[1])*n,0,n),h<a&&(h+=n),h-a<f&&(c=f/(h-a)));let d,m,{x:_,y:g}=Wu(n,t),y=Math.max(c||0,u||0);if(y){let t=new l(c?(h+a)/2:_,u?(o+s)/2:g);return i.center=Hu(n,t).wrap(),i.zoom+=St(y),i}if(this._helper._latRange){let t=p/2;g-t<s&&(m=s+t),g+t>o&&(m=o-t)}if(r){let t=(a+h)/2,e=_;this._helper._renderWorldCopies&&(e=xt(_,t-n/2,t+n/2));let i=f/2;e-i<a&&(d=a+i),e+i>h&&(d=h-i)}if(void 0!==d||void 0!==m){let t=new l(d??_,m??g);i.center=Hu(n,t).wrap()}return i},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new aw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new lw}clone(){let e=new t;return e.apply(this,!1),e}apply(t,e,i){this._helper.apply(t,e,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(t){let e=[new rd(0,t)];if(this._helper._renderWorldCopies){let i=this.screenPointToMercatorCoordinate(new l(0,0)),r=this.screenPointToMercatorCoordinate(new l(this._helper._width,0)),n=this.screenPointToMercatorCoordinate(new l(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new l(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 rd(i,t))}return e}getCameraFrustum(){return Iy.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){let e=this.screenPointToLocation(this.centerPoint,t),i=t?t.getElevationForLngLat(e,this):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(t,e,i=this.elevation){let r=this.screenPointToMercatorCoordinateAtZ(e,i-this.elevation),n=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,0),s=qu.fromLngLat(t),o=new qu(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(qu.fromLngLat(t),e.getElevationForLngLat(t,this),this._pixelMatrix3D):this.coordinatePoint(qu.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)}screenTerrainPointToMercatorCoordinate(t,e){let i=e.getCoverageIndex();if(!i)return null;let{near:r,far:n}=this.getRaySegmentFromPixel(t),s=this.worldSize,o=n[0]-r[0],a=n[1]-r[1],l=n[2]-r[2],h={index:i,exaggeration:e.exaggeration,near:r,dx:o,dy:a,dz:l,worldSize:s},u=0,c=1;if(0===l){if(r[2]>i.maxElevation||r[2]<i.minElevation)return null}else{let t=(i.maxElevation-r[2])/l,e=(i.minElevation-r[2])/l;if(u=Math.max(u,Math.min(t,e)),c=Math.min(c,Math.max(t,e)),u>c)return null}let f=Math.hypot(o,a),p=bt(Math.ceil(f*(c-u)/4),1,512),d=0,m=!vw(h,0);for(let t=0;t<=p;t++){let e=u+(c-u)*t/p;if(m){if(vw(h,e)){let{lo:t,hi:i}=_w(h,vw,d,e,.001/f),n=yw(h,t),u=yw(h,i),c=r[2]+t*l-n.elevation,p=r[2]+i*l-u.elevation,m=n.covered&&c>p?bt(t+c*(i-t)/(c-p),t,i):i;return new qu((r[0]+m*o)/s,(r[1]+m*a)/s,yw(h,m).elevation)}}else m=!vw(h,e);d=e}return null}getRaySegmentFromPixel(t){let e=[t.x,t.y,0,1],i=[t.x,t.y,1,1];q(e,e,this._pixelMatrixInverse),q(i,i,this._pixelMatrixInverse);let r=e[3],n=i[3],s=this.elevation;return{near:[e[0]/r,e[1]/r,e[2]/r+s],far:[i[0]/n,i[1]/n,i[2]/n+s]}}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 qu(ji.number(r[0],n[0],s)/this.worldSize,ji.number(r[1],n[1],s)/this.worldSize,i)}coordinatePoint(t,e=0,i=this._pixelMatrix){let r=[t.x*this.worldSize,t.y*this.worldSize,e,1];return q(r,r,i),new l(r[0]/r[3],r[1]/r[3])}getBounds(){let t=Math.max(0,this._helper._height/2-Yu(this));return(new Qg).extend(this.screenPointToLocation(new l(0,t))).extend(this.screenPointToLocation(new l(this._helper._width,t))).extend(this.screenPointToLocation(new l(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new l(0,this._helper._height)))}isPointOnMapSurface(t,e){return e?null!=this.screenTerrainPointToMercatorCoordinate(t,e):t.y>this.height/2-Yu(this)}calculatePosMatrix(t,e=!1,i=!1){let r=t.key??sd(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=Xu(t,this.worldSize);v(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=Xu(t,this.worldSize);return v(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=qu.fromLngLat(t,e),s=qu.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=St(this.cameraToCenterDistance/h/this.tileSize),f=Gt(Math.atan2(o,-a)),p=Gt(Math.acos(u/h));return p=l<0?90-p:90+p,{center:s.toLngLat(),elevation:r,zoom:c,pitch:p,bearing:f}}_calculateNearFarZIfNeeded(t,e,i){if(!this._helper.autoCalculateNearFarZ)return;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=Nt(this.fov)*(Math.abs(Math.cos(Nt(this.roll)))*this.height+Math.abs(Math.sin(Nt(this.roll)))*this.width)/this.height*(.5+i.y/this.height),l=Math.sin(a)*s/Math.sin(bt(Math.PI-o-a,.01,Math.PI-.01)),h=Yu(this),u=Math.atan(h/this._helper.cameraToCenterDistance),c=Nt(.75),f=u>c?2*u*(.5+i.y/(2*h)):c,p=Math.sin(f)*s/Math.sin(bt(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(){let t,e=this.centerOffset,i=Wu(this.worldSize,this.center),r=i.x,n=i.y,s=Nt(Math.min(this.pitch,Vu)),o=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(s));this._calculateNearFarZIfNeeded(o,s,e),t=new Float64Array(16),E(t,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,t),t[8]=2*-e.x/this._helper._width,t[9]=2*e.y/this._helper._height,this._projectionMatrix=_(t),b(t,t,[1,-1,1]),w(t,t,[0,0,-this._helper.cameraToCenterDistance]),M(t,t,-this.rollInRadians),x(t,t,this.pitchInRadians),M(t,t,-this.bearingInRadians),w(t,t,[-r,-n,0]),this._mercatorMatrix=b([],t,[this.worldSize,this.worldSize,this.worldSize]),b(t,t,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=v(new Float64Array(16),this.clipSpaceToPixelsMatrix,t),w(t,t,[0,0,-this.elevation]),this._viewProjMatrix=t,this._invViewProjMatrix=y([],t);let a=[0,0,-1,1];q(a,a,this._invViewProjMatrix),this._cameraPosition=[a[0]/a[3],a[1]/a[3],a[2]/a[3]],this._fogMatrix=new Float64Array(16),E(this._fogMatrix,this.fovInRadians,this.width/this.height,o,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,b(this._fogMatrix,this._fogMatrix,[1,-1,1]),w(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),M(this._fogMatrix,this._fogMatrix,-this.rollInRadians),x(this._fogMatrix,this._fogMatrix,this.pitchInRadians),M(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),w(this._fogMatrix,this._fogMatrix,[-r,-n,0]),b(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),w(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=v(new Float64Array(16),this.clipSpaceToPixelsMatrix,t);let l=this._helper._width%2/2,h=this._helper._height%2/2,u=Math.cos(this.bearingInRadians),c=Math.sin(-this.bearingInRadians),f=r-Math.round(r)+u*l+c*h,p=n-Math.round(n)+u*h+c*l,d=new Float64Array(t);if(w(d,d,[f>.5?f-1:f,p>.5?p-1:p,0]),this._alignedProjMatrix=d,t=y(new Float64Array(16),this._pixelMatrix),!t)throw Error("failed to invert matrix");this._pixelMatrixInverse=t,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;let t=this.screenPointToMercatorCoordinate(new l(0,0)),e=[t.x*this.worldSize,t.y*this.worldSize,0,1];return q(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=Lu(1,this.center.lat)*this.worldSize;return Ju(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/t).toLngLat()}lngLatToCameraDepth(t,e){let i=qu.fromLngLat(t),r=[i.x*this.worldSize,i.y*this.worldSize,e,1];return q(r,r,this._viewProjMatrix),r[2]/r[3]}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||at(),{mainMatrix:e,tileMercatorCoords:s,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:e,clipAntimeridian:!1}}isLocationOccluded(t){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(t,e,i){return 1}transformLightDirection(t){return S(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],bv(n,n,s)):(n=[t,e,r,1],q(n,n,s));let o=n[3];return{point:new l(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 nd(0,0,0,0,0),i=this.getProjectionData({overscaledTileID:e,applyGlobeMatrix:t}),r=Xu(e,this.worldSize);v(r,this._viewProjMatrix,r);let n=[tt,tt,this.worldSize/this._helper.pixelsPerMeter],s=st();return b(s,r,n),{...i,tileMercatorCoords:[0,0,1,1],fallbackMatrix:s,mainMatrix:s}}getFastPathSimpleProjectionMatrix(t){return this.calculatePosMatrix(t)}};function yw(t,e){return dw(t.index,t.exaggeration,(t.near[0]+e*t.dx)/t.worldSize,(t.near[1]+e*t.dy)/t.worldSize)}function vw(t,e){return mw(yw(t,e),t.near[2]+e*t.dz)}function ww(){$t("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function bw(t){if(t.useSlerp)if(t.k<1){let e=Zt(t.startEulerAngles.roll,t.startEulerAngles.pitch,t.startEulerAngles.bearing),i=Zt(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=Gt(-Math.asin(bt(e[2],-1,1)));return Math.hypot(e[5],e[8])<.001?(i=0,r=-Gt(Math.atan2(e[3],e[4]))):(i=Gt(0===e[5]&&0===e[8]?0:Math.atan2(e[5],e[8])),r=Gt(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(ji.number(t.startEulerAngles.roll,t.endEulerAngles.roll,t.k)),t.tr.setPitch(ji.number(t.startEulerAngles.pitch,t.endEulerAngles.pitch,t.k)),t.tr.setBearing(ji.number(t.startEulerAngles.bearing,t.endEulerAngles.bearing,t.k))}function xw(t,e,i,r,n){let s=n.padding,o=Wu(n.worldSize,i.getNorthWest()),a=Wu(n.worldSize,i.getNorthEast()),h=Wu(n.worldSize,i.getSouthEast()),u=Wu(n.worldSize,i.getSouthWest()),c=Nt(-r),f=o.rotate(c),p=a.rotate(c),d=h.rotate(c),m=u.rotate(c),_=new l(Math.max(f.x,p.x,m.x,d.x),Math.max(f.y,p.y,m.y,d.y)),g=new l(Math.min(f.x,p.x,m.x,d.x),Math.min(f.y,p.y,m.y,d.y)),y=_.sub(g),v=(n.width-(s.left+s.right+e.left+e.right))/y.x,w=(n.height-(s.top+s.bottom+e.top+e.bottom))/y.y;if(w<0||v<0)return void ww();let b=Math.min(St(n.scale*Math.min(v,w)),t.maxZoom),x=l.convert(t.offset),D=new l((e.left-e.right)/2,(e.top-e.bottom)/2).rotate(Nt(r)),M=x.add(D).mult(n.scale/Ft(b));return{center:Hu(n.worldSize,o.add(h).div(2).sub(M)),zoom:b,bearing:r}}var Dw=class{get useGlobeControls(){return!1}handlePanInertia(t,e){let i=t.mag(),r=Math.abs(Yu(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){return xw(t,e,i,r,n)}handleJumpToCenterZoom(t,e){t.zoom!==(void 0===e.zoom?t.zoom:+e.zoom)&&t.setZoom(+e.zoom),void 0!==e.center&&t.setCenter($u.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($u.convert(e.center||c),h??i);sw(t,f);let d=Wu(t.worldSize,c),m=Wu(t.worldSize,f).sub(d),_=Ft(p-i);return l=p!==i,{easeFunc:o=>{if(l&&t.setZoom(ji.number(i,p,o)),qt(n,s)||bw({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=Ft(t.zoom-i),r=(p>i?Math.min(2,_):Math.max(.5,_))**(1-o),n=Hu(t.worldSize,d.add(m.mult(o*r)).mult(e));t.setLocationAtPoint(t.renderWorldCopies?n.wrap():n,u)}},isZooming:l,elevationCenter:f}}handleFlyTo(t,e){let i=void 0!==e.zoom,r=t.zoom,n=t.applyConstrain($u.convert(e.center||e.locationAtOffset),i?+e.zoom:r),s=n.center,o=n.zoom;sw(t,s);let a=t.worldSize,l=Wu(a,e.locationAtOffset),h=Wu(a,s).sub(l),u=h.mag(),c=Ft(o-r),f=Math.max(void 0===e.minZoom?t.minZoom:+e.minZoom,t.minZoom),p=Math.min(f,r,o),d=t.applyConstrain(s,p).zoom;return{easeFunc:(e,i,n,u)=>{t.setZoom(1===e?o:r+St(i));let c=1===e?s:Hu(a,l.add(h.mult(n)));t.setLocationAtPoint(t.renderWorldCopies?c.wrap():c,u)},scaleOfZoom:c,targetCenter:s,scaleOfMinZoom:Ft(d-r),pixelPathLength:u}}};let Mw;const Ew=new au({fill:new ou(128,2),line:new ou(512,0),tile:new ou(128,32),stencil:new ou(128,1),circle:3});var Aw=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 Qv.projectionGlobe}get vertexShaderPreludeCode(){return Qv.projectionMercator.vertexSource}get subdivisionGranularity(){return Ew}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?Ew.stencil:Ew.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=yy(t,e);return this._tileMeshCache[i]=r,r}recalculate(t){}hasTransition(){return!1}},Fw=class extends _e{constructor(t,e){super(),this._transitionable=new lo(Mw||=new xo({type:new go(ye.projection.type,"type")}),"projection",e),this.setProjection(t),this._transitioning=this._transitionable.untransitioned(),this.recalculate(new so(0)),this._mercatorProjection=new rw,this._verticalPerspectiveProjection=new Aw}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 Di){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 Sw(t){let e=Tw(t.worldSize,t.center.lat);return 2*Math.PI*e}function Cw(t,e,i,r,n){let s=1/(1<<n),o=e/tt*s+r*s,a=mt((t/tt*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 zw(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 Tw(t,e){return t/(2*Math.PI)/Math.cos(e*Math.PI/180)}function Pw(t){let e=q(rt(),[0,0,0,1],t.modelViewProjectionMatrix);return q(e,e,t.inverseProjectionMatrix),[e[0]/e[3],e[1]/e[3],e[2]/e[3]]}function Iw(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),s=(r>0?n:-n)/Math.PI*180;return new $u(xt(s,-180,180),e)}return new $u(0,e)}const kw=.98*Math.PI;function $w(t,e){let i=t.cameraPosition,r=C(i);if(r<=1)return t.screenPointToLocation(e);let n=nt();$(n,i);let s=t.getRayDirectionFromPixel(e),o=-j(s,n),a=nt();k(a,s,n,o);let l=C(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(bt(c,-1,1))-u,p=r*Math.cos(u)/Math.sqrt(Math.max(1-c*c,1e-12))-1,d=kw-f,m=h-u,_=f+p*m*d/(d+p*m),g=nt();I(g,a,1/l);let y=nt();return I(y,n,Math.cos(bt(_,0,kw))),k(y,y,g,Math.sin(bt(_,0,kw))),$(y,y),Iw(y)}function jw(t){return Math.cos(t*Math.PI/180)}function Rw(t,e){let i=jw(t);return St(jw(e)/i)}function Ow(t){let e=.5*t,i=Math.sin(e),r=Math.cos(e);return Math.log(i+r)-Math.log(r-i)}function Bw(t,e,i,r){let n=t.lat+i*r;if(Math.abs(i)>1){let s=(Math.sign(t.lat+i)===Math.sign(t.lat)?Math.abs(t.lat):-Math.abs(t.lat))*Math.PI/180,o=Math.abs(t.lat+i)*Math.PI/180,a=Ow(s+r*(o-s)),l=Ow(s),h=Ow(o);return new $u(t.lng+e*((a-l)/(h-l)),n)}return new $u(t.lng+e*r,n)}function Lw(t,e,i=1){let r=j(t,e),n=i*i,s=nt(),o=nt();I(o,e,r),N(s,t,o);let a=n-j(s,s);if(a<0)return null;let l=j(t,t)-n,h=-r+(r<0?1:-1)*Math.sqrt(a),u=l/h,c=h;return{tMin:Math.min(u,c),tMax:Math.max(u,c)}}var Uw=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}},Nw=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=Z([],r[0],r[1],r[2]),s=O([],[i[0],0,0],n),o=O([],[0,i[1],0],n),a=O([],[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];T(i,i,I([],s,1&~t?-1:1)),T(i,i,I([],o,1==(t>>1&1)?1:-1)),T(i,i,I([],a,1==(t>>2&1)?1:-1)),u.push(i)}return new t(u,[[...s,-j(s,u[0])],[...o,-j(o,u[0])],[...a,-j(a,u[0])],[-s[0],-s[1],-s[2],-j(s,u[7])],[-o[0],-o[1],-o[2],-j(o,u[7])],[-a[0],-a[1],-a[2],-j(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 Gw(t,e,i){let r=t-e;return r<0?-r:Math.max(0,r-i)}function qw(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,Gw(e,r,n))}var Vw=class{constructor(){this._boundingVolumeCache=new Uw(this._computeTileBoundingVolume)}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,qw(t,e,o,a,s)),l=Math.min(l,qw(t,e,o+.5,-a-s,s)),l=Math.min(l,qw(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=Gw(t.x,s,n),a=Gw(t.x,s-1,n),l=Gw(t.x,s+1,n),h=Math.min(o,a,l);return h===l?1:h===a?-1:0}allowVariableZoom(t,e){return Oy(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 nd(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/=ku,s/=ku,n+=1,s+=1,t.z<=0)return Nw.fromAabb([-s,-s,-s],[s,s,s]);if(1===t.z)return Nw.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=[Cw(0,0,t.x,t.y,t.z),Cw(tt,0,t.x,t.y,t.z),Cw(tt,tt,t.x,t.y,t.z),Cw(0,tt,t.x,t.y,t.z)],i=[];for(let t of e)i.push(I([],t,s));if(s!==n)for(let t of e)i.push(I([],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=Cw(tt/2,tt/2,t.x,t.y,t.z),l=R([],[0,1,0],a);$(l,l);let h=R([],a,l);$(h,h);let u=R([],e[2],e[1]);$(u,u);let c=R([],e[0],e[3]);$(c,c),i.push(I([],a,s)),t.y>=(1<<t.z)/2&&i.push(I([],Cw(tt/2,0,t.x,t.y,t.z),s)),t.y<(1<<t.z)/2&&i.push(I([],Cw(tt/2,tt,t.x,t.y,t.z),s));let f=Zw(a,i),p=Zw(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(ut(v,y,d),ut(v,y,m)):w.push(ut(_,y,d),ut(_,y,m),ut(_,v,d),ut(_,v,m)),t.y===(1<<t.z)-1?w.push(ut(v,y,d),ut(v,y,m)):w.push(ut(g,y,d),ut(g,y,m),ut(g,v,d),ut(g,v,m)),new Nw(w,[d,m,_,g,y,v],r,o)}}};function Zw(t,e){let i=1/0,r=-1/0;for(let n of e){let e=j(t,n);i=Math.min(i,e),r=Math.max(r,e)}return{min:i,max:r}}var Ww=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){this._cachedClippingPlane=rt(),this._projectionMatrix=ot(),this._globeViewProjMatrix32f=at(),this._globeViewProjMatrixF64=ot(),this._globeViewProjMatrixF64Inverted=ot(),this._globeProjMatrixInverted=ot(),this._cameraPosition=nt(),this.defaultConstrain=(t,e)=>{let i=bt(t.lat,-Wt,Wt),r=bt(+e,this.minZoom+Rw(0,i),this.maxZoom);return{center:new $u(t.lng,i),zoom:r}},this.applyConstrain=(t,e)=>this._helper.applyConstrain(t,e),this._helper=new aw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._coveringTilesDetailsProvider=new Vw}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=nt();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];U(h,h,[0,0,0],-this.bearingInRadians),B(h,h,[0,0,0],-1*this.center.lat*Math.PI/180),L(h,h,[0,0,0],this.center.lng*Math.PI/180);let u=1/C(h);return I(h,h,u),[...h,-s*u]}isLocationOccluded(t){return!this.isSurfacePointVisible(zw(t))}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];R(o,s,n),$(s,s),$(o,o);let a=[0,0,0];return $(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/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(t,e,i){let r=Zu(t,e,i.canonical),n=function(t,e){return[mt(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=Cw(t,e,s.x,s.y,s.z),a=1+(r??0)/ku,h=o[0]*a,u=o[1]*a,c=o[2]*a,f=[h,u,c,1];if(q(f,f,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(h,u,c);return{point:new l(f[0]/f[3],f[1]/f[3]),signedDistanceFromCamera:f[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=bt(-(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(){let t=Tw(this.worldSize,this.center.lat),e=st();this._helper.autoCalculateNearFarZ&&(this._helper._nearZ=.5,this._helper._farZ=this.cameraToCenterDistance+2*t),E(e,this.fovInRadians,this.width/this.height,this._helper._nearZ,this._helper._farZ);let i=this.centerOffset;e[8]=2*-i.x/this._helper._width,e[9]=2*i.y/this._helper._height,this._projectionMatrix=_(e),this._globeProjMatrixInverted=st(),y(this._globeProjMatrixInverted,e),w(e,e,[0,0,-this.cameraToCenterDistance]),M(e,e,this.rollInRadians),x(e,e,-this.pitchInRadians),M(e,e,this.bearingInRadians),w(e,e,[0,0,-t]);let r=nt();r[0]=t,r[1]=t,r[2]=t,x(e,e,this.center.lat*Math.PI/180),D(e,e,-this.center.lng*Math.PI/180),b(e,e,r),this._globeViewProjMatrixF64=e,this._globeViewProjMatrix32f=new Float32Array(e),this._globeViewProjMatrixF64Inverted=st(),y(this._globeViewProjMatrixF64Inverted,e);let n=nt();this._cameraPosition=nt(),this._cameraPosition[2]=this.cameraToCenterDistance/t,U(this._cameraPosition,this._cameraPosition,n,-this.rollInRadians),B(this._cameraPosition,this._cameraPosition,n,this.pitchInRadians),U(this._cameraPosition,this._cameraPosition,n,-this.bearingInRadians),T(this._cameraPosition,this._cameraPosition,[0,0,1]),B(this._cameraPosition,this._cameraPosition,n,-this.center.lat*Math.PI/180),L(this._cameraPosition,this._cameraPosition,n,this.center.lng*Math.PI/180),this._cachedClippingPlane=this._computeClippingPlane(t);let s=_(this._globeViewProjMatrixF64Inverted);b(s,s,[1,1,-1]),this._cachedFrustum=Iy.fromInvProjectionMatrix(s,1,0,this._cachedClippingPlane,!0)}calculateFogMatrix(t){$t("calculateFogMatrix is not supported on globe projection.");let e=st();return g(e),e}getVisibleUnwrappedCoordinates(t){return[new rd(0,t)]}getCameraFrustum(){return this._cachedFrustum}getClippingPlane(){return this._cachedClippingPlane}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(t){t?$t("terrain is not fully supported on vertical perspective projection."):this._helper.recalculateZoomAndCenter(0)}maxPitchScaleFactor(){return 1}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return(C(this._cameraPosition)-1)*ku}getCameraLngLat(){let t=nt();return $(t,this._cameraPosition),Iw(t)}lngLatToCameraDepth(t,e){let i=zw(t);I(i,i,1+e/ku);let r=rt();return q(r,[i[0],i[1],i[2],1],this._globeViewProjMatrixF64),r[2]/r[3]}populateCache(t){}getBounds(){let t=.5*this.width,e=.5*this.height,i=[new l(0,0),new l(t,0),new l(this.width,0),new l(this.width,e),new l(this.width,this.height),new l(t,this.height),new l(0,this.height),new l(0,e)],r=[];for(let t of i)r.push(this.unprojectScreenPoint(t));let n=0,s=0,o=0,a=0,h=this.center;for(let t of r){let e=pt(h.lng,t.lng),i=pt(h.lat,t.lat);e<s&&(s=e),e>n&&(n=e),i<a&&(a=i),i>o&&(o=i)}let u=[h.lng+s,h.lat+a,h.lng+n,h.lat+o];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Qg(u)}calculateCenterFromCameraLngLatAlt(t,e,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(t,e,i,r)}calculateCameraOptionsFromTo(t,e,i,r){let n=$u.convert(i),s=zw($u.convert(t));I(s,s,1+e/ku);let o=zw(n),a=I(nt(),o,1+r/ku),l=P(nt(),s,o),h=C(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=nt();L(l,l,u,-Nt(n.lng)),B(l,l,u,Nt(n.lat));let c=Gt(Math.acos(bt(l[2]/h,-1,1))),f=Math.hypot(l[0],l[1])<1e-9*h?this.bearing:Gt(Math.atan2(-l[0],-l[1]));return{center:n,elevation:r,zoom:St(this.cameraToCenterDistance/h/Tw(this.tileSize,n.lat)),pitch:c,bearing:f}}setLocationAtPoint(t,e,i){let r=zw(this.unprojectScreenPoint(e)),n=zw(t),s=nt();!function(t){t[0]=0,t[1]=0,t[2]=0}(s);let o=nt();L(o,r,s,-this.center.lng*Math.PI/180),B(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=ft(n[0],n[2],o[0],h),f=ft(n[0],n[2],o[0],u),p=nt();L(p,n,s,-c);let d=ft(p[1],p[2],o[1],o[2]),m=nt();L(m,n,s,-f);let _,g,y=ft(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;dt(c,t)+dt(d,e)<dt(f,t)+dt(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 $u(x,bt(D,-90,90))),this.setZoom(this.zoom+Rw(M,this.center.lat))}locationToScreenPoint(t,e){let i=zw(t);return e&&I(i,i,1+e.getElevationForLngLatZoom(t,this._helper._tileZoom)/ku),this._projectSurfacePointToScreen(i)}_projectSurfacePointToScreen(t){let e=rt();return q(e,[...t,1],this._globeViewProjMatrixF64),e[0]/=e[3],e[1]/=e[3],new l((.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 qu.fromLngLat(this.unprojectScreenPoint(t))}screenTerrainPointToMercatorCoordinate(t,e){let i=e.getCoverageIndex();if(!i)return null;let r=this.cameraPosition,n=this.getRayDirectionFromPixel(t),s=Lw(r,n,1+i.maxElevation/ku);if(!s)return null;let o=Lw(r,n,1+i.minElevation/ku),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(Yw(h,e)){let{hi:t}=_w(h,Yw,u,e,1e-12),{sample:i,mercator:r}=Hw(h,t);return new qu(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!!Lw(this._cameraPosition,this.getRayDirectionFromPixel(t))}getRayDirectionFromPixel(t){let e=rt();e[0]=t.x/this.width*2-1,e[1]=-1*(t.y/this.height*2-1),e[2]=1,e[3]=1,q(e,e,this._globeViewProjMatrixF64Inverted),e[0]/=e[3],e[1]/=e[3],e[2]/=e[3];let i=nt();i[0]=e[0]-this._cameraPosition[0],i[1]=e[1]-this._cameraPosition[1],i[2]=e[2]-this._cameraPosition[2];let r=nt();return $(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=rt();return q(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=Lw(e,i);if(r){let t=nt();T(t,e,[i[0]*r.tMin,i[1]*r.tMin,i[2]*r.tMin]);let n=nt();return $(n,t),Iw(n)}let n=this._cachedClippingPlane,s=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=-ht(n,e)/s,a=nt();if(o>0)T(a,e,[i[0]*o,i[1]*o,i[2]*o]);else{let t=nt();T(t,e,[2*i[0],2*i[1],2*i[2]]);let r=ht(this._cachedClippingPlane,t);N(a,t,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}let l=function(t){let e=nt();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 Iw(function(t,e,i){let r=nt();N(r,i,t);let n=nt();return k(n,t,r,e/G(r)),n}(l.center,l.radius,a))}getProjectionDataForCustomLayer(t=!0){let e=this.getProjectionData({overscaledTileID:new nd(0,0,0,0,0),applyGlobeMatrix:t});return e.tileMercatorCoords=[0,0,1,1],e}getFastPathSimpleProjectionMatrix(t){}};function Hw(t,e){let i=nt();k(i,t.origin,t.direction,e);let r=C(i),n=nt();I(n,i,1/r);let s=Iw(n),o=qu.fromLngLat(s),a=new qu(o.x,bt(o.y,0,.999999999)),l=dw(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 Yw(t,e){let{sample:i,radius:r}=Hw(t,e);return mw(i,(r-1)*ku)}var Xw=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 aw({calcMatrices:()=>this._calcMatrices(),defaultConstrain:(t,e)=>this.defaultConstrain(t,e)},t),this._globeness=1,this._mercatorTransform=new gw,this._verticalPerspectiveTransform=new Ww}clone(){let e=new t;return e._globeness=this._globeness,e.apply(this,!1),e}apply(t,e){this._helper.apply(t,e),this._mercatorTransform.apply(this,!1),this._verticalPerspectiveTransform.apply(this,!1)}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){return this.currentTransform.isLocationOccluded(t)}transformLightDirection(t){return this.currentTransform.transformLightDirection(t)}getPixelScale(){return gt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return gt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(t,e,i){return gt(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.apply(this,!1),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(t){return this.currentTransform.calculateFogMatrix(t)}getVisibleUnwrappedCoordinates(t){return this.currentTransform.getVisibleUnwrappedCoordinates(t)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(t){this.currentTransform.recalculateZoomAndCenter(t)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this.currentTransform.getCameraAltitude()}getCameraLngLat(){return this.currentTransform.getCameraLngLat()}lngLatToCameraDepth(t,e){return this.currentTransform.lngLatToCameraDepth(t,e)}populateCache(t){this._mercatorTransform.populateCache(t),this._verticalPerspectiveTransform.populateCache(t)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(t,e,i,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){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(t,e,i),void this.apply(this._mercatorTransform,!1);this._verticalPerspectiveTransform.setLocationAtPoint(t,e,i),this.apply(this._verticalPerspectiveTransform,!1)}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)}},Jw=class t{get useGlobeControls(){return!0}handlePanInertia(t,e){let i=function(t,e){let i=t.rotate(e.bearingInRadians),r=e.zoom+Rw(e.center.lat,0),n=gt(1/jw(e.center.lat),1/jw(Math.min(Math.abs(e.center.lat),60)),_t(r,7,3,0,1)),s=function(t,e){return 360/Sw({worldSize:t,center:{lat:e}})}(e.worldSize,e.center.lat);return new $u(e.center.lng-i.x*s*n,bt(e.center.lat+i.y*s,-Wt,Wt))}(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 l(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=pt(e.center.lng,r.lng),a=o/(Math.abs(o/180)+1),l=pt(e.center.lat,r.lat),h=e.getRayDirectionFromPixel(i),u=e.cameraPosition,c=-1*j(u,h),f=nt();T(f,u,[h[0]*c,h[1]*c,h[2]*c]);let p=C(f),d=Math.exp(.5*-Math.max(p-1-.3,0)),m=_t(p,.95,.999,0,1),_=_t(Tw(e.worldSize,e.center.lat)/Math.min(e.width,e.height),.9,.5,1,.25),g=Math.min(d,gt(1,_,m)),y=(1-Ft(-s))*g,v=e.center.lat,w=e.zoom,b=new $u(e.center.lng+a*y,bt(e.center.lat+l*y,-Wt,Wt));e.setLocationAtPoint(r,i);let x=e.center,D=_t(Math.abs(o),45,85,0,1),M=Math.max(D,m)**.25,E=pt(x.lng,b.lng),A=pt(x.lat,b.lat);e.setCenter(new $u(x.lng+E*M,x.lat+A*M).wrap()),e.setZoom(w+Rw(v,e.center.lat))}handleMapControlsPan(t,e,i){t.panDelta&&function(t,e,i,r,n=!0){let s=$w(t,i),o=e;if(r)o=$w(t,i.sub(r));else if(!t.isPointOnMapSurface(i))return;let a=zw(s),l=zw(o),h=function(t,e){return Z(rt(),-t.lng,-t.lat,e)}(t.center,t.bearing),u=R(nt(),l,a),c=Math.sqrt(j(u,u)),f=Math.acos(bt(j(l,a),-1,1))/2,p=Math.sin(f),d=c?W(u[1]/c*p,-u[0]/c*p,u[2]/c*p,Math.cos(f)):W(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(bt(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}(rt(),h,d)),y=t.center.lat,v=t.zoom,w=bt(_,-90,90),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 $u(0,o)),l=e.x-a.x,h=e.y-a.y,u=l*l+h*h,c=bt(1-(Wt-Math.abs(s))/12,0,1),f=c*c*(3-2*c),p=mt(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 $u(xt(b,-180,180),w)),n||t.setBearing(g),t.setZoom(v+Rw(y,t.center.lat))}(e,i,e.isPointOnMapSurface(t.around)?t.around:e.centerPoint,t.panDelta)}cameraForBoxAndBearing(e,i,r,n,s){let o=xw(e,i,r,n,s),a=i.left/s.width*2-1,l=(s.width-i.right)/s.width*2-1,h=i.top/s.height*-2+1,u=(s.height-i.bottom)/s.height*-2+1,c=pt(r.getWest(),r.getEast())<0,f=c?r.getEast():r.getWest(),p=c?r.getWest():r.getEast(),d=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),_=f+.5*pt(f,p),g=d+.5*pt(d,m),y=s.clone();y.setCenter(o.center),y.setBearing(o.bearing),y.setPitch(0),y.setRoll(0),y.setZoom(o.zoom);let v=y.modelViewProjectionMatrix,w=[zw(r.getNorthWest()),zw(r.getNorthEast()),zw(r.getSouthWest()),zw(r.getSouthEast()),zw(new $u(p,g)),zw(new $u(f,g)),zw(new $u(_,d)),zw(new $u(_,m))],b=zw(o.center),x=1/0;for(let e of w)a<0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"x",a))),l>0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"x",l))),h>0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"y",h))),u<0&&(x=t.getLesserNonNegativeNonNull(x,t.solveVectorScale(e,b,v,"y",u)));if(Number.isFinite(x)&&0!==x)return o.zoom=Math.min(y.zoom+St(x),e.maxZoom),o;ww()}handleJumpToCenterZoom(t,e){let i=t.center.lat,r=t.applyConstrain(e.center?$u.convert(e.center):t.center,t.zoom).center;t.setCenter(r.wrap());let n=void 0===e.zoom?t.zoom+Rw(i,r.lat):+e.zoom;t.zoom!==n&&t.setZoom(n)}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,h=!t.isPaddingEqual(e.padding),u=!1,c=e.center?$u.convert(e.center):r,f=t.applyConstrain(c,i).center;sw(t,f);let p=t.clone();p.setCenter(f),p.setZoom(a?+e.zoom:i+Rw(r.lat,c.lat)),p.setBearing(e.bearing);let d=new l(bt(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),bt(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));p.setLocationAtPoint(f,d);let m=(e.offset&&e.offsetAsPoint.mag())>0?p.center:f,_=a?+e.zoom:i+Rw(r.lat,m.lat),g=i+Rw(r.lat,0),y=_+Rw(m.lat,0),v=pt(r.lng,m.lng),w=pt(r.lat,m.lat),b=Ft(y-g);return u=_!==i,{easeFunc:i=>{if(qt(s,o)||bw({startEulerAngles:s,endEulerAngles:o,tr:t,k:i,useSlerp:s.roll!=o.roll}),h&&t.interpolatePadding(n,e.padding,i),e.around)$t("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=Bw(r,v,w,e);t.setCenter(n.wrap())}if(u){let e=ji.number(g,y,i)+Rw(0,t.center.lat);t.setZoom(e)}},isZooming:u,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($u.convert(e.center||e.locationAtOffset),n).center,h=i?+e.zoom:t.zoom+Rw(t.center.lat,a.lat),u=t.clone();u.setCenter(a),u.setZoom(h),u.setBearing(e.bearing);let c=new l(bt(t.centerPoint.x+e.offsetAsPoint.x,0,t.width),bt(t.centerPoint.y+e.offsetAsPoint.y,0,t.height));u.setLocationAtPoint(a,c);let f=u.center;sw(t,f);let p=function(t,e,i){let r=j(zw(e),zw(i)),n=Math.acos(r),s=Sw(t);return n/(2*Math.PI)*s}(t,r,f),d=n+Rw(r.lat,0),m=h+Rw(f.lat,0),_=Ft(m-d),g=Math.max("number"==typeof e.minZoom?+e.minZoom:t.minZoom,t.minZoom)+Rw(f.lat,0),y=Math.min(g,d,m)+Rw(0,f.lat),v=Ft(t.applyConstrain(f,y).zoom+Rw(f.lat,0)-d),w=pt(r.lng,f.lng),b=pt(r.lat,f.lat);return{easeFunc:(i,n,a)=>{let l=Bw(r,w,b,a);o&&t.interpolatePadding(s,e.padding,i);let u=1===i?f:l;t.setCenter(u.wrap());let c=d+St(n);t.setZoom(1===i?h:c+Rw(0,u.lat))},scaleOfZoom:_,targetCenter:f,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}},Kw=class{constructor(t){this._globe=t,this._mercatorCameraHelper=new Dw,this._verticalPerspectiveCameraHelper=new Jw}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){return this.currentHelper.cameraForBoxAndBearing(t,e,i,r,n)}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 Qw=function(){let t={},e=ye.$version;for(let i in ye.$root){let r=ye.$root[i];if(r.required){let n=null;n="version"===i?e:"array"===r.type?[]:{},null!=n&&(t[i]=n)}}return t}();var tb=class extends _e{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 Vg(qg(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",((t,e)=>this.getGlyphs(t,e))),this.dispatcher.registerMessageHandler("GI",((t,e)=>this.getImages(t,e))),this.dispatcher.registerMessageHandler("GDA",((t,e)=>this.getDashes(t,e))),this.imageManager=new gg,this.imageManager.setEventedParent(this),this.imageManager.setMissingImageResolver(t._missingStyleImageResolver),this.patternAtlas=new yg(this.imageManager);let i=t._container?.lang||typeof document<"u"&&document.documentElement?.lang||void 0;this.glyphManager=new Ig(t._requestManager,e.localIdeographFontFamily,i),this.lineAtlas=new Og(256,512),this.crossTileSymbolIndex=new Jv,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",ae()),Sy().on(Ey,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 no,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;if(Pt(i,this._globalState[t]))return this;this._globalState[t]=i,this._applyGlobalStateChanges([t])}getGlobalState(){return this._globalState}setGlobalState(t){this._checkLoaded();let e=[];for(let i in t)Pt(this._globalState[i],t[i].default)||(e.push(i),this._globalState[i]=t[i].default);this._applyGlobalStateChanges(e)}_applyGlobalStateChanges(t){if(0===t.length)return;let e=new Set,i={};for(let r of t){i[r]=this._globalState[r];for(let t in this._layers){let i=this._layers[t],n=i.getLayoutAffectingGlobalStateRefs(),s=i.getPaintAffectingGlobalStateRefs(),o=i.getVisibilityAffectingGlobalStateRefs();if(n.has(r)&&e.add(i.source),s.has(r))for(let{name:t,value:e}of s.get(r))this._updatePaintProperty(i,t,e);o?.has(r)&&(i.recalculateVisibility(),this._updateLayer(i))}}this.dispatcher.broadcast("UGS",i);for(let t in this.tileManagers)e.has(t)&&(this._reloadSource(t),this._changed=!0)}async loadURL(t,e={},i){this.fire(new H_("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");ie(r.signal);let s=await he(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 me(it(t)))}}loadJSON(t,e={},i){this.fire(new H_("dataloading")),this._frameRequest=new AbortController,B_.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 H_("dataloading")),this._load(Qw,{validate:!1})}_load(t,e,i){let r=e.transformStyle?e.transformStyle(i,t):t;if(!e.validate||!Ws(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 $g(this.stylesheet.light??{},this._globalState),this._setProjectionInternal(this.stylesheet.projection?.type||"mercator"),this.sky=new Rg(this.stylesheet.sky,this._globalState),this.map.setTerrain(this.stylesheet.terrain??null,{validate:!1}),this.fire(new H_("data")),this.fire(new W_)}}_createLayers(){let t=sg(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=Jp(e,this._globalState);if(t.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=t,So(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=mg(t),s=i>1?"@2x":"",o={},a={};for(let{id:t,url:i}of n){let n=await e.transformRequest(_g(i,s,".json"),"SpriteJSON");o[t]=he(n,r);let l=await e.transformRequest(_g(i,s,".png"),"SpriteImage");a[t]=G_.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=B_.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 me(r))}finally{this._spriteRequest=null,this.imageManager.setLoaded(!0),e&&(this._changed=!0),this.dispatcher.broadcast("SI",this.imageManager.listImages()),this.fire(new H_("data")),i?.(r)}}_unloadSprite(){this._markImagesChanged(this.imageManager.removeAllSpriteImages()),this._imagesListDirty=!0,this._changed=!0,this.fire(new H_("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 me(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?It(i):i);let r=[];for(let n of t)if(i[n]){let t=e?It(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 Y_("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 H_("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})}_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)&&Ws(this,t))return!1;(t=It(t)).layers=sg(t.layers);let r=function(t,e){if(!t)return[{command:"setStyle",args:[e]}];let i=[];try{if(!og(t.version,e.version))return[{command:"setStyle",args:[e]}];og(t.center,e.center)||i.push({command:"setCenter",args:[e.center]}),og(t.state,e.state)||i.push({command:"setGlobalState",args:[e.state]}),og(t.centerAltitude,e.centerAltitude)||i.push({command:"setCenterAltitude",args:[e.centerAltitude]}),og(t.zoom,e.zoom)||i.push({command:"setZoom",args:[e.zoom]}),og(t.bearing,e.bearing)||i.push({command:"setBearing",args:[e.bearing]}),og(t.pitch,e.pitch)||i.push({command:"setPitch",args:[e.pitch]}),og(t.roll,e.roll)||i.push({command:"setRoll",args:[e.roll]}),og(t.sprite,e.sprite)||i.push({command:"setSprite",args:[e.sprite]}),og(t.glyphs,e.glyphs)||i.push({command:"setGlyphs",args:[e.glyphs]}),og(t["font-faces"],e["font-faces"])||i.push({command:"setFontFaces",args:[e["font-faces"]]}),og(t.transition,e.transition)||i.push({command:"setTransition",args:[e.transition]}),og(t.light,e.light)||i.push({command:"setLight",args:[e.light]}),og(t.terrain,e.terrain)||i.push({command:"setTerrain",args:[e.terrain]}),og(t.sky,e.sky)||i.push({command:"setSky",args:[e.sky]}),og(t.projection,e.projection)||i.push({command:"setProjection",args:[e.projection]});let r={},n=[];!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)||hg(n,i,r));for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)?og(t[n],e[n])||("geojson"===t[n].type&&"geojson"===e[n].type&&cg(t,e,n)?ag(i,{command:"setGeoJSONSourceData",args:[n,e[n].data]}):ug(n,e,i,r)):lg(n,e,i))}(t.sources,e.sources,n,r);let s=[];t.layers&&t.layers.forEach((t=>{"source"in t&&r[t.source]?i.push({command:"removeLayer",args:[t.id]}):s.push(t)})),i=i.concat(n),function(t,e,i){t||=[],e||=[];let r,n,s,o,a,l=t.map(pg),h=e.map(pg),u=t.reduce(dg,{}),c=e.reduce(dg,{}),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++:(ag(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)?(ag(i,{command:"removeLayer",args:[r]}),f.splice(f.lastIndexOf(r,f.length-e),1)):e++,o=f[f.length-t],ag(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]&&!og(n,s)){if(!og(n.source,s.source)||!og(n["source-layer"],s["source-layer"])||!og(n.type,s.type)){ag(i,{command:"removeLayer",args:[r]}),o=f[f.lastIndexOf(r)+1],ag(i,{command:"addLayer",args:[s,o]});continue}for(a in fg(n.layout,s.layout,i,r,null,"setLayoutProperty"),fg(n.paint,s.paint,i,r,null,"setPaintProperty"),og(n.filter,s.filter)||ag(i,{command:"setFilter",args:[r,s.filter]}),(!og(n.minzoom,s.minzoom)||!og(n.maxzoom,s.maxzoom))&&ag(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.")?fg(n[a],s[a],i,r,a.slice(6),"setPaintProperty"):og(n[a],s[a])||ag(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.")?fg(n[a],s[a],i,r,a.slice(6),"setPaintProperty"):og(n[a],s[a])||ag(i,{command:"setLayerProperty",args:[r,a,s[a]]}))}}(s,e.layers,i)}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 W_({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":e.push((()=>this.addLayer.apply(this,r.args)));break;case"removeLayer":e.push((()=>this.removeLayer.apply(this,r.args)));break;case"setPaintProperty":e.push((()=>this.setPaintProperty.apply(this,r.args)));break;case"setLayoutProperty":e.push((()=>this.setLayoutProperty.apply(this,r.args)));break;case"setFilter":e.push((()=>this.setFilter.apply(this,r.args)));break;case"addSource":e.push((()=>this.addSource.apply(this,r.args)));break;case"removeSource":e.push((()=>this.removeSource.apply(this,r.args)));break;case"setLayerZoomRange":e.push((()=>this.setLayerZoomRange.apply(this,r.args)));break;case"setLight":e.push((()=>this.setLight.apply(this,r.args)));break;case"setGeoJSONSourceData":e.push((()=>this.setGeoJSONSourceData.apply(this,r.args)));break;case"setGlyphs":e.push((()=>this.setGlyphs.apply(this,r.args)));break;case"setFontFaces":e.push((()=>this.setFontFaces.apply(this,r.args)));break;case"setSprite":e.push((()=>this.setSprite.apply(this,r.args)));break;case"setTerrain":e.push((()=>this.map.setTerrain.apply(this,r.args)));break;case"setSky":e.push((()=>this.setSky.apply(this,r.args)));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":e.push((()=>this.setGlobalState.apply(this,r.args)));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 me(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 me(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 H_("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(Zs.has(e.type)&&this._validate(Vs.source,`sources.${t}`,e,null,i))return;this.map?._collectResourceTiming&&(e.collectResourceTiming=!0);let r=this.tileManagers[t]=new Wy(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 me(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 Y_("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 me(Error(`Layer "${n}" already exists on this map.`)));if("custom"===t.type){if(Hs(this,function(t){let e=[],i=t.id;return void 0===i&&e.push(new we(`layers.${i}`,null,'missing required property "id"')),void 0===t.render&&e.push(new we(`layers.${i}`,null,'missing required method "render"')),t.renderingMode&&"2d"!==t.renderingMode&&"3d"!==t.renderingMode&&e.push(new we(`layers.${i}`,null,'property "renderingMode" must be either "2d" or "3d"')),e}(t)))return;r=Jp(t,this._globalState)}else{if("source"in t&&"object"==typeof t.source&&(this.addSource(n,t.source),t=Dt(t=It(t),{source:n})),this._validate(Vs.layer,`layers.${n}`,t,{arrayIndex:-1},i))return;r=Jp(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 me(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 me(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 me(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 me(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 me(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(!Pt(r.filter,e)){if(null==e)return r.setFilter(void 0),void this._updateLayer(r);this._validate(Vs.filter,`layers.${r.id}.filter`,e,null,i)||(r.setFilter(It(e)),this._updateLayer(r))}}else this.fire(new me(Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return It(this.getLayer(t).filter)}setLayoutProperty(t,e,i,r={}){this._checkLoaded();let n=this.getLayer(t);n?Pt(n.getLayoutProperty(e),i)||(n.setLayoutProperty(e,i,r),this._updateLayer(n)):this.fire(new me(Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,e){let i=this.getLayer(t);if(i)return i.getLayoutProperty(e);this.fire(new me(Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,e,i,r={}){this._checkLoaded();let n=this.getLayer(t);n?Pt(n.getPaintProperty(e),i)||this._updatePaintProperty(n,e,i,r):this.fire(new me(Error(`Cannot style non-existing layer "${t}".`)))}_updatePaintProperty(t,e,i,r={}){t.setPaintProperty(e,i,r)&&this._updateLayer(t),So(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 me(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 me(Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new me(Error("The sourceLayer parameter must be provided for vector source types.")));if(void 0===t.id)return void this.fire(new me(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 me(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 me(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 me(Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,t.id,e):this.fire(new me(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 me(Error("The feature id parameter must be provided."))),r.getFeatureState(i,t.id);this.fire(new me(Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new me(Error(`The source '${e}' does not exist in the map's style.`)))}getTransition(){return Dt({duration:300,delay:0},this.stylesheet?.transition)}serialize(){if(!this._loaded)return;let t=zt(this.tileManagers,(t=>t.serialize())),e=this._serializeByIds(this._order,!0),i=this.map.getTerrain()||void 0,r=this.stylesheet;return Tt({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(Vs.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 me(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 me(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(Yg(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(Xg);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])Jg(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(Vs.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(!Pt(t[e],i[e])){r=!0;break}if(!r)return;let n={now:U_(),transition:Dt({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(!Pt(t[e],i[e])){r=!0;break}if(!r)return;let n={now:U_(),transition:Dt({duration:300,delay:0},this.stylesheet.transition)};this.stylesheet.sky=t,this.sky.setSky(t,e),this.sky.updateTransitions(n)}_setProjectionInternal(t){let e=function(t,e,i){let r={constrainOverride:e};if(Array.isArray(t)){let e=new Fw({type:t},i);return{projection:e,transform:new Xw(r),cameraHelper:new Kw(e)}}switch(t){case"mercator":return{projection:new rw,transform:new gw(r),cameraHelper:new Dw};case"globe":{let t=new Fw({type:["interpolate",["linear"],["zoom"],11,"vertical-perspective",12,"mercator"]},{});return{projection:t,transform:new Xw(r),cameraHelper:new Kw(t)}}case"vertical-perspective":return{projection:new Aw,transform:new Ww(r),cameraHelper:new Jw};default:return $t(`Unknown projection name: ${t}. Falling back to mercator projection.`),{projection:new rw,transform:new gw(r),cameraHelper:new Dw}}}(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&&Ys(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),Sy().off(Ey,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(U_(),t.zoom);if((n||!this.pauseablePlacement||h&&(l||this.placement.stale))&&(this._symbolPlacementTriggered=!1,this._placedProjectionTransition=this.projection?.transitionState,this.pauseablePlacement=new Ov(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(U_()),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(U_())}_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(Vs.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=[...mg(this.stylesheet.sprite),...n];this._validate(Vs.sprite,"sprite",s,null,i)||(this.stylesheet.sprite=s,this._loadSprite(n,!0,r))}removeSprite(t){this._checkLoaded();let e=mg(this.stylesheet.sprite);if(!e.find((e=>e.id===t)))return void this.fire(new me(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 H_("data"))}getSprite(){return mg(this.stylesheet.sprite)}setSprite(t,e={},i){this._checkLoaded(),(!t||!this._validate(Vs.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 eb=Io([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);var ib=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 rb=(t,e,i,r,n)=>({u_texture:0,u_ele_delta:t,u_fog_matrix:e,u_fog_color:i?i.properties.get("fog-color"):fi.white,u_fog_ground_blend:i?i.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:n?0:i?i.calculateFogBlendOpacity(r):0,u_horizon_color:i?i.properties.get("horizon-color"):fi.white,u_horizon_fog_blend:i?i.properties.get("horizon-fog-blend"):1,u_is_globe_mode:+!!n}),nb=t=>({u_ele_delta:t}),sb={ProjectionUBO:0,TerrainUBO:1,FrameUBO:2},ob={float:[1,1],int:[1,1],vec2:[2,2],vec4:[4,4],mat4:[16,4]};function ab(t){let e={},i=0;for(let{name:r,type:n}of t){let[t,s]=ob[n];i=Math.ceil(i/s)*s,e[r]=i,i+=t}return{offsets:e,contentWords:i,sizeWords:4*Math.ceil(i/4)}}var lb=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),r.bindBufferBase(r.UNIFORM_BUFFER,e,this.buffer),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,this.bindingDirty=!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}}this.bindingDirty&&=(t.bindBufferBase(t.UNIFORM_BUFFER,this.binding,this.buffer),!1),e&&(t.bindBuffer(t.UNIFORM_BUFFER,this.buffer),t.bufferSubData(t.UNIFORM_BUFFER,0,this.pending),this.uploaded.set(this.pending),this.hasData=!0)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}};const hb=ab([{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"}]),ub=hb.offsets,cb=ab([{name:"u_terrain_matrix",type:"mat4"},{name:"u_terrain_unpack",type:"vec4"},{name:"u_terrain_dim",type:"float"},{name:"u_terrain_exaggeration",type:"float"}]),fb=cb.offsets;function pb(t){let e=[];for(let i of t){if(null===i)continue;let t=i.split(" ");e.push(t.pop())}return e}var db=class{constructor(t,e,i,r,n,s,o,a,l=[]){let h=t.gl;this.program=h.createProgram();let u=pb(e.staticAttributes),c=i?i.getBinderAttributes():[],f=u.concat(c),p=Qv.prelude.staticUniforms?pb(Qv.prelude.staticUniforms):[],d=e.staticUniforms?pb(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(Qv.prelude.fragmentSource,o.fragmentSource,e.fragmentSource).join("\n"),w=y.concat(Qv.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())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(sb)){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 Xa(t,e.u_depth),u_terrain:new Xa(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.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,fb.u_terrain_matrix),i.set(e.u_terrain_unpack,fb.u_terrain_unpack),i[fb.u_terrain_dim]=e.u_terrain_dim,i[fb.u_terrain_exaggeration]=e.u_terrain_exaggeration,t.upload()}(t.terrainUniformBuffer,a)}if(l&&function(t,e){let i=t.pending;i.set(e.mainMatrix,ub.u_projection_matrix),i.set(e.fallbackMatrix,ub.u_projection_fallback_matrix),i.set(e.tileMercatorCoords,ub.u_projection_tile_mercator_coords),i.set(e.clippingPlane,ub.u_projection_clipping_plane),i[ub.u_projection_transition]=e.projectionTransition,t.pendingWords[ub.u_projection_clip_antimeridian]=+!!e.clipAntimeridian,t.upload()}(t.projectionUniformBuffer,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 ib,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 mb(t,e,i){let r=1/et(i,1,e.transform.tileZoom),n=2**i.tileID.overscaledZ,s=i.tileSize*2**e.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 _b=(t,e,i,r)=>{let n=t.style.light,s=n.getCartesianPosition(),o=d();"viewport"===n.properties.get("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.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.transform.transformLightDirection(s),l=n.properties.get("color");return{u_lightpos:s,u_lightpos_globe:a,u_lightintensity:n.properties.get("intensity"),u_lightcolor:[l.r,l.g,l.b],u_vertical_gradient:+e,u_opacity:i,u_fill_translate:r}},gb=(t,e,i,r,n,s,o)=>Dt(_b(t,e,i,r),mb(s,t,o),{u_height_factor:-(2**n.overscaledZ)/o.tileSize/8}),yb=(t,e,i,r,n)=>Dt(mb(e,t,i),{u_fill_translate:r,u_sdf_pattern:+!!n}),vb=t=>({u_fill_translate:t}),wb=t=>({u_fill_translate:t}),bb=(t,e,i,r,n)=>yb(t,e,i,r,n),xb=(t,e,i,r,n)=>{let s,o,a=t.transform,l=0;if("map"===i.paint.get("circle-pitch-alignment")){let t=et(e,1,a.zoom);s=!0,o=[t,t],l=t/(tt*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}},Db=(t,e=1)=>({u_color:t,u_overlay:0,u_overlay_scale:e}),Mb=(t,e,i,r)=>{let n=et(t,1,e)/(tt*2**t.tileID.overscaledZ)*2*Math.PI*r;return{u_extrude_scale:et(t,1,e),u_intensity:i,u_globe_extrude_scale:n}},Eb=(t,e,i,r)=>{let n=m();return A(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")}},Ab=(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.transform.bearingInRadians);return{u_image:0,u_latrange:Sb(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}},Fb=(t,e)=>{let i=e.stride,r=m();return A(r,0,tt,-tt,0,0,1),w(r,r,[0,-tt,0]),{u_matrix:r,u_image:1,u_dimension:[i,i],u_zoom:t.overscaledZ,u_unpack:e.getUnpackVector()}};function Sb(t,e){let i=2**e.canonical.z,r=e.canonical.y;return[new qu(0,r/i).toLngLat().lat,new qu(0,(r+1)/i).toLngLat().lat]}const Cb=(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")}),zb=(t,e,i,r)=>{let n=t.transform;return{u_translation:jb(t,e,i),u_ratio:r/et(e,1,n.zoom)}},Tb=(t,e,i,r,n)=>Dt(zb(t,e,i,r),{u_image:0,u_image_height:n}),Pb=(t,e,i,r,n)=>{let s=t.transform,o=$b(e,s);return{u_translation:jb(t,e,i),u_texsize:e.imageAtlasTexture.size,u_ratio:r/et(e,1,s.zoom),u_image:0,u_scale:[o,n.fromScale,n.toScale],u_fade:n.t}},Ib=(t,e,i,r,n)=>{let s=$b(e,t.transform);return Dt(zb(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})},kb=(t,e,i,r,n,s)=>{let o=$b(e,t.transform);return Dt(zb(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 $b(t,e){return 1/et(t,1,e.tileZoom)}function jb(t,e,i){return lt(t.transform,e,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Rb=(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}),Ob=(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d,m)=>{let _=o.transform;return Dt(Rb(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})},Bb=(t,e,i,r,n,s,o,a,l,h,u,c,f,p,d)=>Dt(Ob(t,e,i,r,n,s,o,a,l,h,!0,u,!0,f,p,d),{u_texsize_icon:c,u_texture_icon:1}),Lb=(t,e)=>({u_opacity:t,u_color:e}),Ub=(t,e,i,r,n)=>Dt(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.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/et(r,1,i.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}),Nb=()=>({}),Gb={fillExtrusion:(t,e)=>({u_lightpos:new Qa(t,e.u_lightpos),u_lightpos_globe:new Qa(t,e.u_lightpos_globe),u_lightintensity:new Ja(t,e.u_lightintensity),u_lightcolor:new Qa(t,e.u_lightcolor),u_vertical_gradient:new Ja(t,e.u_vertical_gradient),u_opacity:new Ja(t,e.u_opacity),u_fill_translate:new Ka(t,e.u_fill_translate)}),fillExtrusionPattern:(t,e)=>({u_lightpos:new Qa(t,e.u_lightpos),u_lightpos_globe:new Qa(t,e.u_lightpos_globe),u_lightintensity:new Ja(t,e.u_lightintensity),u_lightcolor:new Qa(t,e.u_lightcolor),u_vertical_gradient:new Ja(t,e.u_vertical_gradient),u_height_factor:new Ja(t,e.u_height_factor),u_opacity:new Ja(t,e.u_opacity),u_fill_translate:new Ka(t,e.u_fill_translate),u_image:new Xa(t,e.u_image),u_texsize:new Ka(t,e.u_texsize),u_pixel_coord_upper:new Ka(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Ka(t,e.u_pixel_coord_lower),u_scale:new Qa(t,e.u_scale),u_fade:new Ja(t,e.u_fade)}),fill:(t,e)=>({u_fill_translate:new Ka(t,e.u_fill_translate)}),fillPattern:(t,e)=>({u_image:new Xa(t,e.u_image),u_texsize:new Ka(t,e.u_texsize),u_pixel_coord_upper:new Ka(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Ka(t,e.u_pixel_coord_lower),u_scale:new Qa(t,e.u_scale),u_fade:new Ja(t,e.u_fade),u_sdf_pattern:new Xa(t,e.u_sdf_pattern),u_fill_translate:new Ka(t,e.u_fill_translate)}),fillOutline:(t,e)=>({u_fill_translate:new Ka(t,e.u_fill_translate)}),fillOutlinePattern:(t,e)=>({u_image:new Xa(t,e.u_image),u_texsize:new Ka(t,e.u_texsize),u_pixel_coord_upper:new Ka(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Ka(t,e.u_pixel_coord_lower),u_scale:new Qa(t,e.u_scale),u_fade:new Ja(t,e.u_fade),u_sdf_pattern:new Xa(t,e.u_sdf_pattern),u_fill_translate:new Ka(t,e.u_fill_translate)}),circle:(t,e)=>({u_scale_with_map:new Xa(t,e.u_scale_with_map),u_pitch_with_map:new Xa(t,e.u_pitch_with_map),u_extrude_scale:new Ka(t,e.u_extrude_scale),u_globe_extrude_scale:new Ja(t,e.u_globe_extrude_scale),u_translate:new Ka(t,e.u_translate)}),collisionBox:Nb,collisionCircle:Nb,debug:(t,e)=>({u_color:new el(t,e.u_color),u_overlay:new Xa(t,e.u_overlay),u_overlay_scale:new Ja(t,e.u_overlay_scale)}),depth:Nb,clippingMask:Nb,heatmap:(t,e)=>({u_extrude_scale:new Ja(t,e.u_extrude_scale),u_intensity:new Ja(t,e.u_intensity),u_globe_extrude_scale:new Ja(t,e.u_globe_extrude_scale)}),heatmapTexture:(t,e)=>({u_matrix:new sl(t,e.u_matrix),u_image:new Xa(t,e.u_image),u_color_ramp:new Xa(t,e.u_color_ramp),u_opacity:new Ja(t,e.u_opacity)}),hillshade:(t,e)=>({u_image:new Xa(t,e.u_image),u_latrange:new Ka(t,e.u_latrange),u_exaggeration:new Ja(t,e.u_exaggeration),u_altitudes:new rl(t,e.u_altitudes),u_azimuths:new rl(t,e.u_azimuths),u_accent:new el(t,e.u_accent),u_method:new Xa(t,e.u_method),u_shadows:new il(t,e.u_shadows),u_highlights:new il(t,e.u_highlights)}),hillshadePrepare:(t,e)=>({u_matrix:new sl(t,e.u_matrix),u_image:new Xa(t,e.u_image),u_dimension:new Ka(t,e.u_dimension),u_zoom:new Ja(t,e.u_zoom),u_unpack:new tl(t,e.u_unpack)}),colorRelief:(t,e)=>({u_image:new Xa(t,e.u_image),u_unpack:new tl(t,e.u_unpack),u_dimension:new Ka(t,e.u_dimension),u_elevation_stops:new Xa(t,e.u_elevation_stops),u_color_stops:new Xa(t,e.u_color_stops),u_color_ramp_size:new Xa(t,e.u_color_ramp_size),u_opacity:new Ja(t,e.u_opacity)}),line:(t,e)=>({u_translation:new Ka(t,e.u_translation),u_ratio:new Ja(t,e.u_ratio)}),lineGradient:(t,e)=>({u_translation:new Ka(t,e.u_translation),u_ratio:new Ja(t,e.u_ratio),u_image:new Xa(t,e.u_image),u_image_height:new Ja(t,e.u_image_height)}),linePattern:(t,e)=>({u_translation:new Ka(t,e.u_translation),u_texsize:new Ka(t,e.u_texsize),u_ratio:new Ja(t,e.u_ratio),u_image:new Xa(t,e.u_image),u_scale:new Qa(t,e.u_scale),u_fade:new Ja(t,e.u_fade)}),lineSDF:(t,e)=>({u_translation:new Ka(t,e.u_translation),u_ratio:new Ja(t,e.u_ratio),u_image:new Xa(t,e.u_image),u_mix:new Ja(t,e.u_mix),u_tileratio:new Ja(t,e.u_tileratio),u_crossfade_from:new Ja(t,e.u_crossfade_from),u_crossfade_to:new Ja(t,e.u_crossfade_to),u_lineatlas_width:new Ja(t,e.u_lineatlas_width),u_lineatlas_height:new Ja(t,e.u_lineatlas_height)}),lineGradientSDF:(t,e)=>({u_translation:new Ka(t,e.u_translation),u_ratio:new Ja(t,e.u_ratio),u_image:new Xa(t,e.u_image),u_image_height:new Ja(t,e.u_image_height),u_tileratio:new Ja(t,e.u_tileratio),u_crossfade_from:new Ja(t,e.u_crossfade_from),u_crossfade_to:new Ja(t,e.u_crossfade_to),u_image_dash:new Xa(t,e.u_image_dash),u_mix:new Ja(t,e.u_mix),u_lineatlas_width:new Ja(t,e.u_lineatlas_width),u_lineatlas_height:new Ja(t,e.u_lineatlas_height)}),layerOpacity:(t,e)=>({u_image:new Xa(t,e.u_image),u_opacity:new Ja(t,e.u_opacity)}),raster:(t,e)=>({u_tl_parent:new Ka(t,e.u_tl_parent),u_scale_parent:new Ja(t,e.u_scale_parent),u_buffer_scale:new Ja(t,e.u_buffer_scale),u_image_warp:new Qa(t,e.u_image_warp),u_fade_t:new Ja(t,e.u_fade_t),u_opacity:new Ja(t,e.u_opacity),u_image0:new Xa(t,e.u_image0),u_image1:new Xa(t,e.u_image1),u_brightness_low:new Ja(t,e.u_brightness_low),u_brightness_high:new Ja(t,e.u_brightness_high),u_saturation_factor:new Ja(t,e.u_saturation_factor),u_contrast_factor:new Ja(t,e.u_contrast_factor),u_spin_weights:new Qa(t,e.u_spin_weights),u_coords_top:new tl(t,e.u_coords_top),u_coords_bottom:new tl(t,e.u_coords_bottom)}),symbolIcon:(t,e)=>({u_is_size_zoom_constant:new Xa(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Xa(t,e.u_is_size_feature_constant),u_size_t:new Ja(t,e.u_size_t),u_size:new Ja(t,e.u_size),u_rotate_symbol:new Xa(t,e.u_rotate_symbol),u_label_plane_matrix:new sl(t,e.u_label_plane_matrix),u_coord_matrix:new sl(t,e.u_coord_matrix),u_is_text:new Xa(t,e.u_is_text),u_pitch_with_map:new Xa(t,e.u_pitch_with_map),u_is_along_line:new Xa(t,e.u_is_along_line),u_is_variable_anchor:new Xa(t,e.u_is_variable_anchor),u_texsize:new Ka(t,e.u_texsize),u_texture:new Xa(t,e.u_texture),u_translation:new Ka(t,e.u_translation),u_pitched_scale:new Ja(t,e.u_pitched_scale),u_is_offset:new Xa(t,e.u_is_offset),u_height_anchor_ground:new Xa(t,e.u_height_anchor_ground)}),symbolSDF:(t,e)=>({u_is_size_zoom_constant:new Xa(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Xa(t,e.u_is_size_feature_constant),u_size_t:new Ja(t,e.u_size_t),u_size:new Ja(t,e.u_size),u_rotate_symbol:new Xa(t,e.u_rotate_symbol),u_label_plane_matrix:new sl(t,e.u_label_plane_matrix),u_coord_matrix:new sl(t,e.u_coord_matrix),u_is_text:new Xa(t,e.u_is_text),u_pitch_with_map:new Xa(t,e.u_pitch_with_map),u_is_along_line:new Xa(t,e.u_is_along_line),u_is_variable_anchor:new Xa(t,e.u_is_variable_anchor),u_texsize:new Ka(t,e.u_texsize),u_texture:new Xa(t,e.u_texture),u_gamma_scale:new Ja(t,e.u_gamma_scale),u_is_halo:new Xa(t,e.u_is_halo),u_is_plain:new Xa(t,e.u_is_plain),u_translation:new Ka(t,e.u_translation),u_pitched_scale:new Ja(t,e.u_pitched_scale),u_is_offset:new Xa(t,e.u_is_offset),u_height_anchor_ground:new Xa(t,e.u_height_anchor_ground)}),symbolTextAndIcon:(t,e)=>({u_is_size_zoom_constant:new Xa(t,e.u_is_size_zoom_constant),u_is_size_feature_constant:new Xa(t,e.u_is_size_feature_constant),u_size_t:new Ja(t,e.u_size_t),u_size:new Ja(t,e.u_size),u_rotate_symbol:new Xa(t,e.u_rotate_symbol),u_label_plane_matrix:new sl(t,e.u_label_plane_matrix),u_coord_matrix:new sl(t,e.u_coord_matrix),u_is_text:new Xa(t,e.u_is_text),u_pitch_with_map:new Xa(t,e.u_pitch_with_map),u_is_along_line:new Xa(t,e.u_is_along_line),u_is_variable_anchor:new Xa(t,e.u_is_variable_anchor),u_texsize:new Ka(t,e.u_texsize),u_texsize_icon:new Ka(t,e.u_texsize_icon),u_texture:new Xa(t,e.u_texture),u_texture_icon:new Xa(t,e.u_texture_icon),u_gamma_scale:new Ja(t,e.u_gamma_scale),u_is_halo:new Xa(t,e.u_is_halo),u_translation:new Ka(t,e.u_translation),u_pitched_scale:new Ja(t,e.u_pitched_scale),u_is_offset:new Xa(t,e.u_is_offset),u_height_anchor_ground:new Xa(t,e.u_height_anchor_ground)}),background:(t,e)=>({u_opacity:new Ja(t,e.u_opacity),u_color:new el(t,e.u_color)}),backgroundPattern:(t,e)=>({u_opacity:new Ja(t,e.u_opacity),u_image:new Xa(t,e.u_image),u_pattern_tl_a:new Ka(t,e.u_pattern_tl_a),u_pattern_br_a:new Ka(t,e.u_pattern_br_a),u_pattern_tl_b:new Ka(t,e.u_pattern_tl_b),u_pattern_br_b:new Ka(t,e.u_pattern_br_b),u_texsize:new Ka(t,e.u_texsize),u_mix:new Ja(t,e.u_mix),u_pattern_size_a:new Ka(t,e.u_pattern_size_a),u_pattern_size_b:new Ka(t,e.u_pattern_size_b),u_scale_a:new Ja(t,e.u_scale_a),u_scale_b:new Ja(t,e.u_scale_b),u_pixel_coord_upper:new Ka(t,e.u_pixel_coord_upper),u_pixel_coord_lower:new Ka(t,e.u_pixel_coord_lower),u_tile_units_to_pixels:new Ja(t,e.u_tile_units_to_pixels)}),terrain:(t,e)=>({u_texture:new Xa(t,e.u_texture),u_ele_delta:new Ja(t,e.u_ele_delta),u_fog_matrix:new sl(t,e.u_fog_matrix),u_fog_color:new el(t,e.u_fog_color),u_fog_ground_blend:new Ja(t,e.u_fog_ground_blend),u_fog_ground_blend_opacity:new Ja(t,e.u_fog_ground_blend_opacity),u_horizon_color:new el(t,e.u_horizon_color),u_horizon_fog_blend:new Ja(t,e.u_horizon_fog_blend),u_is_globe_mode:new Ja(t,e.u_is_globe_mode)}),terrainDepth:(t,e)=>({u_ele_delta:new Ja(t,e.u_ele_delta)}),atmosphere:(t,e)=>({u_sun_pos:new Qa(t,e.u_sun_pos),u_atmosphere_blend:new Ja(t,e.u_atmosphere_blend),u_globe_position:new Qa(t,e.u_globe_position),u_globe_radius:new Ja(t,e.u_globe_radius),u_inv_proj_matrix:new sl(t,e.u_inv_proj_matrix)}),sky:(t,e)=>({u_sky_color:new el(t,e.u_sky_color),u_horizon_color:new el(t,e.u_horizon_color),u_horizon:new Ka(t,e.u_horizon),u_horizon_normal:new Ka(t,e.u_horizon_normal),u_sky_horizon_blend:new Ja(t,e.u_sky_horizon_blend),u_sky_blend:new Ja(t,e.u_sky_blend),u_inv_proj_matrix:new sl(t,e.u_inv_proj_matrix),u_globe_position:new Qa(t,e.u_globe_position),u_globe_radius:new Ja(t,e.u_globe_radius)})};var qb=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 Vb={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[Vb[r.type]],this.itemSize,e):t.vertexAttribPointer(n.location,r.components,t[Vb[r.type]],!1,this.itemSize,e)}}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}},Wb=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)}},Hb=class extends Wb{getDefault(){return fi.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)}},Yb=class extends Wb{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}},Xb=class extends Wb{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}},Jb=class extends Wb{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)}},Kb=class extends Wb{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}},Qb=class extends Wb{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}},tx=class extends Wb{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)}},ex=class extends Wb{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)}},ix=class extends Wb{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}},rx=class extends Wb{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)}},nx=class extends Wb{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}},sx=class extends Wb{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}},ox=class extends Wb{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}},ax=class extends Wb{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)}},lx=class extends Wb{getDefault(){return fi.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)}},hx=class extends Wb{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}},ux=class extends Wb{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}},cx=class extends Wb{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}},fx=class extends Wb{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}},px=class extends Wb{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}},dx=class extends Wb{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}},mx=class extends Wb{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)}},_x=class extends Wb{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}},gx=class extends Wb{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}},yx=class extends Wb{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}},vx=class extends Wb{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}},wx=class extends Wb{getDefault(){return null}set(t){let e=this.gl;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}},bx=class extends Wb{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.bindVertexArray(t),this.current=t,this.dirty=!1)}},xx=class extends Wb{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}},Dx=class extends Wb{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}},Mx=class extends Wb{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}},Ex=class extends Wb{constructor(t,e){super(t),this.context=t,this.parent=e}getDefault(){return null}},Ax=class extends Ex{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}},Fx=class extends Ex{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}},Sx=class extends Ex{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}},Cx=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 Ax(t,s),r)this.depthAttachment=n?new Sx(t,s):new Fx(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 zx=ab([{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"}]),Tx=zx.offsets;var Px=class{constructor(t,e,i){this.blendFunction=t,this.blendColor=e,this.mask=i}};Px.Replace=[1,0],Px.disabled=new Px(Px.Replace,fi.transparent,[!1,!1,!1,!1]),Px.unblended=new Px(Px.Replace,fi.transparent,[!0,!0,!0,!0]),Px.alphaBlended=new Px([1,771],fi.transparent,[!0,!0,!0,!0]);var Ix=class{constructor(t){this.gl=t,this.clearColor=new Hb(this),this.clearDepth=new Yb(this),this.clearStencil=new Xb(this),this.colorMask=new Jb(this),this.depthMask=new Kb(this),this.stencilMask=new Qb(this),this.stencilFunc=new tx(this),this.stencilOp=new ex(this),this.stencilTest=new ix(this),this.depthRange=new rx(this),this.depthTest=new nx(this),this.depthFunc=new sx(this),this.blend=new ox(this),this.blendFunc=new ax(this),this.blendColor=new lx(this),this.blendEquation=new hx(this),this.cullFace=new ux(this),this.cullFaceSide=new cx(this),this.frontFace=new fx(this),this.program=new px(this),this.activeTexture=new dx(this),this.viewport=new mx(this),this.bindFramebuffer=new _x(this),this.bindRenderbuffer=new gx(this),this.bindTexture=new yx(this),this.bindVertexBuffer=new vx(this),this.bindElementBuffer=new wx(this),this.bindVertexArray=new bx(this),this.pixelStoreUnpack=new xx(this),this.pixelStoreUnpackPremultiplyAlpha=new Dx(this),this.pixelStoreUnpackFlipY=new Mx(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.projectionUniformBuffer=function(t){return new lb(t,sb.ProjectionUBO,hb)}(this),this.terrainUniformBuffer=function(t){return new lb(t,sb.TerrainUBO,cb)}(this),this.frameUniformBuffer=function(t){return new lb(t,sb.FrameUBO,zx)}(this)}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.projectionUniformBuffer.bindingDirty=!0,this.terrainUniformBuffer.bindingDirty=!0,this.frameUniformBuffer.bindingDirty=!0}setCustomLayerDefaults(){this.unbindVAO(),this.cullFace.setDefault(),this.activeTexture.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}createIndexBuffer(t,e){return new qb(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 Cx(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){Pt(t.blendFunction,Px.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)}},kx=class{constructor(t,e,i){this.func=t,this.mask=e,this.range=i}};kx.ReadOnly=!1,kx.ReadWrite=!0,kx.disabled=new kx(519,kx.ReadOnly,[0,1]);const $x=7680;var jx=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}};jx.disabled=new jx({func:519,mask:0},0,0,$x,$x,$x);const Rx=2305;var Ox=class{constructor(t,e,i){this.enable=t,this.mode=e,this.frontFace=i}};let Bx;function Lx(t,e,i,r,n){let s=t.context,o=t.transform,a=s.gl,l=t.useProgram("collisionBox"),h=[],u=0,c=0;for(let f of r){let r=e.getTile(f).getBucket(i);if(!r)continue;let p=n?r.textCollisionBox:r.iconCollisionBox,d=r.collisionCircleArray;d.length>0&&(h.push({circleArray:d,circleOffset:c,coord:f}),u+=d.length/4,c=u),p&&l.draw(s,a.LINES,kx.disabled,jx.disabled,t.colorModeForRenderPass(),Ox.disabled,null,t.style.map.terrain?.getTerrainData(f),o.getProjectionData({overscaledTileID:f,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),i.id,p.layoutVertexBuffer,p.indexBuffer,p.segments,null,t.transform.zoom,null,null,p.collisionVertexBuffer)}if(!n||!h.length)return;let f=t.useProgram("collisionCircle"),p=new Ta;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)}(!Bx||Bx.length<2*u)&&(Bx=function(t){let e=2*t,i=new Ia;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=s.createIndexBuffer(Bx,!0),_=s.createVertexBuffer(p,Sc.members,!0);for(let e of h)f.draw(s,a.TRIANGLES,kx.disabled,jx.disabled,t.colorModeForRenderPass(),Ox.disabled,null,t.style.map.terrain?.getTerrainData(e.coord),null,i.id,_,m,Oa.simpleSegment(0,2*e.circleOffset,e.circleArray.length,e.circleArray.length/2),null,t.transform.zoom,null,null,null);_.destroy(),m.destroy()}Ox.disabled=new Ox(!1,1029,Rx),Ox.backCCW=new Ox(!0,1029,Rx),Ox.frontCCW=new Ox(!0,1028,Rx);const Ux=g(new Float32Array(16));function Nx(t,e,i,r,n,s){let{horizontalAlign:o,verticalAlign:a}=Lf(t);return new l((-(o-.5)*e/n+r[0])*s,(-(a-.5)*i/n+r[1])*s)}function Gx(t,e,i,r,n,s){let o=e.tileAnchorPoint.add(new l(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 nv(a.x,a.y,e.pitchedLabelPlaneMatrix,rv(e,a.x,a.y)).point}if(i){let i=pv(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 qx(t,e,i,r,n,s,o,a,h,u,c,f,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 l(y.anchorX,y.anchorY),d={getElevation:f,heightOffset:y.heightOffset,heightAnchorGround:p,width:n.width,height:n.height,pitchedLabelPlaneMatrix:s,pitchWithMap:i,transform:n,tileAnchorPoint:r,translation:u,unwrappedTileID:c},_=i?mv(r.x,r.y,d):pv(r.x,r.y,d),w=sv(n.cameraToCenterDistance,_.signedDistanceFromCamera),b=ip(t.textSizeData,a,y)*w/24;i&&(b*=t.tilePixelRatio/o);let{width:x,height:D,anchor:M,textOffset:E,textBoxScale:A}=v,F=Nx(M,x,D,E,A,b),S=n.getPitchedTextCorrection(r.x+u[0],r.y+u[1],c),C=Gx(_.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++)jp(m,C,z);h&&y.associatedIconIndex>=0&&(g[y.associatedIconIndex]={shiftedAnchor:C,angle:z})}else wv(y.numGlyphs,m)}if(h){_.clear();let e=t.icon.placedSymbolArray;for(let t=0;t<e.length;t++){let i=e.get(t);if(i.hidden)wv(i.numGlyphs,_);else{let e=g[t];if(e)for(let t=0;t<i.numGlyphs;t++)jp(_,e.shiftedAnchor,e.angle);else wv(i.numGlyphs,_)}}t.icon.dynamicLayoutVertexBuffer.updateData(_)}t.text.dynamicLayoutVertexBuffer.updateData(m)}function Vx(t,e,i){return i.iconsInText&&e?"symbolTextAndIcon":t?"symbolSDF":"symbolIcon"}function Zx(t,e,i,r,n,s,o,a,l,h,u,c,f){let p=t.context,d=p.gl,_=t.transform,g="map"===a,y="map"===l,v="viewport"!==a&&"point"!==i.layout.get("symbol-placement"),w=g&&!y&&!v,b=!i.layout.get("symbol-sort-key").isConstant(),x=!1,D=t.getDepthModeForSublayer(0,kx.ReadOnly),M=i._unevaluatedLayout.hasValue("text-variable-anchor")||i._unevaluatedLayout.hasValue("text-variable-anchor-offset"),E=[],A=_.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=y||0!==_.pitch,P=t.useProgram(Vx(C,n,l),S),I=rp(z,_.zoom),k=t.style.map.terrain?.getTerrainData(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||t.options.rotating||t.options.zooming||"composite"===z.kind||"camera"===z.kind?d.LINEAR:d.NEAREST);else{let e=1!==i.layout.get("icon-size").constantOr(0)||l.iconsNeedLinear;p=r.imageAtlasTexture,D=C||t.options.rotating||t.options.zooming||e||T?d.LINEAR:d.NEAREST,c=r.imageAtlasTexture.size}let R=et(r,1,t.transform.zoom),O=tv(g,t.transform,R),B=ev(y,g,t.transform,R),L=lt(_,r,s,o),U=_.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!f,applyTerrainMatrix:!0}),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(v){let e=m();Ky(e,O);let r=t.style.map.terrain?(e,i)=>t.style.map.terrain.getElevation(a,e,i):void 0;av(l,t,n,O,e,y,h,"map"===i.layout.get("text-rotation-alignment"),a.toUnwrapped(),_.width,_.height,L,r)}let Z,W=n&&M||G,H=v||W?Ux:y?O:t.transform.clipSpaceToPixelsMatrix,Y=C&&0!==i.paint.get(n?"text-halo-width":"icon-halo-width").constantOr(1);Z=C?l.iconsInText?Bb(z.kind,I,w,y,v,W,t,H,B,L,c,$,A,q,V):Ob(z.kind,I,w,y,v,W,t,H,B,L,n,c,Y,A,q,V):Rb(z.kind,I,w,y,v,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 Oa([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,Wx(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)}Wx(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 Wx(t,e,i,r,n,s,o,a,l,h,u){let c=r.context;n.draw(c,c.gl.TRIANGLES,s,o,a,Ox.backCCW,l,u,h,i.id,t.layoutVertexBuffer,t.indexBuffer,e,i.paint,r.transform.zoom,t.programConfigurations.get(i.id),t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer)}function Hx(t,e,i,r,n){let s=t.context,o=s.gl,a=jx.disabled,l=new Px([o.ONE,o.ONE],fi.transparent,[!0,!0,!0,!0]),h=e.getBucket(i);if(!h)return;let u=r.key,c=i.heatmapFbos.get(u);c||(c=Xx(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:fi.transparent});let f=h.programConfigurations.get(i.id),p=t.useProgram("heatmap",f,!n),d=t.transform.getProjectionData({overscaledTileID:e.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),m=t.style.map.terrain.getTerrainData(r);p.draw(s,o.TRIANGLES,kx.disabled,a,l,Ox.disabled,Mb(e,t.transform.zoom,i.paint.get("heatmap-intensity"),1),m,d,i.id,h.layoutVertexBuffer,h.indexBuffer,h.segments,i.paint,t.transform.zoom,f)}function Yx(t,e,i,r,n){let s=t.context,o=s.gl,a=t.transform;s.setColorMode(t.colorModeForRenderPass());let l=Jx(s,e),h=i.key,u=e.heatmapFbos.get(h);if(!u)return;s.activeTexture.set(o.TEXTURE0),o.bindTexture(o.TEXTURE_2D,u.colorAttachment.get()),s.activeTexture.set(o.TEXTURE1),l.bind(o.LINEAR,o.CLAMP_TO_EDGE);let c=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});t.useProgram("heatmapTexture").draw(s,o.TRIANGLES,kx.disabled,jx.disabled,t.colorModeForRenderPass(),Ox.disabled,Eb(t,e,0,1),null,c,e.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments,e.paint,a.zoom),u.destroy(),e.heatmapFbos.delete(h)}function Xx(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 Jx(t,e){return e.colorRampTexture||=new dh(t,e.colorRamp,t.gl.RGBA),e.colorRampTexture}function Kx(t,e,i,r){let n=t.context,s=n.bindFramebuffer.get(),o=n.viewport.get(),[,,a,l]=o;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,a,l),n.viewport.set([0,0,a,l]),n.clear({color:fi.transparent,depth:1,stencil:0}),t.currentStencilSource=void 0,t.renderTileClippingMasks(e,i,r),{compositeTarget:s,compositeViewport:o}}function Qx(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.useProgram("layerOpacity").draw(n,s.TRIANGLES,kx.disabled,jx.disabled,t.colorModeForRenderPass(),Ox.disabled,(t=>({u_image:0,u_opacity:t}))(e),null,null,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,r.paint,t.transform.zoom),t.currentStencilSource=void 0}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.transform.maxZoom-o.canonical.z):1;l=bt(function(t){return t<=1?1:2**Math.ceil(Math.log(t)/Math.LN2)}(s.maxLineLength/tt*1024*n),256,i.maxTextureSize)}return a.gradient=sh({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 dh(i,a.gradient,r.RGBA),a.version=n.gradientVersion,a.texture}function eD(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 rD(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 nD(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 sD(t,e,i,r,n,s){let o,{isRenderingToTexture:a}=n,l=t.getDepthModeForSublayer(0,kx.ReadOnly),h=t.colorModeForRenderPass(),u=i.paint.get("line-dasharray"),c=u.constantOr(1),f=i.paint.get("line-pattern"),p=f.constantOr(1),d=i.paint.get("line-gradient"),m=i.getCrossfadeParameters();o=p?"linePattern":c&&d?"lineGradientSDF":c?"lineSDF":d?"lineGradient":"line";let _=t.context,g=_.gl,y=t.transform,v=!0;for(let n of r){let r=e.getTile(n);if(p&&!r.patternsLoaded())continue;let w=r.getBucket(i);if(!w)continue;let b=w.programConfigurations.get(i.id),x=t.context.program.get(),D=t.useProgram(o,b),M=v||D.program!==x,E=s?t.getTerrainDataForTile(n,a):null,A=f.constantOr(null),F=u?.constantOr(null);if(A&&r.imageAtlas){let t=r.imageAtlas,e=t.patternPositions[A.to.toString()],i=t.patternPositions[A.from.toString()];e&&i&&b.setConstantPatternPositions(e,i)}else if(F){let e="round"===i.layout.get("line-cap").constantOr(null),r=t.lineAtlas.getDash(F.to,e),n=t.lineAtlas.getDash(F.from,e);b.setConstantDashPositions(r,n)}let S,C=y.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),z=y.getPixelScale();p?(S=Pb(t,r,i,z,m),eD(_,g,r,b,m)):c&&d?(S=kb(t,r,i,z,m,w.lineClipsArray.length),nD(t,e,_,g,i,w,n,b,m)):c?(S=Ib(t,r,i,z,m),iD(t,_,g,b,M,m)):d?(S=Tb(t,r,i,z,w.lineClipsArray.length),rD(t,e,_,g,i,w,n)):S=zb(t,r,i,z);let T=t.stencilModeForClipping(n);D.draw(_,g.TRIANGLES,l,T,h,Ox.disabled,S,E,C,i.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,i.paint,t.transform.zoom,b,w.layoutVertexBuffer2),v=!1}}function oD(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 aD(t,e,i,r,n){let{isRenderingToTexture:s}=n,o=t.colorModeForRenderPass();hD(t,e,i,r,t.getDepthModeForSublayer(1,kx.ReadOnly),o,!1,s),lD(t,e,i,r,n)}function lD(t,e,i,r,n){if(!i.paint.get("fill-antialias"))return;let{isRenderingToTexture:s}=n,o=t.colorModeForRenderPass();hD(t,e,i,r,t.getDepthModeForSublayer(i.getPaintProperty("fill-outline-color")?2:0,kx.ReadOnly),o,!0,s)}function hD(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=t.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=t.useProgram(h,M),A=t.getTerrainDataForTile(m,a);_&&(t.context.activeTexture.set(p.TEXTURE0),r.imageAtlasTexture.bind(p.LINEAR,p.CLAMP_TO_EDGE),M.updatePaintBuffers(g)),oD(M,d,b,r,i);let F=y.getProjectionData({overscaledTileID:m,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),S=lt(y,r,v,w);o?(c=x.indexBuffer2,f=x.segments2,u="fillOutlinePattern"===h&&_?bb(t,g,r,S,D):wb(S)):(c=x.indexBuffer,f=x.segments,u=_?yb(t,g,r,S,D):vb(S));let C=t.stencilModeForClipping(m);E.draw(t.context,l,n,C,s,Ox.backCCW,u,A,F,i.id,x.layoutVertexBuffer,c,f,i.paint,t.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),_=t.transform;for(let c of r){let r=e.getTile(c),g=r.getBucket(i);if(!g)continue;let y=t.style.map.terrain?.getTerrainData(c),v=g.programConfigurations.get(i.id),w=t.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=_.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!a,applyTerrainMatrix:!0});oD(v,u,m,r,i);let x=lt(_,r,i.paint.get("fill-extrusion-translate"),i.paint.get("fill-extrusion-translate-anchor")),D=i.paint.get("fill-extrusion-vertical-gradient"),M=f?gb(t,D,d,x,c,p,r):_b(t,D,d,x);w.draw(l,l.gl.TRIANGLES,n,s,o,Ox.backCCW,M,y,b,i.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,i.paint,t.transform.zoom,v,t.style.map.terrain&&g.centroidVertexBuffer)}}function cD(t,e,i,r,n,s,o,a,l){let h=t.style.projection,u=t.context,c=t.transform,f=u.gl,p=[`#define NUM_ILLUMINATION_SOURCES ${i.paint.get("hillshade-highlight-color").values.length}`],d=t.useProgram("hillshade",null,!1,p),m=!t.options.moving;for(let p of r){let r=e.getTile(p),_=r.fbo;if(!_)continue;let g=h.getMeshFromTileID(u,p.canonical,a,!0,"raster"),y=t.getTerrainDataForTile(p,l);u.activeTexture.set(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,_.colorAttachment.get());let v=c.getProjectionData({overscaledTileID:p,aligned:m,applyGlobeMatrix:!l,applyTerrainMatrix:!0});d.draw(u,f.TRIANGLES,s,n[p.overscaledZ],o,Ox.backCCW,Ab(t,r,i),y,v,i.id,g.vertexBuffer,g.indexBuffer,g.segments)}}let fD=0;function pD(t,e,i,r,n,s,o,a,l){let h=t.style.projection,u=t.context,c=t.transform,f=u.gl,p=t.useProgram("colorRelief"),d=!t.options.moving,m="nearest"===i.paint.get("resampling")?f.NEAREST:f.LINEAR,_=!0,g=0;for(let y of r){let r=e.getTile(y),v=r.dem;if(!v?.data)continue;if(_){fD||=f.getParameter(f.MAX_TEXTURE_SIZE);let t=fD,{elevationTexture:e,colorTexture:r}=i.getColorRampTextures(u,t,v.getUnpackVector());u.activeTexture.set(f.TEXTURE1),e.bind(f.NEAREST,f.CLAMP_TO_EDGE),u.activeTexture.set(f.TEXTURE4),r.bind(f.LINEAR,f.CLAMP_TO_EDGE),_=!1,g=e.size[0]}let w=v.stride;u.activeTexture.set(f.TEXTURE0),(!r.demTexture||r.needsColorReliefPrepare)&&(u.pixelStoreUnpackPremultiplyAlpha.set(!1),r.demTexture||=t.getTileTexture(w)??new dh(u,{width:w,height:w,data:null},f.RGBA),r.demTexture.update(v.getPixels(),{premultiply:!1}),r.needsColorReliefPrepare=!1),r.demTexture.bind(m,f.CLAMP_TO_EDGE);let b=h.getMeshFromTileID(u,y.canonical,a,!0,"raster"),x=t.getTerrainDataForTile(y,l),D=c.getProjectionData({overscaledTileID:y,aligned:d,applyGlobeMatrix:!l,applyTerrainMatrix:!0});p.draw(u,f.TRIANGLES,s,n[y.overscaledZ],o,Ox.backCCW,Cb(i,r.dem,g),x,D,i.id,b.vertexBuffer,b.indexBuffer,b.segments)}}const dD=[new l(0,0),new l(tt,0),new l(tt,tt),new l(0,tt)];function mD(t,e,i,r,n,s,o,a,l,h=!1,u=!1,c=null){let f=r[r.length-1].overscaledZ,p=t.context,d=p.gl,m=t.useProgram("raster"),_=t.transform,g=t.style.projection,y=t.colorModeForRenderPass(),v=!t.options.moving,w=i.paint.get("raster-opacity"),b="nearest"===i.paint.get("resampling")||"nearest"===i.paint.get("raster-resampling")?d.NEAREST:d.LINEAR,x=i.paint.get("raster-fade-duration"),D=!!t.style.map.terrain;for(let M of r){let r=t.getDepthModeForSublayer(M.overscaledZ-f,1===w?kx.ReadWrite:kx.ReadOnly,d.LESS),E=e.getTile(M);p.activeTexture.set(d.TEXTURE0),E.texture.bind(b,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),p.activeTexture.set(d.TEXTURE1);let{parentTile:A,parentScaleBy:F,parentTopLeft:S,fadeValues:C}=_D(E,e,x,D);E.fadeOpacity=C.tileOpacity,A?(A.fadeOpacity=C.parentTileOpacity,A.texture.bind(b,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST)):E.texture.bind(b,d.CLAMP_TO_EDGE,d.LINEAR_MIPMAP_NEAREST),E.texture.useMipmap&&p.extTextureFilterAnisotropic&&t.transform.pitch>t.options.anisotropicFilterPitch&&d.texParameterf(d.TEXTURE_2D,p.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,p.extTextureFilterAnisotropicMax);let z=t.getTerrainDataForTile(M,u),T=_.getProjectionData({overscaledTileID:M,aligned:v,applyGlobeMatrix:!u,applyTerrainMatrix:!0}),P=fy(S,F,C.fadeMix,i,a,l),I=c??g.getMeshFromTileID(p,M.canonical,s,o,"raster");m.draw(p,d.TRIANGLES,r,n?n[M.overscaledZ]:jx.disabled,y,h?Ox.frontCCW:Ox.backCCW,P,z,T,i.id,I.vertexBuffer,I.indexBuffer,I.segments)}}function _D(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:gD(t,r,i)}}return t.selfFading?{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:yD(t,i)}:n}function gD(t,e,i){let r=U_(),n=(r-e.timeAdded)/i,s=1===t.fadingDirection,o=bt((r-t.timeAdded)/i,0,1),a=bt(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=bt((U_()-t.timeAdded)/e,0,1);return{tileOpacity:i,fadeMix:{opacity:i,mix:0}}}const vD=new fi(1,0,0,1),wD=new fi(0,1,0,1),bD=new fi(0,0,1,1),xD=new fi(1,0,1,1),DD=new fi(0,1,1,1);function MD(t,e,i,r){AD(t,0,e+i/2,t.transform.width,i,r)}function ED(t,e,i,r){AD(t,e-i/2,0,i,t.transform.height,r)}function AD(t,e,i,r,n,s){let o=t.context,a=o.gl;a.enable(a.SCISSOR_TEST),a.scissor(e*t.pixelRatio,i*t.pixelRatio,r*t.pixelRatio,n*t.pixelRatio),o.clear({color:s}),a.disable(a.SCISSOR_TEST)}function FD(t,e,i){let r=t.context,n=r.gl,s=t.useProgram("debug"),o=kx.disabled,a=jx.disabled,l=t.colorModeForRenderPass(),h="$debug",u=t.style.map.terrain?.getTerrainData(i);r.activeTexture.set(n.TEXTURE0);let c=e.getTileByID(i.key).latestRawTileData?.byteLength||0,f=Math.floor(c/1024),p=e.getTile(i).tileSize,d=512/Math.min(p,512)*(i.overscaledZ/t.transform.zoom)*.5,m=i.canonical.toString();i.overscaledZ!==i.canonical.z&&(m+=` => ${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,`${m} ${f}kB`);let _=t.transform.getProjectionData({overscaledTileID:i,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,n.TRIANGLES,o,a,Px.alphaBlended,Ox.disabled,Db(fi.transparent,d),null,_,h,t.debugBuffer,t.quadTriangleIndexBuffer,t.debugSegments),s.draw(r,n.LINE_STRIP,o,a,l,Ox.disabled,Db(fi.red),u,_,h,t.debugBuffer,t.tileBorderIndexBuffer,t.debugSegments)}function SD(t,e){if(!e.mesh){let i=new ga;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1);let r=new ka;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),e.mesh=new _y(t.createVertexBuffer(i,gy.members),t.createIndexBuffer(r),Oa.simpleSegment(0,0,i.length,r.length))}return e.mesh}const CD={symbol:function(t,e,i,r,n,s){if("translucent"!==s.currentPass)return;let{isRenderingToTexture:o}=s,a=jx.disabled,l=t.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.transform,u=e.style.map.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=rp(s.textSizeData,h.zoom),d=et(t,1,e.transform.zoom),m=tv(c,e.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;qx(s,c,f,l,h,m,2**(h.zoom-t.tileID.overscaledZ),p,_,lt(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),0!==i.paint.get("icon-opacity").constantOr(1)&&Zx(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"),a,l,o),0!==i.paint.get("text-opacity").constantOr(1)&&Zx(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"),a,l,o),e.map.showCollisionBoxes&&(Lx(t,e,i,r,!0),Lx(t,e,i,r,!1))},circle:function(t,e,i,r,n){if("translucent"!==n.currentPass)return;let{isRenderingToTexture:s}=n,o=i.paint.get("circle-opacity"),a=i.paint.get("circle-stroke-width"),l=i.paint.get("circle-stroke-opacity"),h=!i.layout.get("circle-sort-key").isConstant();if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===l.constantOr(1)))return;let u=t.context,c=u.gl,f=t.transform,p=t.getDepthModeForSublayer(0,kx.ReadOnly),d=jx.disabled,m=t.colorModeForRenderPass(),_=[],g=f.getCircleRadiusCorrection();for(let n of r){let r=e.getTile(n),o=r.getBucket(i);if(!o)continue;let a=lt(f,r,i.paint.get("circle-translate"),i.paint.get("circle-translate-anchor")),l=o.programConfigurations.get(i.id),u=t.useProgram("circle",l),c=o.layoutVertexBuffer,p=o.indexBuffer,d=t.style.map.terrain?.getTerrainData(n),m={programConfiguration:l,program:u,layoutVertexBuffer:c,indexBuffer:p,uniformValues:xb(t,r,i,a,g),terrainData:d,projectionData:f.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!s,applyTerrainMatrix:!0})};if(h){let t=o.segments.get();for(let e of t)_.push({segments:new Oa([e]),sortKey:e.sortKey,state:m})}else _.push({segments:o.segments,sortKey:0,state:m})}h&&_.sort(((t,e)=>t.sortKey-e.sortKey));for(let e of _){let{programConfiguration:r,program:n,layoutVertexBuffer:s,indexBuffer:o,uniformValues:a,terrainData:l,projectionData:h}=e.state;n.draw(u,c.TRIANGLES,p,d,m,Ox.backCCW,a,l,h,i.id,s,o,e.segments,i.paint,t.transform.zoom,r)}},heatmap:function(t,e,i,r,n){if(0===i.paint.get("heatmap-opacity"))return;let s=t.context,{isRenderingToTexture:o,isRenderingGlobe:a}=n;if(t.style.map.terrain){for(let s of r){let r=e.getTile(s);e.hasRenderableParent(s)||("offscreen"===n.currentPass?Hx(t,r,i,s,a):"translucent"===n.currentPass&&Yx(t,i,s,o,a))}s.viewport.set([0,0,t.width,t.height])}else"offscreen"===n.currentPass?function(t,e,i,r){let n=t.context,s=n.gl,o=t.transform,a=jx.disabled,l=new Px([s.ONE,s.ONE],fi.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(oh);n?(r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),t.bindFramebuffer.set(n.framebuffer)):(n=Xx(t,e.width/4,e.height/4),i.heatmapFbos.set(oh,n))})(n,t,i),n.clear({color:fi.transparent});for(let h of r){if(e.hasRenderableParent(h))continue;let r=e.getTile(h),u=r.getBucket(i);if(!u)continue;let c=u.programConfigurations.get(i.id),f=t.useProgram("heatmap",c),p=o.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!0,applyTerrainMatrix:!1}),d=o.getCircleRadiusCorrection();f.draw(n,s.TRIANGLES,kx.disabled,a,l,Ox.backCCW,Mb(r,o.zoom,i.paint.get("heatmap-intensity"),d),null,p,i.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,i.paint,o.zoom,c)}n.viewport.set([0,0,t.width,t.height])}(t,e,i,r):"translucent"===n.currentPass&&function(t,e){let i=t.context,r=i.gl;i.setColorMode(t.colorModeForRenderPass());let n=e.heatmapFbos.get(oh);n&&(i.activeTexture.set(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.colorAttachment.get()),i.activeTexture.set(r.TEXTURE1),Jx(i,e).bind(r.LINEAR,r.CLAMP_TO_EDGE),t.useProgram("heatmapTexture").draw(i,r.TRIANGLES,kx.disabled,jx.disabled,t.colorModeForRenderPass(),Ox.disabled,Eb(t,e,0,1),null,null,e.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,e.paint,t.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)return;let l=!!t.style.map.terrain;if(a<1){let s=Kx(t,i,r,l);return sD(t,e,i,r,n,l),void Qx(t,a,s,i)}sD(t,e,i,r,n,l)},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=Kx(t,i,r,!!t.style.map.terrain);return aD(t,e,i,r,n),void Qx(t,a,s,i)}let l=i.paint.get("fill-pattern"),h=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===s.constantOr(fi.transparent).a&&1===o.constantOr(0);if(h&&"opaque"===n.currentPass){let{isRenderingToTexture:s}=n,o=t.colorModeForRenderPass();hD(t,e,i,r,t.getDepthModeForSublayer(1,kx.ReadWrite),o,!1,s)}else h&&"translucent"===n.currentPass?lD(t,e,i,r,n):"translucent"===n.currentPass&&aD(t,e,i,r,n)},fillExtrusion:function(t,e,i,r,n){let s=i.paint.get("fill-extrusion-opacity");if(0===s)return;let{isRenderingToTexture:o}=n;if("translucent"===n.currentPass){let a=new kx(t.context.gl.LEQUAL,kx.ReadWrite,n.depthRangeFor3D);if(1!==s||i.paint.get("fill-extrusion-pattern").constantOr(1))uD(t,e,i,r,a,jx.disabled,Px.disabled,o),uD(t,e,i,r,a,t.stencilModeFor3D(),t.colorModeForRenderPass(),o);else{let n=t.colorModeForRenderPass();uD(t,e,i,r,a,jx.disabled,n,o)}}},hillshade:function(t,e,i,r,n){if("offscreen"!==n.currentPass&&"translucent"!==n.currentPass)return;let{isRenderingToTexture:s}=n,o=t.context,a=t.style.projection.useSubdivision,l=t.getDepthModeForSublayer(0,kx.ReadOnly),h=t.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 dh(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 dh(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.useProgram("hillshadePrepare").draw(a,l.TRIANGLES,n,s,o,Ox.disabled,Fb(i.tileID,c),null,null,r.id,t.rasterBoundsBuffer,t.quadTriangleIndexBuffer,t.rasterBoundsSegments),i.needsHillshadePrepare=!1}})(t,e,r,i,l,jx.disabled,h),o.viewport.set([0,0,t.width,t.height]);else if("translucent"===n.currentPass)if(a){let[n,o,a]=t.stencilConfigForOverlapTwoPass(r);cD(t,e,i,a,n,l,h,!1,s),cD(t,e,i,a,o,l,h,!0,s)}else{let[n,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);cD(t,e,i,o,n,l,h,!1,s)}},colorRelief:function(t,e,i,r,n){if("translucent"!==n.currentPass||!r.length)return;let{isRenderingToTexture:s}=n,o=t.style.projection.useSubdivision,a=t.getDepthModeForSublayer(0,kx.ReadOnly),l=t.colorModeForRenderPass();if(o){let[n,o,h]=t.stencilConfigForOverlapTwoPass(r);pD(t,e,i,h,n,a,l,!1,s),pD(t,e,i,h,o,a,l,!0,s)}else{let[n,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);pD(t,e,i,o,n,a,l,!1,s)}},raster:function(t,e,i,r,n){if("translucent"!==n.currentPass||0===i.paint.get("raster-opacity")||!r.length)return;let{isRenderingToTexture:s}=n,o=e.getSource(),a=t.style.projection.useSubdivision;if(o instanceof wy)mD(t,e,i,r,null,!1,!1,o.tileCoords,o.imageWarp,o.flippedWindingOrder,s,o.getMesh(t.context,a));else if(a){let[n,o,a]=t.stencilConfigForOverlapTwoPass(r);mD(t,e,i,a,n,!1,!0,dD,cy,!1,s),mD(t,e,i,a,o,!0,!0,dD,cy,!1,s)}else{let[n,o]=t.getStencilConfigForOverlapAndUpdateStencilID(r);mD(t,e,i,o,n,!1,!0,dD,cy,!1,s)}},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{isRenderingToTexture:a}=n,l=t.context,h=l.gl,u=t.style.projection,c=t.transform,f=c.tileSize,p=i.paint.get("background-pattern");if(t.isPatternMissing(p))return;let d=!p&&1===s.a&&1===o&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(n.currentPass!==d)return;let m=jx.disabled,_=t.getDepthModeForSublayer(0,"opaque"===d?kx.ReadWrite:kx.ReadOnly),g=t.colorModeForRenderPass(),y=t.useProgram(p?"backgroundPattern":"background"),v=r||By(c,{tileSize:f,terrain:t.style.map.terrain});p&&(l.activeTexture.set(h.TEXTURE0),t.patternAtlas.bind(t.context));let w=i.getCrossfadeParameters();for(let e of v){let r=c.getProjectionData({overscaledTileID:e,applyGlobeMatrix:!a,applyTerrainMatrix:!0}),n=p?Ub(o,t,p,{tileID:e,tileSize:f},w):Lb(o,s),d=t.getTerrainDataForTile(e,a),v=u.getMeshFromTileID(l,e.canonical,!1,!0,"raster");y.draw(l,h.TRIANGLES,_,m,g,Ox.backCCW,n,d,r,i.id,v.vertexBuffer,v.indexBuffer,v.segments)}},sky:function(t,e){let i=t.context,r=i.gl,n=((t,e,i)=>{let r=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),s=Yu(e),o=e.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:t.properties.get("sky-color"),u_horizon_color:t.properties.get("horizon-color"),u_horizon:[(e.width/2-s*n)*i,(e.height/2+s*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:t.properties.get("sky-horizon-blend")*e.height/2*i,u_sky_blend:o,u_inv_proj_matrix:e.inverseProjectionMatrix,u_globe_position:Pw(e),u_globe_radius:Tw(e.worldSize,e.center.lat)}})(e,t.transform,t.pixelRatio),s=new kx(r.LEQUAL,kx.ReadWrite,[0,1]),o=jx.disabled,a=t.colorModeForRenderPass(),l=t.useProgram("sky"),h=SD(i,e);l.draw(i,r.TRIANGLES,s,o,a,Ox.disabled,n,null,void 0,"sky",h.vertexBuffer,h.indexBuffer,h.segments)},atmosphere:function(t,e,i){let r=t.context,n=r.gl,s=t.useProgram("atmosphere"),o=new kx(n.LEQUAL,kx.ReadOnly,[0,1]),a=t.transform,l=function(t,e){let i=t.getCartesianPosition();!function(t,e){t[0]=-e[0],t[1]=-e[1],t[2]=-e[2]}(i,i);let r=g(new Float64Array(16));return"map"===t.properties.get("anchor")&&(M(r,r,e.rollInRadians),x(r,r,-e.pitchInRadians),M(r,r,e.bearingInRadians),x(r,r,e.center.lat*Math.PI/180),D(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.transform),h=a.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),u=e.properties.get("atmosphere-blend")*h.projectionTransition;if(0===u)return;let c=Tw(a.worldSize,a.center.lat),f=((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,u,Pw(a),c,a.inverseProjectionMatrix),p=SD(r,e);s.draw(r,n.TRIANGLES,o,jx.disabled,Px.alphaBlended,Ox.disabled,f,null,null,"atmosphere",p.vertexBuffer,p.indexBuffer,p.segments)},custom:function(t,e,i,r){let{isRenderingGlobe:n}=r,s=t.context,o=i.implementation,a=t.style.projection,l=t.transform,h=l.getProjectionDataForCustomLayer(n),u={farZ:l.farZ,nearZ:l.nearZ,fov:l.fov*Math.PI/180,modelViewProjectionMatrix:l.modelViewProjectionMatrix,projectionMatrix:l.projectionMatrix,shaderData:{variantName:a.shaderVariantName,vertexShaderPrelude:`const float PI = 3.141592653589793;\nuniform mat4 u_projection_matrix;\n${a.shaderPreludeCode.vertexSource}`,define:a.shaderDefine},defaultProjectionData:h,getProjectionData:t=>l.getProjectionData({overscaledTileID:new nd(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})},c=o.renderingMode?o.renderingMode:"2d";if("offscreen"===r.currentPass){let e=o.prerender;e&&(t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),e.call(o,s.gl,u),s.setDirty(),t.setBaseState())}else if("translucent"===r.currentPass){t.setCustomLayerDefaults(),s.setColorMode(t.colorModeForRenderPass()),s.setStencilMode(jx.disabled);let e="3d"===c?t.getDepthModeFor3D():t.getDepthModeForSublayer(0,kx.ReadOnly);s.setDepthMode(e),o.render(s.gl,u),s.setDirty(),t.setBaseState(),s.bindFramebuffer.set(null)}},debug:function(t,e,i){for(let r of i)FD(t,e,r)},debugPadding:function(t){let e=t.transform.padding;MD(t,t.transform.height-(e.top||0),3,vD),MD(t,e.bottom||0,3,wD),ED(t,e.left||0,3,bD),ED(t,t.transform.width-(e.right||0),3,xD);let i=t.transform.centerPoint;!function(t,e,i,r){AD(t,e-1,i-10,2,20,r),AD(t,e-10,i-1,20,2,r)}(t,i.x,t.transform.height-i.y,DD)},terrainDepth:function(t,e){let i=t.context,r=i.gl,n=t.transform,s=Px.unblended,o=new kx(r.LEQUAL,kx.ReadWrite,[0,1]),a=e.tileManager.getRenderableTiles(),l=t.useProgram("terrainDepth");i.bindFramebuffer.set(e.getFramebuffer().framebuffer),i.viewport.set([0,0,t.width/devicePixelRatio,t.height/devicePixelRatio]),i.clear({color:fi.white,depth:1});for(let t of a){let a=e.getTerrainMesh(t.tileID),h=e.getTerrainData(t.tileID),u=n.getProjectionData({overscaledTileID:t.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0}),c=nb(e.getSkirtLength(n.zoom));l.draw(i,r.TRIANGLES,o,jx.disabled,s,Ox.backCCW,c,h,u,"terrain",a.vertexBuffer,a.indexBuffer,a.segments)}i.bindFramebuffer.set(null),i.viewport.set([0,0,t.width,t.height])}};var zD=class t{constructor(t,e){this.drawFunctions=CD,this.context=new Ix(t),this.transform=e,this.layerOpacityFbo=null,this._tileTextures={},this._rttObjectRecyclePool=[],this._rttSharedFbo=null,this.terrainFacilitator={depthDirty:!0,matrix:g(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Wy.maxOverzooming+Wy.maxUnderzooming+1,this.depthEpsilon=1/65536,this.crossTileSymbolIndex=new Jv}resize(t,e,i){if(this.width=Math.floor(t*i),this.height=Math.floor(e*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let t of this.style._order)this.style._layers[t].resize()}setup(){let t=this.context,e=new ga;e.emplaceBack(0,0),e.emplaceBack(tt,0),e.emplaceBack(0,tt),e.emplaceBack(tt,tt),this.tileExtentBuffer=t.createVertexBuffer(e,gy.members),this.tileExtentSegments=Oa.simpleSegment(0,0,4,2);let i=new ga;i.emplaceBack(0,0),i.emplaceBack(tt,0),i.emplaceBack(0,tt),i.emplaceBack(tt,tt),this.debugBuffer=t.createVertexBuffer(i,gy.members),this.debugSegments=Oa.simpleSegment(0,0,4,5);let r=new va;r.emplaceBack(0,0,0,0),r.emplaceBack(tt,0,tt,0),r.emplaceBack(0,tt,0,tt),r.emplaceBack(tt,tt,tt,tt),this.rasterBoundsBuffer=t.createVertexBuffer(r,eb.members),this.rasterBoundsSegments=Oa.simpleSegment(0,0,4,2);let n=new ga;n.emplaceBack(0,0),n.emplaceBack(tt,0),n.emplaceBack(0,tt),n.emplaceBack(tt,tt),this.rasterBoundsBufferPosOnly=t.createVertexBuffer(n,gy.members),this.rasterBoundsSegmentsPosOnly=Oa.simpleSegment(0,0,4,5);let s=new ga;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(s,gy.members),this.viewportSegments=Oa.simpleSegment(0,0,4,2);let o=new ja;o.emplaceBack(0),o.emplaceBack(1),o.emplaceBack(3),o.emplaceBack(2),o.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(o);let a=new ka;a.emplaceBack(1,0,2),a.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);let l=this.context.gl;this.stencilClearMode=new jx({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.tileExtentMesh=new _y(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){let t=this.context,e=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let i=m();A(i,0,this.width,this.height,0,0,1),b(i,i,[e.drawingBufferWidth,e.drawingBufferHeight,0]);let r={mainMatrix:i,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:i,clipAntimeridian:!1};this.useProgram("clippingMask",null,!0).draw(t,e.TRIANGLES,kx.disabled,this.stencilClearMode,Px.disabled,Ox.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}renderTileClippingMasks(t,e,i){if(this.currentStencilSource===t.source||!t.isTileClipped()||!e?.length)return;this.currentStencilSource=t.source,this.nextStencilID+e.length>256&&this.clearStencil();let r=this.context;r.setColorMode(Px.disabled),r.setDepthMode(kx.disabled);let n={};for(let t of e)n[t.key]=this.nextStencilID++;this.style.projection.useSubdivision&&this._renderTileMasks(n,e,i,!0),this._renderTileMasks(n,e,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(t,e,i,r){let n=this.context,s=n.gl,o=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(let h of e){let e=t[h.key],u=this.getTerrainDataForTile(h,i),c=o.getMeshFromTileID(this.context,h.canonical,r,!0,"stencil"),f=a.getProjectionData({overscaledTileID:h,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(n,s.TRIANGLES,kx.disabled,new jx({func:s.ALWAYS,mask:0},e,255,s.KEEP,s.KEEP,s.REPLACE),Px.disabled,i?Ox.disabled:Ox.backCCW,null,u,f,"$clipping",c.vertexBuffer,c.indexBuffer,c.segments)}}getTerrainDataForTile(t,e){return e&&"mercator"===this.style.projection?.name?null:this.style.map.terrain?.getTerrainData(t)||null}_renderTilesDepthBuffer(){let t=this.context,e=t.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),s=this.getDepthModeFor3D(),o=By(r,{tileSize:r.tileSize});for(let a of o){let o=this.style.map.terrain?.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),h=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(t,e.TRIANGLES,s,jx.disabled,Px.disabled,Ox.backCCW,null,o,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 jx({func:e.NOTEQUAL,mask:255},t,255,e.KEEP,e.KEEP,e.REPLACE)}stencilModeForClipping(t){let e=this.context.gl;return new jx({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 jx({func:e.GEQUAL,mask:255},i+this.nextStencilID,255,e.KEEP,e.KEEP,e.REPLACE);return this.nextStencilID+=n,[t,i]}return[{[r]:jx.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 jx({func:e.GREATER,mask:255},n+1+i,255,e.KEEP,e.KEEP,e.REPLACE),s[i+r]=new jx({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 jx({func:e.GREATER,mask:255},2,255,e.KEEP,e.KEEP,e.REPLACE)},{[r]:new jx({func:e.GREATER,mask:255},1,255,e.KEEP,e.KEEP,e.REPLACE)},i]}colorModeForRenderPass(){let t=this.context.gl;if(this._showOverdrawInspector){let e=1/8;return new Px([t.CONSTANT_COLOR,t.ONE],new fi(e,e,e,0),[!0,!0,!0,!0])}return"opaque"===this.renderOptions.currentPass?Px.unblended:Px.alphaBlended}getDepthModeForSublayer(t,e,i){if(!this.opaquePassEnabledForLayer())return kx.disabled;let r=1-((1+this.renderOptions.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new kx(i||this.context.gl.LEQUAL,e,[r,r])}getDepthModeFor3D(){return new kx(this.context.gl.LEQUAL,kx.ReadWrite,this.renderOptions.depthRangeFor3D)}opaquePassEnabledForLayer(){return this.renderOptions.currentLayer<this.renderOptions.opaquePassCutoff}render(t,e){this.style=t,this.options=e;let i=this.renderOptions=function(t,e,i){let r=e?.transitionState??0;return{currentPass:"offscreen",currentLayer:0,opaquePassCutoff:1/0,depthRangeFor3D:[0,1],isRenderingToTexture:!1,transform:t,terrain:i,projectionTransition:r,isRenderingGlobe:r>0}}(this.transform,t.projection,t.map.terrain??null);this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.patternAtlas=t.patternAtlas,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(U_()),function(t,e){let i=t.pending,{transform:r}=e,n=e.context.gl;i[Tx.u_units_to_pixels]=1/r.pixelsToGLUnits[0],i[Tx.u_units_to_pixels+1]=1/r.pixelsToGLUnits[1],i[Tx.u_world_size]=n.drawingBufferWidth,i[Tx.u_world_size+1]=n.drawingBufferHeight,i[Tx.u_camera_to_center_distance]=r.cameraToCenterDistance,i[Tx.u_symbol_fade_change]=e.options.fadeDuration?e.symbolFadeChange:1,i[Tx.u_aspect_ratio]=r.width/r.height,i[Tx.u_device_pixel_ratio]=e.pixelRatio,i[Tx.u_viewport_size]=r.width,i[Tx.u_viewport_size+1]=r.height,i[Tx.u_pixel_extrude_scale]=1/r.width,i[Tx.u_pixel_extrude_scale+1]=1/r.height,i[Tx.u_pitch]=r.pitch/360*2*Math.PI,t.upload()}(this.context.frameUniformBuffer,this),this.imageManager.beginFrame();let r=this.style._order,n=this.style.tileManagers,s={},o={},a={};for(let t in n){let e=n[t];e.used&&e.prepare(this.context),s[t]=e.getVisibleCoordinates(!1),o[t]=s[t].slice().reverse(),a[t]=e.getVisibleCoordinates(!0).reverse()}i.opaquePassCutoff=1/0;for(let t=0;t<r.length;t++)if(this.style._layers[r[t]].is3D()){i.opaquePassCutoff=t;break}this.maybeDrawDepth(),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),i.opaquePassCutoff=0),i.currentPass="offscreen";for(let t of r){let e=this.style._layers[t];if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;let r=o[e.source];("custom"===e.type||r.length)&&this.renderLayer(this,n[e.source],e,r,i)}if(this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:e.showOverdrawInspector?fi.black:fi.transparent,depth:1}),this.clearStencil(),this.style.sky&&this.drawFunctions.sky(this,this.style.sky),this._showOverdrawInspector=e.showOverdrawInspector,i.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(i.currentPass="opaque",i.currentLayer=r.length-1;i.currentLayer>=0;i.currentLayer--){let t=this.style._layers[r[i.currentLayer]];if(t.isHidden(this.transform.zoom))continue;let e=n[t.source],o=s[t.source];this.renderTileClippingMasks(t,o,!1),this.renderLayer(this,e,t,o,i)}i.currentPass="translucent";let l=!1;for(i.currentLayer=0;i.currentLayer<r.length;i.currentLayer++){let t=this.style._layers[r[i.currentLayer]];if(t.isHidden(this.transform.zoom))continue;let e=n[t.source];if(this.renderToTexture?.renderLayer(t,i))continue;!this.opaquePassEnabledForLayer()&&!l&&(l=!0,i.isRenderingGlobe&&!this.style.map.terrain&&this._renderTilesDepthBuffer());let h=("symbol"===t.type?a:o)[t.source];this.renderTileClippingMasks(t,s[t.source],!!this.renderToTexture),this.renderLayer(this,e,t,h,i)}if(i.isRenderingGlobe&&this.drawFunctions.atmosphere(this,this.style.sky,this.style.light),this.options.showTileBoundaries){let t=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}(this.style,this.transform.zoom);t&&this.drawFunctions.debug(this,t,t.getVisibleCoordinates())}this.options.showPadding&&this.drawFunctions.debugPadding(this),this.context.setDefault()}maybeDrawDepth(){if(!this.style?.projection||!this.style.map?.terrain)return;let t=this.terrainFacilitator.matrix,e=this.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.style.map.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=U_(),this.terrainFacilitator.depthDirty=!1,this.drawFunctions.terrainDepth(this,this.style.map.terrain))}renderLayer(t,e,i,r,n){if(i.isHidden(this.transform.zoom)||"background"!==i.type&&"custom"!==i.type&&!(r||[]).length)return;this.id=i.id;let s=this.drawFunctions;Vp(i)?s.symbol(t,e,i,r,this.style.placement.variableOffsets,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):So(i)?s.raster(t,e,i,r,n):(t=>"background"===t.type)(i)?s.background(t,e,i,r,n):(t=>"custom"===t.type)(i)&&s.custom(t,e,i,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 dh(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)}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let e=this.patternAtlas.getPattern(t.from.toString()),i=this.patternAtlas.getPattern(t.to.toString());return!e||!i}useProgram(t,e,i=!1,r=[]){this.cache||={};let n=!!this.style.map.terrain,s=this.style.projection,o=i?Qv.projectionMercator:s.shaderPreludeCode,a=i?ew:s.shaderDefine,l=t+(e?e.cacheKey:"")+`/${i?iw:s.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(n?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||=new db(this.context,Qv[t],e,Gb[t],this._showOverdrawInspector,n,o,a,r),this.cache[l]}setCustomLayerDefaults(){this.context.setCustomLayerDefaults()}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 dh(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={}}for(let t of this._rttObjectRecyclePool)t.texture.destroy();if(this._rttObjectRecyclePool=[],this._rttSharedFbo){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}if(this.layerOpacityFbo?.destroy(),this.layerOpacityFbo=null,this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&this.tileExtentMesh.vertexBuffer?.destroy(),this.tileExtentMesh&&this.tileExtentMesh.indexBuffer?.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.context.projectionUniformBuffer.destroy(),this.context.terrainUniformBuffer.destroy(),this.context.frameUniformBuffer.destroy(),this.cache){for(let t in this.cache){let e=this.cache[t];e?.program&&this.context.gl.deleteProgram(e.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:e}=this.context.gl;return this.width!==t||this.height!==e}},TD=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 PD(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 ID=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=PD(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 $u(+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 kD={linearity:.3,easing:vt(0,0,.3,1)},$D=Dt({deceleration:2500,maxSpeed:1400},kD),jD=Dt({deceleration:20,maxSpeed:1400},kD),RD=Dt({deceleration:1e3,maxSpeed:360},kD),OD=Dt({deceleration:1e3,maxSpeed:90},kD),BD=Dt({deceleration:1e3,maxSpeed:360},kD);var LD=class{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:U_(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,e=U_();for(;t.length>0&&e-t[0].time>160;)t.shift()}_getVelocityEntries(){let t=this._inertiaBuffer,e=U_()-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 l(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=U_()-e[0].time,n={};if(i.pan.mag()){let e=ND(i.pan.mag(),r,Dt({},$D,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,UD(n,e)}if(i.zoom){let t=ND(i.zoom,r,jD);n.zoom=Ct(this._map.getZoom()+t.amount,this._map.getZoomSnap(),t.amount),UD(n,t)}if(i.bearing){let t=ND(i.bearing,r,RD);n.bearing=this._map.getBearing()+bt(t.amount,-179,179),UD(n,t)}if(i.pitch){let t=ND(i.pitch,r,OD);n.pitch=this._map.getPitch()+t.amount,UD(n,t)}if(i.roll){let t=ND(i.roll,r,BD);n.roll=this._map.getRoll()+bt(t.amount,-179,179),UD(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(),Dt(n,{noMoveStart:!0})}};function UD(t,e){(!t.duration||t.duration<e.duration)&&(t.duration=e.duration,t.easing=e.easing)}function ND(t,e,i){let{maxSpeed:r,linearity:n,deceleration:s}=i,o=bt(t*n/(e/1e3),-r,r),a=Math.abs(o)/(s*n);return{easing:i.easing,duration:1e3*a,amount:a/2*o}}var GD=class{constructor(t,e){this._map=t,this._clickTolerance=e.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new K_(this._map,t))}mousedown(t,e){return this._mousedownPos=e,this._firePreventable(new X_(t.type,this._map,t))}mouseup(t){this._map.fire(new X_(t.type,this._map,t))}click(t,e){this._mousedownPos&&this._mousedownPos.dist(e)>=this._clickTolerance||this._map.fire(new X_(t.type,this._map,t))}dblclick(t){return this._firePreventable(new X_(t.type,this._map,t))}mouseover(t){this._map.fire(new X_(t.type,this._map,t))}mouseout(t){this._map.fire(new X_(t.type,this._map,t))}touchstart(t){return this._firePreventable(new J_(t.type,this._map,t))}touchmove(t){this._map.fire(new J_(t.type,this._map,t))}touchend(t){this._map.fire(new J_(t.type,this._map,t))}touchcancel(t){this._map.fire(new J_(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},qD=class{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new X_(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new X_("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new X_(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}},VD=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&&(N_.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=N_.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(),N_.suppressClick(),i.x!==r.x||i.y!==r.y)return this._map.fire(new Q_("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),N_.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,e){return this._map.fire(new Q_(t,{originalEvent:e}))}};function ZD(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 WD=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 l(0,0);for(let i of t)e._add(i);return e.div(t.length)}(e),this.touches=ZD(i,e)))}touchmove(t,e,i){if(this.aborted||!this.centroid)return;let r=ZD(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}}},HD=class{constructor(t){this.singleTap=new WD(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}}},YD=class{constructor(t,e){this._tr=e,this._zoomIn=new HD({numTouches:1,numTaps:2}),this._zoomOut=new HD({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:Ct(s.zoom+1,e.getZoomSnap()),around:s.unproject(r)},{originalEvent:t})}):n?(this._active=!0,t.preventDefault(),setTimeout((()=>this.reset()),0),{cameraAnimation:e=>e.easeTo({duration:300,zoom:Ct(s.zoom-1,e.getZoomSnap()),around:s.unproject(n)},{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}},XD=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&&N_.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 JD={0:1,2:2};var KD=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=JD[e];return void 0===t.buttons||(t.buttons&i)!==i}(t,this._eventButton)}isValidEndEvent(t){return t.button===this._eventButton}},QD=class{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return 1===t.targetTouches.length}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}},tM=class{constructor(t=new KD({checkCorrectEvent:()=>!0}),e=new QD){this.mouseMoveStateManager=t,this.oneFingerTouchMoveStateManager=e}_executeRelevantHandler(t,e,i){return t instanceof MouseEvent?e(t):typeof TouchEvent<"u"&&t instanceof TouchEvent?i(t):void 0}startMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.startMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.startMove(t)}))}endMove(t){this._executeRelevantHandler(t,(t=>{this.mouseMoveStateManager.endMove(t)}),(t=>{this.oneFingerTouchMoveStateManager.endMove(t)}))}isValidStartEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidStartEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidStartEvent(t)))}isValidMoveEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidMoveEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(t)))}isValidEndEvent(t){return!!this._executeRelevantHandler(t,(t=>this.mouseMoveStateManager.isValidEndEvent(t)),(t=>this.oneFingerTouchMoveStateManager.isValidEndEvent(t)))}};const eM=t=>{t.mousedown=t.dragStart,t.mousemoveWindow=t.dragMove,t.mouseup=t.dragEnd,t.contextmenu=t=>{t.preventDefault()}};function iM({enable:t,clickTolerance:e,aroundCenter:i=!0,minPixelCenterThreshold:r=100,rotateSpeed:n=.8},s){return new XD({clickTolerance:e,move:(t,e)=>{let o=s();if(i&&Math.abs(o.y-t.y)>r)return{bearingDelta:Vt(new l(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 KD({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button&&!t.ctrlKey}),enable:t,assignEvents:eM})}var rM=class{constructor(t,e){this._clickTolerance=t.clickTolerance||1,this._map=e,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l(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=ZD(i,e),n=new l(0,0),s=new l(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}},nM=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=sM(i,e,r),o=sM(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=sM(i,e,r),o=sM(i,e,n);s&&o||(this._active&&N_.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 sM(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 aM=class extends nM{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 hM=class extends nM{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 uM(t){return Math.abs(t.y)>Math.abs(t.x)}var cM=class extends nM{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,uM(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 uM(t)&&uM(e)&&s}};const fM={panStep:100,bearingStep:15,pitchStep:10};var pM=class{constructor(t,e){this._tr=e;let i=fM;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:dM,zoom:e?Ct(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 dM(t){return t*(2-t)}const mM=4.000244140625;var _M=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=U_(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==e&&e%mM==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=N_.mousePos(this._map.getCanvas(),t),i=this._tr;this._aroundPoint=this._aroundCenter?i.transform.locationToScreenPoint($u.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)>mM?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?Ft(this._targetZoom):t.scale,n=t.applyConstrain(t.getCameraLngLat(),St(r*i)).zoom,s=this._map.getZoomSnap();if("wheel"===this._type&&s>0){let e=Ct(t.zoom,s);this._targetZoom=Ct(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=U_()-this._lastWheelEventTime,o=Math.min((t+5)/200,1),a=n(o);e=ji.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=wt;if(this._prevEase){let t=this._prevEase,i=(U_()-t.start)/t.duration,r=t.easing(i+.01)-t.easing(i),n=.27/Math.sqrt(r*r+1e-4)*.01;e=vt(n,Math.sqrt(.0729-n*n),.25,1)}return this._prevEase={start:U_(),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)}},gM=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()}},yM=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:Ct(this._tr.zoom+(t.shiftKey?-1:1),i.getZoomSnap()),around:this._tr.unproject(e)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}},vM=class{constructor(){this._tap=new HD({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}},wM=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()}},bM=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()}},xM=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()}},DM=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=N_.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 V_("cooperativegestureprevented",{gestureType:t,originalEvent:e})),this._container.classList.add("maplibregl-show"),setTimeout((()=>{this._container.classList.remove("maplibregl-show")}),100))}},MM=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(l.convert(t),this._camera.terrain)}};const EM=t=>t.zoom||t.drag||t.roll||t.pitch||t.rotate;var AM=class extends de{};function FM(t){return t.panDelta?.mag()||t.zoomDelta||t.bearingDelta||t.pitchDelta||t.rollDelta}var SM=class{get _ownerDocument(){return this._el?.ownerDocument||document}get _ownerWindow(){return this._el?.ownerDocument?.defaultView||window}constructor(t,e,i){this._terrainGestureAnchorElevation=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(Jt(t,e||t.type)){let i=N_.mousePos(this._map.getCanvas(),t);h=a[e||t.type](t,i)}else if(Xt(t,e||t.type)){let i=this._getMapTouches(t.touches),r=N_.touchPos(this._map.getCanvas(),i);h=a[e||t.type](t,r,i)}else Kt(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||FM(r))&&(this._changes.push([r,n,o]),this._triggerRenderFrame()),(Object.keys(s).length||FM(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 MM(this._camera),this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new LD(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 GD(e,t));let r=e.boxZoom=new VD(e,t,this._transformProvider);this._add("boxZoom",r),t.interactive&&t.boxZoom&&r.enable();let n=e.cooperativeGestures=new DM(e,t.cooperativeGestures);this._add("cooperativeGestures",n),t.cooperativeGestures&&n.enable();let s=new YD(e,this._transformProvider),o=new yM(e,this._transformProvider);e.doubleClickZoom=new gM(o,s),this._add("tapZoom",s),this._add("clickZoom",o),t.interactive&&t.doubleClickZoom&&e.doubleClickZoom.enable();let a=new vM;this._add("tapDragZoom",a);let l=e.touchPitch=new cM(e);this._add("touchPitch",l),t.interactive&&t.touchPitch&&e.touchPitch.enable(t.touchPitch);let h=()=>e.project(e.getCenter()),u=iM(t,h),c=function({enable:t,clickTolerance:e,pitchSpeed:i=-.5}){return new XD({clickTolerance:e,move:(t,e)=>({pitchDelta:(e.y-t.y)*i}),moveStateManager:new KD({checkCorrectEvent:t=>0===t.button&&t.ctrlKey||2===t.button}),enable:t,assignEvents:eM})}(t),f=function({enable:t,clickTolerance:e,rollDegreesPerPixelMoved:i=.3},r){return new XD({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 KD({checkCorrectEvent:t=>2===t.button&&t.ctrlKey}),enable:t,assignEvents:eM})}(t,h);e.dragRotate=new bM(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 XD({clickTolerance:e,move:(t,e)=>({around:e,panDelta:e.sub(t)}),activateOnStart:!0,moveStateManager:new KD({checkCorrectEvent:t=>0===t.button&&!t.ctrlKey}),enable:t,assignEvents:eM})}(t),d=new rM(t,e);e.dragPan=new wM(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 hM,_=new aM;e.touchZoomRotate=new xM(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 qD(e));let g=e.scrollZoom=new _M(e,(()=>this._triggerRenderFrame()),this._transformProvider);this._add("scrollZoom",g,["mousePan"]),t.interactive&&t.scrollZoom&&e.scrollZoom.enable(t.scrollZoom);let y=e.keyboard=new pM(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!!EM(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;Dt(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 l(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),Dt(e,n),Dt(i,s);this._updateMapTransform(t,e,i),this._changes=[]}_updateMapTransform(t,e,i){let r=this._map,n=this._camera.getTransformForUpdate(),s=r.terrain;if(!(FM(t)||s&&this._terrainMovement))return void this._fireEvents(e,i,!0);this._camera.stop(!0);let{panDelta:o,zoomDelta:a,bearingDelta:l,pitchDelta:h,rollDelta:u}=t,{around:c,aroundOnSurface:f}=this._resolveAround(t,s,n),p=s?this._terrainGestureElevation(s,c,f,n,e):void 0,d={panDelta:o,zoomDelta:a,rollDelta:u,pitchDelta:h,bearingDelta:l,around:c,aroundElevation:p};this._camera.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(c)&&(c=n.centerPoint);let m=this._computePreZoomAroundLoc(n,c,o,p);this._handleMapControls({terrain:s,tr:n,deltasForHelper:d,preZoomAroundLoc:m,combinedEventsInProgress:e,panDelta:o}),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._terrainMovement&&(n.drag||n.zoom)){let i=r.screenTerrainPointToMercatorCoordinate(e,t);this._terrainGestureAnchorElevation=i?i.z:null}if(null===this._terrainGestureAnchorElevation)return;let s=this._terrainGestureAnchorElevation;return 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)return o.useGlobeControls?(!this._terrainMovement&&(n.drag||n.zoom)&&(this._terrainMovement=!0,this._camera.elevationFreeze=!0),void o.handleMapControlsPan(i,e,r)):this._terrainMovement||!n.drag&&!n.zoom?void(void 0===i.aroundElevation&&n.drag&&this._terrainMovement&&s?e.setCenter(e.screenPointToLocation(e.centerPoint.sub(s))):o.handleMapControlsPan(i,e,r)):(this._terrainMovement=!0,this._camera.elevationFreeze=!0,void o.handleMapControlsPan(i,e,r));o.handleMapControlsPan(i,e,r)}_fireEvents(t,e,i){let r=EM(this._eventsInProgress),n=EM(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=EM(this._eventsInProgress),h=(r||n)&&!l;if(h&&this._terrainMovement){this._camera.elevationFreeze=!1,this._terrainMovement=!1,this._terrainGestureAnchorElevation=null;let t=this._camera.getTransformForUpdate();this._map.getCenterClampedToGround()&&t.recalculateZoomAndCenter(this._map.terrain),this._camera.applyUpdatedTransform(t)}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&&B_.prefersReducedMotion?(this._map.fire(new Z_("moveend",{originalEvent: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._map.fire(new Z_(t,e?{originalEvent:e}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add((t=>{delete this._frameId,this.handleEvent(new AM("renderFrame",{timeStamp:t})),this._applyChanges()}))}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}},CM=class extends _e{constructor(t){super(),this._renderFrameCallback=()=>{let t=Math.min((U_()-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 gw,this.cameraHelper=new Dw,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}))}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 $u(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=l.convert(t).mult(-1),this.panTo(this.transform.center,Dt({offset:t},e),i)}panTo(t,e,i){return this.easeTo(Dt({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(Dt({zoom:t},e),i)}zoomIn(t,e){return this.zoomTo(Ct(this.getZoom()+1,this._zoomSnap),t,e),this}zoomOut(t,e){return this.zoomTo(Ct(this.getZoom()-1,this._zoomSnap),t,e),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(t,e){return t!=this.transform.fov&&(this.transform.setFov(t),this.fire(new Z_("movestart",e)).fire(new Z_("move",e)).fire(new Z_("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(Dt({bearing:t},e),i)}resetNorth(t,e){return this.rotateTo(0,Dt({duration:1e3},t),e),this}resetNorthPitch(t,e){return this.easeTo(Dt({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=Qg.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=Dt({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=Dt(n,r.padding);r.padding=s;let o=this.transform,a=new Qg(t,e),l=this.cameraHelper.cameraForBoxAndBearing(r,s,a,i,o);return l&&this._zoomSnap&&(l.zoom=Ct(l.zoom,this._zoomSnap,-1)),l}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(l.convert(t)),this.transform.screenPointToLocation(l.convert(e)),i,r),r,n)}_fitInternal(t,e,i){return t?(delete(e=Dt(t,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=Ct(t.zoom,this._zoomSnap));let i=this.getTransformForUpdate(),r=!1,n=!1,s=!1,o=i.zoom;this.terrain&&i.setElevation(this.terrain.getElevationForLngLat(t.center?$u.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 Z_("movestart",e)).fire(new Z_("move",e)),a&&this.fire(new Z_("zoomstart",e)).fire(new Z_("zoom",e)).fire(new Z_("zoomend",e)),r&&this.fire(new Z_("rotatestart",e)).fire(new Z_("rotate",e)).fire(new Z_("rotateend",e)),n&&this.fire(new Z_("pitchstart",e)).fire(new Z_("pitch",e)).fire(new Z_("pitchend",e)),s&&this.fire(new Z_("rollstart",e)).fire(new Z_("roll",e)).fire(new Z_("rollend",e)),this.fire(new Z_("moveend",e))}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=Dt({offset:[0,0],duration:500,easing:wt},t)).zoom&&this._zoomSnap&&(t.zoom=Ct(t.zoom,this._zoomSnap)),(!1===t.animate||!t.essential&&B_.prefersReducedMotion)&&(t.duration=0);let i,r,n=this.getTransformForUpdate(),s=this.getBearing(),o=n.pitch,a=n.roll,h=void 0===t.bearing?s:this._normalizeBearing(t.bearing,s),u=void 0===t.pitch?o:+t.pitch,c=void 0===t.roll?a:this._normalizeBearing(t.roll,a),f=void 0===t.padding?n.padding:t.padding,p=l.convert(t.offset);t.around&&(i=$u.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:h,pitch:u,roll:c,padding:f,around:i,aroundPoint:r,offsetAsPoint:p,offset:t.offset,zoom:t.zoom,center:t.center});return this._rotating||=s!==h,this._pitching||=u!==o,this._rolling||=c!==a,this._padding=!n.isPaddingEqual(f),this._zooming||=m.isZooming,this._easeId=t.easeId,this._prepareEase(e,t.noMoveStart,d),this.terrain&&this._prepareElevation(m.elevationCenter),this._ease((i=>{m.easeFunc(i),this.terrain&&!t.freezeElevation&&this._updateElevation(i),this.applyUpdatedTransform(n),this._fireMoveEvents(e)}),(i=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(e,i)}),t),this}_prepareEase(t,e,i={}){this._moving=!0,!e&&!i.moving&&this.fire(new Z_("movestart",t)),this._zooming&&!i.zooming&&this.fire(new Z_("zoomstart",t)),this._rotating&&!i.rotating&&this.fire(new Z_("rotatestart",t)),this._pitching&&!i.pitching&&this.fire(new Z_("pitchstart",t)),this._rolling&&!i.rolling&&this.fire(new Z_("rollstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLat(t,this.transform),this.elevationFreeze=!0}_updateElevation(t){(void 0===this._elevationStart||void 0===this._elevationCenter)&&this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));let e=this.terrain.getElevationForLngLat(this._elevationCenter,this.transform);if(t<1&&e!==this._elevationTarget){let i=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(i-(e-(i*t+this._elevationStart))/(1-t)),this._elevationTarget=e}this.transform.setElevation(ji.number(this._elevationStart,this._elevationTarget,t))}_finalizeElevation(){this.elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||=this.transform.clone(),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){if(!this.terrain&&t.elevation>=0&&t.pitch<=90)return{};let e=t.getCameraLngLat(),i=t.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(e,t.zoom):0;if(i<r){let i=t.calculateCameraOptionsFromTo(e,r,t.center,t.elevation);return{pitch:i.pitch,zoom:i.zoom}}return{}}applyUpdatedTransform(t){let e=[];if(e.push((t=>this._elevateCameraIfInsideTerrain(t))),this.transformCameraUpdate&&e.push((t=>this.transformCameraUpdate(t))),!e.length)return;let i=t.clone();for(let t of e){let e=i.clone(),{center:r,zoom:n,roll:s,pitch:o,bearing:a,elevation:l}=t(e);r&&e.setCenter(r),void 0!==l&&e.setElevation(l),void 0!==n&&e.setZoom(n),void 0!==s&&e.setRoll(s),void 0!==o&&e.setPitch(o),void 0!==a&&e.setBearing(a),i.apply(e,!1)}this.transform.apply(i,!1)}_fireMoveEvents(t){this.fire(new Z_("move",t)),this._zooming&&this.fire(new Z_("zoom",t)),this._rotating&&this.fire(new Z_("rotate",t)),this._pitching&&this.fire(new Z_("pitch",t)),this._rolling&&this.fire(new Z_("roll",t))}_afterEase(t,e){if(this._easeId&&e&&this._easeId===e)return;delete this._easeId;let i=this._zooming,r=this._rotating,n=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,i&&this.fire(new Z_("zoomend",t)),r&&this.fire(new Z_("rotateend",t)),n&&this.fire(new Z_("pitchend",t)),s&&this.fire(new Z_("rollend",t)),this.fire(new Z_("moveend",t))}flyTo(t,e){if(!t.essential&&B_.prefersReducedMotion){let i=Mt(t,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(i,e)}this.stop(),void 0!==(t=Dt({offset:[0,0],speed:1.2,curve:1.42,easing:wt},t)).zoom&&this._zoomSnap&&(t.zoom=Ct(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),h=void 0===t.pitch?n:+t.pitch,u=void 0===t.roll?s:this._normalizeBearing(t.roll,s),c=void 0===t.padding?i.padding:t.padding,f=l.convert(t.offset),p=i.centerPoint.add(f),d=i.screenPointToLocation(p),m=this.cameraHelper.handleFlyTo(i,{bearing:a,pitch:h,roll:u,padding:c,locationAtOffset:d,offsetAsPoint:f,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=h!==n,this._rolling=u!==s,this._padding=!i.isPaddingEqual(c),this._prepareEase(e,!1),this.terrain&&this._prepareElevation(m.targetCenter),this._ease((l=>{let d=l*F,_=1/E(d),g=A(d);this._rotating&&i.setBearing(ji.number(r,a,l)),this._pitching&&i.setPitch(ji.number(n,h,l)),this._rolling&&i.setRoll(ji.number(s,u,l)),this._padding&&(i.interpolatePadding(o,c,l),p=i.centerPoint.add(f)),m.easeFunc(l,_,g,p),this.terrain&&!t.freezeElevation&&this._updateElevation(l),this.applyUpdatedTransform(i),this._fireMoveEvents(e)}),(()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(e)}),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=U_(),this._easeOptions=i,this._onEaseFrame=t,this._onEaseEnd=e,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,e){t=xt(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 zM={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};var TM=class{constructor(t=zM){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=N_.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=N_.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=N_.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(" | ");i!==this._attribHTML&&(this._attribHTML=i,t.length?(this._innerContainer.innerHTML=N_.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}},PM=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=N_.create("div","maplibregl-ctrl");let e=N_.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}},IM=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 kM=["none","zoom","sourceTiles","visibleLayers","revision"];var $M=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 jM={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};var RM=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){let i=e!==this._lastPrepareZoom;this._lastPrepareZoom=e,this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=t._order.filter((i=>!t._layers[i].isHidden(e)));let r=this._renderableLayerIds.join(),n=new Set;for(let e of this._renderableLayerIds){let i=t._layers[e],r=i.source;r&&jM[i.type]&&n.add(r)}this._coordsAscending={},this._rttFingerprints={};for(let i of n){let n=t.tileManagers[i];if(!n)continue;this._coordsAscending[i]={};let s=this._coordsAscending[i],o=n.getSource(),a=o instanceof wy?o.terrainTileRanges:null;for(let t of n.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=n.getState().revision;for(let t in s)l[t]=new $M(s[t],h,e,r)}this.needsFollowUpFrame=!1;let s=i||this.painter.options.moving,o=!1;for(let t of this._renderableTiles){let e=this._textureDifference(t);"none"!==e&&("zoom"===e&&s||"visibleLayers"===e&&i?this.needsFollowUpFrame=!0:"zoom"===e||"sourceTiles"===e?(o?this.needsFollowUpFrame=!0:t.releaseRTT(this.painter),o=!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]);kM.indexOf(n)>kM.indexOf(e)&&(e=n)}return e}renderLayer(t,e){if(t.isHidden(this.painter.transform.zoom))return!1;let i={...e,isRenderingToTexture:!0},r=t.type,n=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(jM[r]&&((!this._prevType||!jM[this._prevType])&&this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(t.id),!s))return!0;if(jM[this._prevType]||jM[r]&&s){this._prevType=r;let t=this._stacks.length-1,e=this._stacks[t]||[];for(let r of this._renderableTiles){if(this._rttTiles.push(r),r.getRTT(t))continue;let s=r.acquireRTT(n,t,this.rttSize);n.bindRTT(s),n.context.clear({color:fi.transparent,stencil:0}),n.currentStencilSource=void 0;for(let t of e){let e=n.style._layers[t],s=e.source?this._coordsAscending[e.source][r.tileID.key]:[r.tileID];n.context.viewport.set([0,0,this.rttSize,this.rttSize]),n.renderTileClippingMasks(e,s,!0),n.renderLayer(n,n.style.tileManagers[e.source],e,s,i),e.source&&(r.rttFingerprint[e.source]=this._rttFingerprints[e.source][r.tileID.key])}s.texture.generateMipmap()}return function(t,e,i,r){let{isRenderingGlobe:n}=r,s=t.context,o=s.gl,a=t.transform,l=t.colorModeForRenderPass(),h=t.getDepthModeFor3D(),u=t.useProgram("terrain");s.bindFramebuffer.set(null),s.viewport.set([0,0,t.width,t.height]);for(let r of i){let i=e.getTerrainMesh(r.tileID),c=t.renderToTexture.getTexture(r),f=e.getTerrainData(r.tileID);s.activeTexture.set(o.TEXTURE0),c.bind(o.LINEAR,o.CLAMP_TO_EDGE,o.LINEAR_MIPMAP_LINEAR);let p=e.getSkirtLength(a.zoom),d=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=rb(p,d,t.style.sky,a.pitch,n),_=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(s,o.TRIANGLES,h,jx.disabled,l,Ox.backCCW,m,f,_,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}(this.painter,this.terrain,this._rttTiles,i),this._rttTiles=[],jM[r]}return!1}};const OM={"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"},BM={hash:!1,interactive:!0,bearingSnap:7,zoomSnap:0,attributionControl:zM,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:re.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 LM=class extends _e{get _ownerWindow(){return this._container?.ownerDocument?.defaultView||window}constructor(t){super(),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new IM,this._controls=[],this._mapId=At(),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 ig("webglcontextlost",{originalEvent:t}))}else this.fire(new ig("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 me(t))}this.resize(),this._update(),this._resizeInternal(),this.fire(new ig("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={...BM,...t,canvasContextAttributes:{...BM.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 CM({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={...OM,...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&&(B_.prefersReducedMotion=e.reduceMotion),this._requestManager=new q_(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=G_.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.terrainFacilitator.depthDirty=!0,this._update(!0)})),this.once("idle",(()=>this._idleTriggered=!0)),this._handlers=new SM(this,this._camera,e),typeof window<"u"&&(this._ownerWindow.addEventListener("online",this._onWindowOnline,!1),this._setupResizeObserver()),this._hash=e.hash?new ID("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,Dt({},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 TM("boolean"==typeof e.attributionControl?void 0:e.attributionControl)),e.maplibreLogo&&this.addControl(new PM,e.logoPosition),this.on("style.load",(()=>{if(i||this._resizeTransform(),this._camera.transform.unmodified){let t=Mt(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 H_("styledata",t):new Y_("sourcedata",t))})),this.on("dataloading",(t=>{this.fire("style"===t.dataType?new H_("styledataloading",t):new Y_("sourcedataloading",t))})),this.on("dataabort",(t=>{this.fire(new Y_("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 me(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 me(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 By(this._camera.transform,t)}setTransformCameraUpdate(t){this._camera.transformCameraUpdate=t}getCenter(){return new $u(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}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($u.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 Z_("movestart",t)).fire(new Z_("move",t))),this.fire(new V_("resize",t)),i&&this.fire(new Z_("moveend",t)),this}_resizeInternal(t=!0){let[e,i]=this._containerDimensions(),r=this._getClampedPixelRatio(e,i);if(this._resizeCanvas(e,i,r),this.painter.resize(e,i,r),this.painter.overLimit()){let t=this.painter.context.gl;this._maxCanvasSize=[t.drawingBufferWidth,t.drawingBufferHeight];let r=this._getClampedPixelRatio(e,i);this._resizeCanvas(e,i,r),this.painter.resize(e,i,r)}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&&$t("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.transform.setMaxBounds(Qg.convert(t)),this._update()}setMinZoom(t){if(t??=-2,t>=-2&&t<=this._camera.transform.maxZoom){let e=this._camera.transform.zoom,i=this._camera.getTransformForUpdate();return i.setMinZoom(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.zoom&&this.fire(new Z_("zoomstart")).fire(new Z_("zoom")).fire(new Z_("zoomend")).fire(new Z_("movestart")).fire(new Z_("move")).fire(new Z_("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,i=this._camera.getTransformForUpdate();return i.setMaxZoom(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.zoom&&this.fire(new Z_("zoomstart")).fire(new Z_("zoom")).fire(new Z_("zoomend")).fire(new Z_("movestart")).fire(new Z_("move")).fire(new Z_("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,i=this._camera.getTransformForUpdate();return i.setMinPitch(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.pitch&&this.fire(new Z_("pitchstart")).fire(new Z_("pitch")).fire(new Z_("pitchend")).fire(new Z_("movestart")).fire(new Z_("move")).fire(new Z_("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,i=this._camera.getTransformForUpdate();return i.setMaxPitch(t),this._camera.applyUpdatedTransform(i),this._update(),e!==this._camera.transform.pitch&&this.fire(new Z_("pitchstart")).fire(new Z_("pitch")).fire(new Z_("pitchend")).fire(new Z_("movestart")).fire(new Z_("move")).fire(new Z_("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.transform.setRenderWorldCopies(t),this._update()}setTransformConstrain(t){return this._camera.transform.setConstrainOverride(t),this._update()}project(t){return this._camera.transform.locationToScreenPoint($u.convert(t),this.style&&this.terrain)}unproject(t){return this._camera.transform.screenPointToLocation(l.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}_createDelegatedListener(t,e,i){if("mouseenter"===t||"mouseover"===t){let r=!1;return{layers:e,listener:i,delegates:{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 X_(t,this,n.originalEvent,{features:o}))):r=!1},mouseout:()=>{r=!1}}}}if("mouseleave"===t||"mouseout"===t){let r=!1;return{layers:e,listener:i,delegates:{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 X_(t,this,n.originalEvent)))},mouseout:e=>{r&&(r=!1,i.call(this,new X_(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{layers:e,listener:i,delegates:{[t]:r}}}}_saveDelegatedListener(t,e){this._delegatedListeners||={},this._delegatedListeners[t]||=[],this._delegatedListeners[t].push(e)}_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=this._createDelegatedListener(t,r,i);this._saveDelegatedListener(t,n);for(let t in n.delegates)this.on(t,n.delegates[t]);return{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=this._createDelegatedListener(t,r,i);for(let e in n.delegates){let s=n.delegates[e];n.delegates[e]=(...e)=>{this._removeDelegatedListener(t,r,i),s(...e)}}this._saveDelegatedListener(t,n);for(let t in n.delegates)this.once(t,n.delegates[t]);return this}off(t,e,i){return void 0===i?super.off(t,e):(this._removeDelegatedListener(t,"string"==typeof e?[e]:e,i),this)}queryRenderedFeatures(t,e){if(!this.style)return[];let i,r=t instanceof l||Array.isArray(t),n=r?t:[[0,0],[this._camera.transform.width,this._camera.transform.height]];if(e||=(r?{}:t)||{},n instanceof l||"number"==typeof n[0])i=[l.convert(n)];else{let t=l.convert(n[0]),e=l.convert(n[1]);i=[t,new l(e.x,t.y),e,new l(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=Dt({},{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 tb(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 tb(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 he(t,r);this._diffStyleRequest=null,this._updateDiff(n.data,e)}catch(t){this._diffStyleRequest=null,ee(t)||this.fire(new me(it(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){$t(`Unable to perform style diff: ${it(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();$t("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 me(Error(`There is no tile manager with ID '${t}'`)))}setTerrain(t,e={}){if(this.style._checkLoaded(),t&&Ys(this,Vs.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&&$t("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&&$t("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 fw(this.painter,e,t,this._terrainSkirtLength),this.painter.renderToTexture=new RM(this.painter,this.terrain),this._camera.terrain=this.terrain,this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform)),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._camera.terrain=null,this._camera.transform.setMinElevationForCurrentTile(0),this.getCenterClampedToGround()&&this._camera.transform.setElevation(0);return this.style.triggerSymbolPlacement(),this.fire(new tg({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._camera.elevationFreeze&&(this._camera.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._camera.transform.center,this._camera.transform.tileZoom)),this.getCenterClampedToGround()&&this._camera.transform.setElevation(this.terrain.getElevationForLngLat(this._camera.transform.center,this._camera.transform))),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=jy(Math.max(1,t),Math.max(1,e))}else for(let i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=jy(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 id(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||Lt(t)){let{width:e,height:h,data:u}=B_.getImageData(t);return{data:new rh({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 me(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=zf(c.data);return{data:f?new rh({width:e,height:h}):new rh({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 me(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||Lt(e)?B_.getImageData(e):e;if(void 0===r||void 0===n)return this.fire(new me(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 me(Error("The width and height of the updated image must be that same as the previous version of the image")));if(i.isWebGLImage=zf(s),i.isWebGLImage)i.userImage=e;else{let t=!(e instanceof HTMLImageElement||Lt(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 me(Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(t)}async loadImage(t){let e=await G_.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=this._container.clientWidth||400,e=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=PD((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._container;t.classList.add("maplibregl-map");let e=this._canvasContainer=N_.create("div","maplibregl-canvas-container",t);this._interactive&&e.classList.add("maplibregl-interactive"),this._canvas=N_.create("canvas","maplibregl-canvas",e),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);let n=this._controlContainer=N_.create("div","maplibregl-control-container",t),s=this._controlPositions={};for(let t of["top-left","top-right","bottom-left","bottom-right"])s[t]=N_.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){this._canvas.width=Math.floor(i*t),this._canvas.height=Math.floor(i*e),this._canvas.style.width=`${t}px`,this._canvas.style.height=`${e}px`}_setupPainter(){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 TD(t,e);this.painter=new zD(i,this._camera.transform)}migrateProjection(t,e){this._camera.migrateProjection(t,e),this.painter.transform=t,this.fire(new eg({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=U_();this.style.zoomHistory.update(t,i);let n=new so(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),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:e,showPadding:this.showPadding,anisotropicFilterPitch:this.getAnisotropicFilterPitch()}),this.fire(new V_("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new V_("load"))),this.style&&(this.style.hasTransitions()||r)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let s=this._sourcesDirty||this._styleDirty||this._placementDirty||this.painter.renderToTexture?.needsFollowUpFrame;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new V_("idle")),this._loaded&&!this._fullyLoaded&&!s&&(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),G_.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 V_("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,B_.frame(this._frameRequest,(t=>{this._frameRequest=null;try{this._render(t)}catch(t){if(!ee(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"6.9.0"}getCameraTargetElevation(){return this._camera.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(t){return this._lazyInitEmptyStyle(),this.style.setProjection(t),this._update(!0)}};const UM={showCompass:!0,showZoom:!0,visualizePitch:!1,visualizeRoll:!0};var NM=class{constructor(t){this._updateZoomButtons=()=>{let t=this._map.getZoom(),e=t===this._map.getMaxZoom(),i=t===this._map.getMinZoom(!0);this._zoomInButton.disabled=e,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",e.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{let t=this._map.getPitch(),e=this._map.getRoll(),i=this._map.getBearing(),r=1/Math.cos(Nt(t))**.5;this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${r}) rotateZ(${-e}deg) rotateX(${t}deg) rotateZ(${-i}deg)`:this.options.visualizePitch?`scale(${r}) rotateX(${t}deg) rotateZ(${-i}deg)`:this.options.visualizeRoll?`rotate(${-i-e}deg)`:`rotate(${-i}deg)`},this._setButtonTitle=(t,e)=>{let i=this._map._getUIString(`NavigationControl.${e}`);t.title=i,t.setAttribute("aria-label",i)},this.options=Dt({},UM,t),this._container=N_.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",(t=>t.preventDefault())),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",(t=>this._map.zoomIn({},{originalEvent:t}))),N_.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",(t=>this._map.zoomOut({},{originalEvent:t}))),N_.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",(t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})})),this._compassIcon=N_.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(t){return this._map=t,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("move",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new GM(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){this._container.remove(),this.options.showZoom&&this._map.off("move",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(t,e){let i=N_.create("button",t,this._container);return i.type="button",i.addEventListener("click",e),i}},GM=class{constructor(t,e,i=!1){this.mousedown=t=>{this.startMove(t,N_.mousePos(this.element,t)),window.addEventListener("mousemove",this.mousemove),window.addEventListener("mouseup",this.mouseup)},this.mousemove=t=>{this.move(t,N_.mousePos(this.element,t))},this.mouseup=t=>{this._rotatePitchHandler.dragEnd(t),this.offTemp()},this.touchstart=t=>{1===t.targetTouches.length?(this._startPos=this._lastPos=N_.touchPos(this.element,t.targetTouches)[0],this.startMove(t,this._startPos),window.addEventListener("touchmove",this.touchmove,{passive:!1}),window.addEventListener("touchend",this.touchend)):this.reset()},this.touchmove=t=>{1===t.targetTouches.length?(this._lastPos=N_.touchPos(this.element,t.targetTouches)[0],this.move(t,this._lastPos)):this.reset()},this.touchend=t=>{0===t.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=e;let r=new tM;this._rotatePitchHandler=new XD({clickTolerance:3,move:(t,r)=>{let n=e.getBoundingClientRect(),s=new l((n.bottom-n.top)/2,(n.right-n.left)/2);return{bearingDelta:Vt(new l(t.x,r.y),r,s),pitchDelta:i?-.5*(r.y-t.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=t,e.addEventListener("mousedown",this.mousedown),e.addEventListener("touchstart",this.touchstart,{passive:!1}),e.addEventListener("touchcancel",this.reset)}startMove(t,e){this._rotatePitchHandler.dragStart(t,e),N_.disableDrag()}move(t,e){let i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHandler.dragMove(t,e)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){let t=this.element;t.removeEventListener("mousedown",this.mousedown),t.removeEventListener("touchstart",this.touchstart),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend),t.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){N_.enableDrag(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup),window.removeEventListener("touchmove",this.touchmove),window.removeEventListener("touchend",this.touchend)}};const qM={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"},VM={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0,padding:void 0},ZM=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");var WM=class extends de{},HM=class extends _e{constructor(t){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map._camera.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&this._content.remove(),this._container&&(this._container.remove(),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousemove",this._update),this._map.off("mouseup",this._update),this._map.off("drag",this._update),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new WM("close"))),this),this._update=t=>{let e;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=N_.create("div","maplibregl-popup",this._map.getContainer()),this._tip=N_.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let t of this.options.className.split(" "))this._container.classList.add(t);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=function(t,e,i,r=!1){if(r||!i.getCoveringTilesDetailsProvider().allowWorldCopies())return t?.wrap();let n=new $u(t.lng,t.lat);if(t=new $u(t.lng,t.lat),e){let r=new $u(t.lng-360,t.lat),n=new $u(t.lng+360,t.lat),s=i.locationToScreenPoint(t).distSqr(e);i.locationToScreenPoint(r).distSqr(e)<s?t=r:i.locationToScreenPoint(n).distSqr(e)<s&&(t=n)}for(;Math.abs(t.lng-i.center.lng)>180;){let e=i.locationToScreenPoint(t);if(e.x>=0&&e.y>=0&&e.x<=i.width&&e.y<=i.height)break;t.lng>i.center.lng?t.lng-=360:t.lng+=360}return t.lng!==n.lng&&i.isPointOnMapSurface(i.locationToScreenPoint(t))?t:n}(this._lngLat,this._flatPos,this._map._camera.transform,this._trackPointer),t&&"point"in t&&t.point&&(e=t.point),this._trackPointer&&!e)return;let i=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map._camera.transform.locationToScreenPoint(this._lngLat));let r=this.options.anchor,n=YM(this.options.offset);if(!r){let t,e=this._container.offsetWidth,s=this._container.offsetHeight,o=function(t){return t?{top:t.top??0,right:t.right??0,bottom:t.bottom??0,left:t.left??0}:{top:0,right:0,bottom:0,left:0}}(this.options.padding);t=i.y+n.bottom.y<s+o.top?["top"]:i.y>this._map._camera.transform.height-s-o.bottom?["bottom"]:[],i.x<e/2+o.left?t.push("left"):i.x>this._map._camera.transform.width-e/2-o.right&&t.push("right"),r=0===t.length?"bottom":t.join("-")}let s=i.add(n[r]);this.options.subpixelPositioning||(s=s.round()),this._container.style.transform=`${qM[r]} translate(${s.x}px,${s.y}px)`,function(t,e,i){let r=t.classList;for(let t in qM)r.remove(`maplibregl-${i}-anchor-${t}`);r.add(`maplibregl-${i}-anchor-${e}`)}(this._container,r,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=Dt(Object.create(VM),t)}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._map.on("terrain",this._update),this._map.on("projectiontransition",this._update),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._update),this._map.on("mouseup",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new WM("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=$u.convert(t),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._update),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._update),this._map.on("drag",this._update),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(document.createTextNode(t))}setHTML(t){let e,i=document.createDocumentFragment(),r=document.createElement("body");for(r.innerHTML=t;e=r.firstChild,e;)i.appendChild(e);return this.setDOMContent(i)}getMaxWidth(){return this._container?.style.maxWidth}setMaxWidth(t){return this.options.maxWidth=t,this._update(),this}setDOMContent(t){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=N_.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(t),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(t){return this._container&&this._container.classList.add(t),this}removeClassName(t){return this._container&&this._container.classList.remove(t),this}setOffset(t){return this.options.offset=t,this._update(),this}toggleClassName(t){if(this._container)return this._container.classList.toggle(t)}setSubpixelPositioning(t){this.options.subpixelPositioning=t}setPadding(t){this.options.padding=t,this._update()}_createCloseButton(){this.options.closeButton&&(this._closeButton=N_.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let t=this._container.querySelector(ZM);t&&t.focus()}};function YM(t){if(!t)return YM(new l(0,0));if("number"==typeof t){let e=Math.round(Math.abs(t)/Math.SQRT2);return{center:new l(0,0),top:new l(0,t),"top-left":new l(e,e),"top-right":new l(-e,e),bottom:new l(0,-t),"bottom-left":new l(e,-e),"bottom-right":new l(-e,-e),left:new l(t,0),right:new l(-t,0)}}if(t instanceof l||Array.isArray(t)){let e=l.convert(t);return{center:e,top:e,"top-left":e,"top-right":e,bottom:e,"bottom-left":e,"bottom-right":e,left:e,right:e}}return{center:l.convert(t.center||[0,0]),top:l.convert(t.top||[0,0]),"top-left":l.convert(t["top-left"]||[0,0]),"top-right":l.convert(t["top-right"]||[0,0]),bottom:l.convert(t.bottom||[0,0]),"bottom-left":l.convert(t["bottom-left"]||[0,0]),"bottom-right":l.convert(t["bottom-right"]||[0,0]),left:l.convert(t.left||[0,0]),right:l.convert(t.right||[0,0])}}function XM(t){re.WORKER_URL=t}export{oe as AJAXError,TM as AttributionControl,VD as BoxZoomHandler,Dy as CanvasSource,DM as CooperativeGesturesHandler,gM as DoubleClickZoomHandler,wM as DragPanHandler,bM as DragRotateHandler,tt as EXTENT,nw as EdgeInsets,me as ErrorEvent,de as Event,_e as Evented,TD as GPUInitializationError,uy as GeoJSONSource,ID as Hash,wy as ImageSource,pM as KeyboardHandler,$u as LngLat,Qg as LngLatBounds,PM as LogoControl,LM as Map,Q_ as MapBoxZoomEvent,ig as MapContextEvent,V_ as MapLibreEvent,LM as MapLibreMap,X_ as MapMouseEvent,Z_ as MapMovementEvent,eg as MapProjectionEvent,Y_ as MapSourceDataEvent,H_ as MapStyleDataEvent,rg as MapStyleImageMissingEvent,W_ as MapStyleLoadEvent,tg as MapTerrainEvent,J_ as MapTouchEvent,K_ as MapWheelEvent,qu as MercatorCoordinate,NM as NavigationControl,l as Point,HM as Popup,WM as PopupEvent,ry as RasterDEMTileSource,iy as RasterTileSource,_M as ScrollZoomHandler,tb as Style,cM as TwoFingersTouchPitchHandler,hM as TwoFingersTouchRotateHandler,aM as TwoFingersTouchZoomHandler,xM as TwoFingersTouchZoomRotateHandler,ey as VectorTileSource,xy as VideoSource,re as config,vy as createTileMesh,Wg as getGlobalDispatcher,U_ as now,XM as setWorkerUrl}
|